From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io>
Cc: "Kieran Bingham" <kieran.bingham@ideasonboard.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"sakari.ailus@linux.intel.com" <sakari.ailus@linux.intel.com>,
"Himanshu Bhavani" <himanshu.bhavani@siliconsignals.io>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@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>,
"Benjamin Mugnier" <benjamin.mugnier@foss.st.com>,
"Matthias Fend" <matthias.fend@emfend.at>,
"Heimir Thor Sverrisson" <heimir.sverrisson@gmail.com>,
"Sylvain Petinot" <sylvain.petinot@foss.st.com>,
"Dongcheng Yan" <dongcheng.yan@intel.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 v5 2/2] media: i2c: add ov2735 image sensor driver
Date: Sat, 26 Jul 2025 12:43:13 +0300 [thread overview]
Message-ID: <20250726094313.GD27425@pendragon.ideasonboard.com> (raw)
In-Reply-To: <PN3P287MB3519055FE42890F5F577B51BFF58A@PN3P287MB3519.INDP287.PROD.OUTLOOK.COM>
On Sat, Jul 26, 2025 at 06:06:05AM +0000, Hardevsinh Palaniya wrote:
> > Quoting Hardevsinh Palaniya (2025-07-25 06:55:23)
> > <snip>
> > > > > +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;
> > > >
> > > > ' & 0xff' part is redundant.
> > > >
> > > > > +���� u32 addr = reg & ~CCI_REG_PRIVATE_MASK;
> > > > > +���� int ret = 0;
> > > >
> > > > How is this assignment being used?
> > > >
> > > > > +���� 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, err);
> > > > > +������������ 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);
> > > >
> > > > Do you really need this castings?
> > >
> > > Do you really think this casting is unnecessary?
> > >
> >
> > Yes? Well quite probably - I haven't checked myself yet but ..
> >
> >
> > > Please check the definitions of cci_read/write
> > >
> > > without this, we can't even build the driver.
> >
> > How about ... changing the function prototype of ov2735_page_access ?
>
> Of course, changing the function prototype would work.
>
> My intention is to keep a single ov2735_page_access() function that can
> handle both read and write operations. The cci_read() function expects
> a u64 *, whereas cci_write() expects a u64 value. To support both cases
> within one function, I’ve used a void *val and cast it appropriately
> depending on the operation.
>
> If we were to remove the casting, we would need to split this into two
> separate functions, one for read and one for write, even though the only
> difference between them would be a single line. I’d prefer to avoid that
> redundancy and keep the code compact.
>
> Let me know if you see a better way to handle this without duplicating
> the logic.
Move the cci_read() and cci_write() calls from the bottom of
ov2735_page_access() to ov2735_read() and ov2735_write() respectively.
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2025-07-26 9:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-24 10:47 [PATCH v5 0/2] media: i2c: Add ov2735 camera sensor driver Hardevsinh Palaniya
2025-07-24 10:47 ` [PATCH v5 1/2] dt-bindings: media: i2c: Add ov2735 sensor Hardevsinh Palaniya
2025-07-24 10:47 ` [PATCH v5 2/2] media: i2c: add ov2735 image sensor driver Hardevsinh Palaniya
2025-07-24 21:17 ` Andy Shevchenko
2025-07-25 5:55 ` Hardevsinh Palaniya
2025-07-25 14:40 ` Kieran Bingham
2025-07-26 6:06 ` Hardevsinh Palaniya
2025-07-26 9:43 ` Laurent Pinchart [this message]
2025-07-29 6:35 ` Hardevsinh Palaniya
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=20250726094313.GD27425@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--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=hardevsinh.palaniya@siliconsignals.io \
--cc=heimir.sverrisson@gmail.com \
--cc=himanshu.bhavani@siliconsignals.io \
--cc=hverkuil@xs4all.nl \
--cc=jingjing.xiong@intel.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=krzk+dt@kernel.org \
--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