[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aH53L948F7m16eHZ@smile.fi.intel.com>
Date: Mon, 21 Jul 2025 20:21:51 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Hardevsinh Palaniya <hardevsinh.palaniya@...iconsignals.io>
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
On Thu, Jul 17, 2025 at 01:11:53PM +0000, Hardevsinh Palaniya wrote:
> > 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;
^^^ (1)
> > > > > + 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.
Right and this function is no-op already for this case.
> 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.
I don't see this scenario. I see that we apply *err = 0 when *err == 0 already.
> 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.
Have you taken into account 1) above?
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists