Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Gaurav Suman" <gauravsuman007@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	media-ci@linuxtv.org
Subject: Re: [PATCH 8/8] media: i2c: Add ON Semiconductor LC898123F40 lens autofocus driver
Date: Mon, 09 Nov 2026 22:49:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-205770@kernel.org> (raw)
In-Reply-To: <20261109-sm8150-camera-v1-8-3d2e7b407516@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] media: i2c: lc898123: unlocked __v4l2_ctrl_handler_setup() in
  lc898123_open()
- [Medium] media: i2c: lc898123: missing runtime PM and unconditional
  init on every open()
- [Low] media: i2c: unsorted CONFIG_VIDEO_LC898123 entry in
  drivers/media/i2c/Makefile
--

commit 90488b1ee2e93be2704532224dc3a72b0184545b
Author: Gaurav Suman <gauravsuman007@gmail.com>

media: i2c: Add ON Semiconductor LC898123F40 lens autofocus driver

This commit adds a V4L2 lens sub-device driver for the autofocus function
of the ON Semiconductor LC898123F40 OIS/AF controller.

> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
> index 7e714dbcbf69d..836bf5b8a44e2 100644
> --- a/drivers/media/i2c/Makefile
> +++ b/drivers/media/i2c/Makefile
> @@ -36,6 +36,7 @@ obj-$(CONFIG_VIDEO_DW9714) += dw9714.o
>  obj-$(CONFIG_VIDEO_DW9719) += dw9719.o
>  obj-$(CONFIG_VIDEO_DW9768) += dw9768.o
>  obj-$(CONFIG_VIDEO_DW9807_VCM) += dw9807-vcm.o
> +obj-$(CONFIG_VIDEO_LC898123) += lc898123.o
>  obj-$(CONFIG_VIDEO_ET8EK8) += et8ek8/
>  obj-$(CONFIG_VIDEO_GC0308) += gc0308.o
>  obj-$(CONFIG_VIDEO_GC0310) += gc0310.o

[Severity: Low]
This isn't a bug, but entries in this Makefile are sorted alphabetically by
CONFIG symbol, so CONFIG_VIDEO_LC898123 belongs between CONFIG_VIDEO_KS0127
and CONFIG_VIDEO_LM3560.

> diff --git a/drivers/media/i2c/lc898123.c b/drivers/media/i2c/lc898123.c
> new file mode 100644
> index 0000000000000..69516ad964d60
> --- /dev/null
> +++ b/drivers/media/i2c/lc898123.c

[ ... ]

> +static int lc898123_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
> +{
> +	struct lc898123 *lc = container_of(sd, struct lc898123, sd);
> +	int ret = 0;
> +
> +	cci_write(lc->regmap, LC898123_REG_OIS_CTRL, 0, &ret);
> +	cci_write(lc->regmap, LC898123_REG_SERVO, 1, &ret);
> +	if (!ret)
> +		ret = __v4l2_ctrl_handler_setup(&lc->ctrls);
> +	return ret;
> +}

[Severity: Medium]
Should lc898123_open() call v4l2_ctrl_handler_setup(&lc->ctrls) instead of
__v4l2_ctrl_handler_setup(&lc->ctrls)?

subdev_open() invokes sd->internal_ops->open() without holding
lc->ctrls.lock, so calling the unlocked helper triggers
lockdep_assert_held(hdl->lock) on every open of the subdev node and races
with concurrent V4L2 control ioctls or open() calls when updating control
state and writing LC898123_REG_AF_POS.

