All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hikmah Gumelar" <hikmahgumelar@gmail.com>
Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v2 5/7] media: i2c: add ov12a10 image sensor driver
Date: Mon, 23 Nov 2026 12:57:53 +0000	[thread overview]
Message-ID: <sashiko-outbox-229277@kernel.org> (raw)
In-Reply-To: <20261123123546.152162-6-hikmahgumelar@gmail.com>

Thank you for your contribution! Sashiko AI review found 11 potential
issues to consider:
- [High] media: i2c: ov12a10: missing IS_ERR() checks on GPIOs in
  ov12a10_probe()
- [Medium] media: i2c: ov12a10: missing vana_gpio rollback in
  ov12a10_power_on()
- [Medium] media: i2c: ov12a10: missing v4l2_subdev_cleanup() in probe()
  and remove()
- [Medium] media: i2c: ov12a10: uninitialized active state in
  ov12a10_set_format()
- [Medium] media: i2c: ov12a10: runtime PM ordering in probe() and
  ov12a10_set_ctrl()
- [Medium] media: i2c: ov12a10: missing test pattern enable bit in
  ov12a10_set_ctrl()
- [Medium] media: i2c: ov12a10: missing exposure range update in
  ov12a10_set_ctrl()
- [Low] media: i2c: ov12a10: missing fwnode endpoint validation in
  ov12a10_probe()
- [Low] media: i2c: ov12a10: mismatched OV12A10_REG_EXPOSURE and unused
  macros
- [Low] media: i2c: ov12a10: missing pm_ptr() and
  DEFINE_RUNTIME_DEV_PM_OPS()
- [Low] media: i2c: ov12a10: empty commit message and coding style
  violations
--

commit 87e706783d08e4892b5ba94e037a4944e990a93f
Author: Hikmah Gumelar <hikmahgumelar@gmail.com>

> media: i2c: add ov12a10 image sensor driver
>
> Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com>

[Severity: Low]
This commit adds a new V4L2 image sensor driver with an empty commit
message body.  Please include a description of the OmniVision OV12A10
sensor and the features supported by the driver.

> diff --git a/drivers/media/i2c/ov12a10.c b/drivers/media/i2c/ov12a10.c
> new file mode 100644
> index 0000000000000..ce2e01bc67e0c
> --- /dev/null
> +++ b/drivers/media/i2c/ov12a10.c
> @@ -0,0 +1,720 @@

[ ... ]

> +#define OV12A10_CHIP_ID_REG		0x300a
> +#define OV12A10_CHIP_ID			0x5612
> +#define OV12A10_REG_MODE_SELECT		0x0100
> +#define OV12A10_MODE_STANDBY		0x00
> +#define OV12A10_MODE_STREAMING		0x01
> +#define OV12A10_REG_VTS			0x380e
> +#define OV12A10_REG_EXPOSURE		0x3501
> +#define OV12A10_REG_ANALOG_GAIN		0x3508
> +#define OV12A10_REG_TEST_PATTERN		0x5080
> +#define OV12A10_XVCLK_FREQ		24000000
> +#define OV12A10_LINK_FREQ_216MHZ		216000000ULL
> +#define OV12A10_PIXEL_RATE		144000000ULL

[Severity: Low]
Should OV12A10_REG_EXPOSURE be 0x3500 instead of 0x3501?
ov12a10_set_ctrl() performs a 3-byte write for V4L2_CID_EXPOSURE starting
at hardcoded register 0x3500, leaving OV12A10_REG_EXPOSURE unused.
OV12A10_MODE_STREAMING is also unused because ov12a10_set_stream() uses a
local stream_on_regs[] table with raw values { 0x0100, 0x01 }.

> +
> +struct ov12a10_reg { u16 address;
> +u8 val;
> +};

[Severity: Low]
This isn't a bug, but the formatting of struct ov12a10_reg, the
misaligned break statements in ov12a10_set_ctrl(), and the goto labels
sharing lines with cleanup calls in ov12a10_probe() do not follow kernel
coding style.

