Re: [PATCH v4 2/2] media: i2c: add ov2735 image sensor driver

From: Hardevsinh Palaniya
Date: Thu Jul 17 2025 - 03:27:12 EST


Hi Andy,

> On Wed, Jul 16, 2025 at 07:14:17PM +0530, Hardevsinh Palaniya wrote:
> > Add a v4l2 subdevice driver for the Omnivision OV2735 sensor.
> >
> > The Omnivision OV2735 is a 1/2.7-Inch CMOS image sensor with an
> > active array size of 1920 x 1080.
> >
> > The following features are supported:
> > - Manual exposure an gain control support
> > - vblank/hblank control support
> > - Test pattern support control
> > - Supported resolution: 1920 x 1080 @ 30fps (SGRBG10)
>
> ...
>
> > +static int ov2735_page_access(struct ov2735 *ov2735,
> > +                           u32 reg, void *val, int *err, bool is_read)
> > +{
> > +     u8 page = (reg >> CCI_REG_PRIVATE_SHIFT) & 0xff;
> > +     u32 addr = reg & ~CCI_REG_PRIVATE_MASK;
> > +     int ret = 0;
> > +
> > +     if (err && *err)
> > +             return *err;
> > +
> > +     mutex_lock(&ov2735->page_lock);
> > +
> > +     /* Perform page access before read/write */
> > +     if (ov2735->current_page != page) {
> > +             ret = cci_write(ov2735->cci, OV2735_REG_PAGE_SELECT, page, &ret);
> > +             if (ret)
> > +                     goto err_mutex_unlock;
> > +             ov2735->current_page = page;
> > +     }
> > +
> > +     if (is_read)
> > +             ret = cci_read(ov2735->cci, addr, (u64 *)val, err);
> > +     else
> > +             ret = cci_write(ov2735->cci, addr, *(u64 *)val, err);
> > +
> > +err_mutex_unlock:
>
> > +     if (ret && err)
>
> Why do you need to check for ret != 0?

To prevents overwriting *err with 0 on successful operations, which could
obscure previous errors.

Best Regards,
Hardev