From: Hardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "sakari.ailus@linux.intel.com" <sakari.ailus@linux.intel.com>,
"laurent.pinchart@ideasonboard.com"
<laurent.pinchart@ideasonboard.com>,
"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
"Himanshu Bhavani" <himanshu.bhavani@siliconsignals.io>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Hans Verkuil" <hverkuil@xs4all.nl>,
"Ricardo Ribalda" <ribalda@chromium.org>,
"Bryan O'Donoghue" <bryan.odonoghue@linaro.org>,
"Hans de Goede" <hansg@kernel.org>,
"André Apitzsch" <git@apitzsch.eu>,
"Sylvain Petinot" <sylvain.petinot@foss.st.com>,
"Matthias Fend" <matthias.fend@emfend.at>,
"Dongcheng Yan" <dongcheng.yan@intel.com>,
"Benjamin Mugnier" <benjamin.mugnier@foss.st.com>,
"Heimir Thor Sverrisson" <heimir.sverrisson@gmail.com>,
"Jingjing Xiong" <jingjing.xiong@intel.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 2/2] media: i2c: add ov2735 image sensor driver
Date: Thu, 17 Jul 2025 13:11:53 +0000 [thread overview]
Message-ID: <PN3P287MB35199EB9309448F3EDD43402FF51A@PN3P287MB3519.INDP287.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <aHjubei5Aex9n-HI@smile.fi.intel.com>
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
next prev parent reply other threads:[~2025-07-17 13:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-16 13:44 [PATCH v4 0/2] media: i2c: Add ov2735 camera " Hardevsinh Palaniya
2025-07-16 13:44 ` [PATCH v4 1/2] dt-bindings: media: i2c: Add ov2735 sensor Hardevsinh Palaniya
2025-07-16 13:58 ` Hardevsinh Palaniya
2025-07-17 6:26 ` Krzysztof Kozlowski
2025-07-17 6:30 ` Krzysztof Kozlowski
2025-07-17 7:28 ` Hardevsinh Palaniya
2025-07-17 11:00 ` Krzysztof Kozlowski
2025-07-17 11:55 ` Hardevsinh Palaniya
2025-07-17 13:00 ` Krzysztof Kozlowski
2025-07-17 13:30 ` Hardevsinh Palaniya
2025-07-16 13:44 ` [PATCH v4 2/2] media: i2c: add ov2735 image sensor driver Hardevsinh Palaniya
2025-07-16 14:46 ` Andy Shevchenko
2025-07-17 7:26 ` Hardevsinh Palaniya
2025-07-17 12:37 ` Andy Shevchenko
2025-07-17 13:11 ` Hardevsinh Palaniya [this message]
2025-07-21 17:21 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=PN3P287MB35199EB9309448F3EDD43402FF51A@PN3P287MB3519.INDP287.PROD.OUTLOOK.COM \
--to=hardevsinh.palaniya@siliconsignals.io \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=benjamin.mugnier@foss.st.com \
--cc=bryan.odonoghue@linaro.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dongcheng.yan@intel.com \
--cc=git@apitzsch.eu \
--cc=hansg@kernel.org \
--cc=heimir.sverrisson@gmail.com \
--cc=himanshu.bhavani@siliconsignals.io \
--cc=hverkuil@xs4all.nl \
--cc=jingjing.xiong@intel.com \
--cc=krzk+dt@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=matthias.fend@emfend.at \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=sylvain.petinot@foss.st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®