> +
> +static const struct v4l2_subdev_internal_ops lc898123_internal_ops = {
> +	.open = lc898123_open,
> +};
> +
> +static const struct v4l2_subdev_ops lc898123_ops = { };
> +
> +static int lc898123_probe(struct i2c_client *client)
> +{
> +	struct lc898123 *lc;
> +	u64 val;
> +	int ret;
> +
> +	lc = devm_kzalloc(&client->dev, sizeof(*lc), GFP_KERNEL);
> +	if (!lc)
> +		return -ENOMEM;
> +	ret = devm_regulator_get_enable_optional(&client->dev, "vdd");
> +	if (ret && ret != -ENODEV)
> +		return dev_err_probe(&client->dev, ret, "vdd supply\n");
> +	if (!ret)
> +		usleep_range(10000, 12000);	/* controller boot from flash */
> +
> +	lc->regmap = devm_cci_regmap_init_i2c(client, 16);
> +	if (IS_ERR(lc->regmap))
> +		return PTR_ERR(lc->regmap);
> +	ret = cci_read(lc->regmap, LC898123_REG_AF_POS, &val, NULL);
> +	if (ret)
> +		return dev_err_probe(&client->dev, ret, "no response\n");
> +	cci_write(lc->regmap, LC898123_REG_SERVO, 1, NULL);

[Severity: Medium]
Does enabling the vdd supply and LC898123_REG_SERVO here without runtime PM
or a .close callback leave the regulator and VCM servo energized permanently
from boot?

Although linux/pm_runtime.h is included, runtime PM is never set up, so the
actuator draws current continuously even when the camera is idle or the
system is suspended.  In addition, the return value of cci_write() here is
ignored, and lc898123_open() unconditionally rewrites LC898123_REG_OIS_CTRL,
LC898123_REG_SERVO and LC898123_REG_AF_POS on every open() of the subdev
node, which can disturb an active camera session if another process opens
the device node.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261109-sm8150-camera-v1-0-3d2e7b407516@gmail.com?part=8

      reply	other threads:[~2026-11-09 22:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 22:38 [PATCH 0/8] Add SM8150 CAMSS and LG G8x ThinQ camera sensors Gaurav Suman via B4 Relay
2026-11-09 22:38 ` [PATCH 1/8] dt-bindings: media: Add qcom,sm8150-camss Gaurav Suman via B4 Relay
2026-11-09 22:56   ` sashiko-bot
2026-11-10  8:13   ` Krzysztof Kozlowski
2026-11-09 22:38 ` [PATCH 2/8] media: qcom: camss: Add SM8150 support Gaurav Suman via B4 Relay
2026-11-09 22:56   ` sashiko-bot
2026-11-10  0:00   ` Bryan O'Donoghue
2026-11-09 22:38 ` [PATCH 3/8] dt-bindings: media: i2c: Add Samsung S5K3M3 image sensor Gaurav Suman via B4 Relay
2026-11-09 22:43   ` sashiko-bot
2026-11-10  8:16   ` Krzysztof Kozlowski
2026-11-09 22:38 ` [PATCH 4/8] media: i2c: Add Samsung S5K3M3 image sensor driver Gaurav Suman via B4 Relay
2026-11-09 22:52   ` sashiko-bot
2026-11-10  0:04   ` Bryan O'Donoghue
2026-11-10  8:18   ` Krzysztof Kozlowski
2026-11-09 22:38 ` [PATCH 5/8] dt-bindings: media: i2c: Add Samsung S5KGD1 image sensor Gaurav Suman via B4 Relay
2026-11-10  8:18   ` Krzysztof Kozlowski
2026-11-09 22:38 ` [PATCH 6/8] media: i2c: Add Samsung S5KGD1 image sensor driver Gaurav Suman via B4 Relay
2026-11-09 22:54   ` sashiko-bot
2026-11-09 22:38 ` [PATCH 7/8] dt-bindings: media: i2c: Add ON Semiconductor LC898123F40 Gaurav Suman via B4 Relay
2026-11-10  8:20   ` Krzysztof Kozlowski
2026-11-09 22:38 ` [PATCH 8/8] media: i2c: Add ON Semiconductor LC898123F40 lens autofocus driver Gaurav Suman via B4 Relay
2026-11-09 22:49   ` sashiko-bot [this message]

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-205770@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gauravsuman007@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox