[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<PN3P287MB35199EB9309448F3EDD43402FF51A@PN3P287MB3519.INDP287.PROD.OUTLOOK.COM>
Date: Thu, 17 Jul 2025 13:11:53 +0000
From: Hardevsinh Palaniya <hardevsinh.palaniya@...iconsignals.io>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
CC: "sakari.ailus@...ux.intel.com" <sakari.ailus@...ux.intel.com>,
"laurent.pinchart@...asonboard.com" <laurent.pinchart@...asonboard.com>,
"krzk+dt@...nel.org" <krzk+dt@...nel.org>, Himanshu Bhavani
<himanshu.bhavani@...iconsignals.io>, Mauro Carvalho Chehab
<mchehab@...nel.org>, Rob Herring <robh@...nel.org>, Conor Dooley
<conor+dt@...nel.org>, Hans Verkuil <hverkuil@...all.nl>, Ricardo Ribalda
<ribalda@...omium.org>, Bryan O'Donoghue <bryan.odonoghue@...aro.org>, Hans
de Goede <hansg@...nel.org>, André Apitzsch
<git@...tzsch.eu>, Sylvain Petinot <sylvain.petinot@...s.st.com>, Matthias
Fend <matthias.fend@...end.at>, Dongcheng Yan <dongcheng.yan@...el.com>,
Benjamin Mugnier <benjamin.mugnier@...s.st.com>, Heimir Thor Sverrisson
<heimir.sverrisson@...il.com>, Jingjing Xiong <jingjing.xiong@...el.com>,
Arnd Bergmann <arnd@...db.de>, "linux-media@...r.kernel.org"
<linux-media@...r.kernel.org>, "devicetree@...r.kernel.org"
<devicetree@...r.kernel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 2/2] media: i2c: add ov2735 image sensor driver
Hi Andy,
> On Thu, Jul 17, 2025 at 07:26:49AM +0000, Hardevsinh Palaniya wrote:
> > > On Wed, Jul 16, 2025 at 07:14:17PM +0530, Hardevsinh Palaniya wrote:
>
> ...
>
> > > > +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.
>
> Can you elaborate a bit how the *err is not 0 at this point
> (assuming err != NULL)?
A previous operation have already failed and stored a non-
zero error code in *err.
Assuming this function is used in a sequence of write (or read)
operations. If the current operation succeeds (i.e., ret == 0) and we
unconditionally write *err = ret, we would overwrite the
existing error with 0, falsely indicating that all operations
were successful.
Therefore, the condition if (ret && err) ensures that we only
update *err when there's a new error, preserving any previously
recorded failures.
Let me know if you have a different suggestion for how this should
be handled.
Best Regards,
Hardev
Powered by blists - more mailing lists