[ ... ]

> +static int ov12a10_power_on(struct device *dev)
> +{
> +	struct ov12a10 *ov12a10 = to_ov12a10(dev_get_drvdata(dev));
> +	int ret;
> +
> +	if (ov12a10->vana_gpio)
> +		gpiod_set_value_cansleep(ov12a10->vana_gpio, 1);
> +
> +	ret = regulator_bulk_enable(OV12A10_NUM_SUPPLIES, ov12a10->supplies);
> +	if (ret)
> +		return ret;
> +
> +	ret = clk_prepare_enable(ov12a10->xvclk);
> +	if (ret) {
> +		regulator_bulk_disable(OV12A10_NUM_SUPPLIES, ov12a10->supplies);
> +		return ret;
> +	}

[Severity: Medium]
Does ov12a10_power_on() leave ov12a10->vana_gpio asserted high when
regulator_bulk_enable() or clk_prepare_enable() fails?

[ ... ]

> +static int ov12a10_set_ctrl(struct v4l2_ctrl *ctrl)
> +{
> +	struct ov12a10 *ov12a10 = container_of(ctrl->handler, struct ov12a10, ctrl_handler);
> +	int ret = 0;
> +
> +	if (!pm_runtime_get_if_in_use(ov12a10->dev))
> +		return 0;

[Severity: Medium]
Can pm_runtime_get_if_in_use() return -EINVAL here without incrementing
the runtime PM usage counter?

When runtime PM is disabled (for example on a kernel without CONFIG_PM,
or during the window in ov12a10_probe() where
v4l2_async_register_subdev_sensor() runs before pm_runtime_enable()),
pm_runtime_get_if_in_use() returns -EINVAL, so ov12a10_set_ctrl()
proceeds to write registers and calls an unbalanced pm_runtime_put() that
underflows usage_count.  Checking pm_runtime_get_if_in_use(ov12a10->dev)
<= 0 and enabling runtime PM before registering the async subdevice in
ov12a10_probe() would avoid both issues.

> +	switch (ctrl->id) {
> +	case V4L2_CID_ANALOGUE_GAIN:
> +		ret = ov12a10_write_reg(ov12a10, OV12A10_REG_ANALOG_GAIN, 2, ctrl->val);
> +	break;
> +	case V4L2_CID_EXPOSURE:
> +		ret = ov12a10_write_reg(ov12a10, 0x3500, 3, ctrl->val << 4);
> +	break;
> +	case V4L2_CID_VBLANK:
> +		ret = ov12a10_write_reg(ov12a10, OV12A10_REG_VTS, 2,
> +				ov12a10->cur_mode->height + ctrl->val);
> +	break;

[Severity: Medium]
Should changing V4L2_CID_VBLANK also update the range of
ov12a10->exposure via __v4l2_ctrl_modify_range() before the
pm_runtime_get_if_in_use() check?  Without that, lowering V4L2_CID_VBLANK
(for example to its minimum of 124, giving VTS = 844) leaves
ov12a10->exposure with a maximum of 3360 and default of 2400, allowing
exposure values that exceed VTS.

> +	case V4L2_CID_TEST_PATTERN:
> +		ret = ov12a10_write_reg(ov12a10, OV12A10_REG_TEST_PATTERN, 1, ctrl->val);
> +	break;

[Severity: Medium]
Does writing ctrl->val directly to OV12A10_REG_TEST_PATTERN (0x5080)
leave the test pattern generator disabled for non-zero menu items?  On
OmniVision sensors using register 0x5080, BIT(7) must be set to enable
test pattern output.

[ ... ]

> +static int ov12a10_set_format(struct v4l2_subdev *sd, const struct v4l2_subdev_client_info *ci, struct v4l2_subdev_state *sd_state,
> +		struct v4l2_subdev_format *fmt)
> +{
> +	struct ov12a10 *ov12a10 = to_ov12a10(sd);
> +
> +	ov12a10_update_pad_format(&supported_modes[0], &fmt->format);
> +	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
> +		*v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
> +	else
> +		ov12a10->cur_mode = &supported_modes[0];
> +
> +	return 0;
> +}

[Severity: Medium]
Does this leave sd->active_state uninitialized when fmt->which is
V4L2_SUBDEV_FORMAT_ACTIVE?

ov12a10_probe() calls v4l2_subdev_init_finalize(), but
ov12a10_internal_ops implements .open instead of .init_state and
ov12a10_set_format() only writes to sd_state for V4L2_SUBDEV_FORMAT_TRY.
As a result, sd->active_state->pads[0].format stays zero-initialized for
the lifetime of the subdevice, breaking format queries or link validation
in callers that inspect active subdev state.

[ ... ]

> +static int ov12a10_probe(struct i2c_client *client)
> +{
> +	struct device *dev = &client->dev;
> +	struct ov12a10 *ov12a10;
> +	u32 val = 0;
> +	unsigned int i;
> +	int ret;

[Severity: Low]
Should ov12a10_probe() parse and validate the fwnode graph endpoint using
v4l2_fwnode_endpoint_alloc_parse()?  The DT binding requires a port
endpoint with 4 CSI-2 data lanes and a 216 MHz link-frequencies property,
which are currently never checked.

> +
> +	ov12a10 = devm_kzalloc(dev, sizeof(*ov12a10), GFP_KERNEL);
> +	if (!ov12a10)
> +		return -ENOMEM;
> +	ov12a10->dev = dev;
> +	v4l2_i2c_subdev_init(&ov12a10->sd, client, &ov12a10_subdev_ops);
> +	ov12a10->xvclk = devm_v4l2_sensor_clk_get(dev, NULL);
> +	if (IS_ERR(ov12a10->xvclk))
> +		return dev_err_probe(dev, PTR_ERR(ov12a10->xvclk), "xvclk\n");
> +	clk_set_rate(ov12a10->xvclk, OV12A10_XVCLK_FREQ);
> +	ov12a10->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> +	ov12a10->vana_gpio = devm_gpiod_get_optional(dev, "vana", GPIOD_OUT_LOW);
> +	ov12a10->pwdn_gpio = devm_gpiod_get_optional(dev, "pwdn", GPIOD_OUT_HIGH);
> +	if (IS_ERR(ov12a10->reset_gpio))
> +		return dev_err_probe(dev, PTR_ERR(ov12a10->reset_gpio), "reset\n");

[Severity: High]
What happens if devm_gpiod_get_optional() returns an error or
-EPROBE_DEFER for ov12a10->vana_gpio or ov12a10->pwdn_gpio?

Because only ov12a10->reset_gpio is checked with IS_ERR(), a non-NULL
ERR_PTR stored in vana_gpio or pwdn_gpio passes the truthiness checks in
ov12a10_power_on() and ov12a10_power_off() and is passed straight to
gpiod_set_value_cansleep(), triggering a warning in gpiolib and breaking
probe deferral.

[ ... ]

> +	ret = v4l2_subdev_init_finalize(&ov12a10->sd);
> +	if (ret)
> +		goto err_media;
> +	ret = v4l2_async_register_subdev_sensor(&ov12a10->sd);
> +	if (ret)
> +		goto err_media;
> +	pm_runtime_set_active(dev);
> +	pm_runtime_enable(dev);
> +	pm_runtime_idle(dev);
> +	return 0;
> +err_media: media_entity_cleanup(&ov12a10->sd.entity);
> +err_ctrl: v4l2_ctrl_handler_free(ov12a10->sd.ctrl_handler);
> +err_mutex: mutex_destroy(&ov12a10->mutex);
> +err_power: ov12a10_power_off(dev);
> +	return ret;
> +}
> +
> +static void ov12a10_remove(struct i2c_client *client)
> +{
> +	struct v4l2_subdev *sd = i2c_get_clientdata(client);
> +	struct ov12a10 *ov12a10 = to_ov12a10(sd);
> +
> +	v4l2_async_unregister_subdev(sd);
> +	media_entity_cleanup(&sd->entity);
> +	v4l2_ctrl_handler_free(sd->ctrl_handler);

[Severity: Medium]
Does omitting v4l2_subdev_cleanup() in ov12a10_remove() and on the
v4l2_async_register_subdev_sensor() error path in ov12a10_probe() leak
sd->active_state allocated by v4l2_subdev_init_finalize()?

[ ... ]

> +static const struct dev_pm_ops ov12a10_pm_ops = { SET_RUNTIME_PM_OPS(ov12a10_power_off,
> +		ov12a10_power_on, NULL) };
> +static const struct of_device_id ov12a10_of_match[] = { { .compatible = "ovti,ov12a10" }, { } };
> +MODULE_DEVICE_TABLE(of, ov12a10_of_match);
> +static struct i2c_driver ov12a10_i2c_driver = {
> +	.driver = { .name = "ov12a10", .pm = &ov12a10_pm_ops, .of_match_table = ov12a10_of_match },

[Severity: Low]
This isn't a bug, but using DEFINE_RUNTIME_DEV_PM_OPS() for
ov12a10_pm_ops and wrapping .pm with pm_ptr(&ov12a10_pm_ops) would allow
the PM callbacks to be dropped when CONFIG_PM is disabled.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123123546.152162-1-hikmahgumelar@gmail.com?part=5

  reply	other threads:[~2026-11-23 12:57 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 11:07 [PATCH 0/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 1/6] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 2/6] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar
2026-11-23 15:11   ` Rob Herring (Arm)
2026-11-23 11:08 ` [PATCH 3/6] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 4/6] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 5/6] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 6/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar
2026-11-23 12:35   ` [PATCH v2 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar
2026-11-23 12:42     ` sashiko-bot
2026-11-23 12:35   ` [PATCH v2 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar
2026-11-23 12:43     ` sashiko-bot
2026-11-23 15:11     ` Rob Herring (Arm)
2026-11-23 12:35   ` [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar
2026-11-23 12:52     ` sashiko-bot
2026-11-23 13:56     ` Uwe Kleine-König
2026-11-23 14:14       ` Hikmah Gumelar
2026-11-23 12:35   ` [PATCH v2 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar
2026-11-23 12:45     ` sashiko-bot
2026-11-23 15:11     ` Rob Herring (Arm)
2026-11-23 12:35   ` [PATCH v2 5/7] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar
2026-11-23 12:57     ` sashiko-bot [this message]
2026-11-23 12:35   ` [PATCH v2 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states Hikmah Gumelar
2026-11-23 12:49     ` sashiko-bot
2026-11-23 12:35   ` [PATCH v2 7/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-23 12:52     ` sashiko-bot
2026-11-23 15:27   ` [PATCH v3 0/7] " Hikmah Gumelar
2026-11-23 15:27     ` [PATCH v3 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar
2026-11-23 19:18       ` Abel Vesa
2026-11-23 15:27     ` [PATCH v3 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar
2026-11-23 17:25       ` Konrad Dybcio
2026-11-23 15:27     ` [PATCH v3 3/7] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar
2026-11-23 15:53       ` sashiko-bot
2026-11-23 15:27     ` [PATCH v3 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar
2026-11-23 15:27     ` [PATCH v3 5/7] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar
2026-11-23 15:50       ` sashiko-bot
2026-11-23 15:27     ` [PATCH v3 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states Hikmah Gumelar
2026-11-23 15:27     ` [PATCH v3 7/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-23 15:46       ` sashiko-bot

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=sashiko-outbox-229277@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hikmahgumelar@gmail.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.