From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Hardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io>
Cc: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.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, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/2] media: i2c: add ov2735 image sensor driver
Date: Fri, 25 Jul 2025 00:17:08 +0300 [thread overview]
Message-ID: <aIKi1BkNzNvsf5Tr@smile.fi.intel.com> (raw)
In-Reply-To: <20250724104711.18764-3-hardevsinh.palaniya@siliconsignals.io>
On Thu, Jul 24, 2025 at 04:17:05PM +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)
...
> MAINTAINERS | 9 +
This should be started as part of patch 1 as in between you will have a
dangling file, which is not recorded in MAINTAINERS.
...
> + * Inspired from ov8858, imx219, imx283 camera drivers
Missing period at the end.
...
> +#include <linux/array_size.h>
+ bitops.h
> +#include <linux/clk.h>
> +#include <linux/container_of.h>
> +#include <linux/delay.h>
> +#include <linux/device/devres.h>
> +#include <linux/err.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/i2c.h>
> +#include <linux/module.h>
> +#include <linux/mutex.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/property.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/units.h>
> +#include <linux/types.h>
> +#include <vdso/time64.h>
We do not include vdso in the (regular) drivers. Use linux/time.h.
...
> +struct ov2735 {
> + struct device *dev;
Do you need this? Can't it be derived from regmap cci below?
> + struct regmap *cci;
> + struct v4l2_subdev sd;
> + struct media_pad pad;
> + struct i2c_client *client;
Do you need this?
> + struct clk *xclk;
> + struct gpio_desc *reset_gpio;
> + struct gpio_desc *enable_gpio;
> + struct regulator_bulk_data supplies[ARRAY_SIZE(ov2735_supply_name)];
> +
> + /* V4L2 Controls */
> + struct v4l2_ctrl_handler handler;
> + struct v4l2_ctrl *link_freq;
> + struct v4l2_ctrl *pixel_rate;
> + struct v4l2_ctrl *hblank;
> + struct v4l2_ctrl *vblank;
> + struct v4l2_ctrl *gain;
> + struct v4l2_ctrl *exposure;
> + struct v4l2_ctrl *test_pattern;
> +
> + u32 link_freq_index;
> +
> + u8 current_page;
> + struct mutex page_lock;
> +};
...
> +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?
> +
> +err_mutex_unlock:
> + mutex_unlock(&ov2735->page_lock);
> + return ret;
Hmm... Wouldn't be cleanup.h helpful here?
> +}
...
> +static int ov2735_write(struct ov2735 *ov2735, u32 reg, u64 val, int *err)
> +{
> + return ov2735_page_access(ov2735, reg, (void *)&val, err, false);
Why casting?
> +}
...
> +static int ov2735_set_pll_ctrl(struct ov2735 *ov2735)
> +{
> + struct ov2735_pll_parameters *pll_parameters;
> + u8 pll_ctrl;
> + u8 pll_outdiv;
> + int ret = 0;
> +
> + pll_parameters = &pll_configs[ov2735->link_freq_index];
> +
> + /* BIT[7]: pll_clk_sel, BIT[6:2]: pll_nc, BIT[1:0]: pll_mc */
> + pll_ctrl = ((pll_parameters->pll_nc << 2) |
> + (pll_parameters->pll_mc << 0)) & OV2735_REG_PLL_ENABLE;
Logically better to wrap like this (yes, I know that it's slightly longer than 80):
pll_ctrl = ((pll_parameters->pll_nc << 2) | (pll_parameters->pll_mc << 0)) &
OV2735_REG_PLL_ENABLE;
> + pll_outdiv = pll_parameters->pll_outdiv;
> +
> + ov2735_write(ov2735, OV2735_REG_PLL_CTRL, pll_ctrl, &ret);
> + ov2735_write(ov2735, OV2735_REG_PLL_OUTDIV, pll_outdiv, &ret);
> +
> + return ret;
> +}
...
> + /* Apply format settings. */
> + /* Apply customized values from user */
Define a single style for one-line comments and use it everywhere consistently.
> + goto error_power_off;
...
> + devm_pm_runtime_set_active_enabled(ov2735->dev);
> + devm_pm_runtime_get_noresume(ov2735->dev);
No error checks? What's the point to use devm and what will happen if the first
fails, for example?
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-07-24 21:17 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 [this message]
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
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=aIKi1BkNzNvsf5Tr@smile.fi.intel.com \
--to=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=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