Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wenmeng Liu" <wenmeng.liu@oss.qualcomm.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v3 2/3] media: i2c: og0ve1b: Introduce per-sensor data structure
Date: Wed, 08 Jul 2026 14:45:33 +0000	[thread overview]
Message-ID: <20260708144534.1DE821F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708-og0va1b-v3-2-de8e44455a42@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Incorrect evaluation of pm_runtime_get_if_active() return value leads to unbalanced pm_runtime_put() and usage counter underflow when Runtime PM is disabled.
--

--- Patch [2]: [PATCH v3 2/3] media: i2c: og0ve1b: Introduce per-sensor data structure ---
commit 7e9c88bb94dde2349f9f1531e2c8f8721c3dd997
Author: Wenmeng Liu <wenmeng.liu@oss.qualcomm.com>

    media: i2c: og0ve1b: Introduce per-sensor data structure

    Refactor the driver to separate sensor-specific data from the common
    driver code. Introduce a sensor_data structure, populated through
    i2c_get_match_data(), to hold the chip ID, MCLK frequency, link
    frequencies and supported modes.

> diff --git a/drivers/media/i2c/og0ve1b.c b/drivers/media/i2c/og0ve1b.c
> index 84a28cdcade10..041342fbe3c82 100644
> --- a/drivers/media/i2c/og0ve1b.c
> +++ b/drivers/media/i2c/og0ve1b.c
[ ... ]
> @@ -273,11 +287,21 @@ static int og0ve1b_enable_test_pattern(struct og0ve1b *og0ve1b, u32 pattern)
>  	return cci_write(og0ve1b->regmap, OG0VE1B_REG_PRE_ISP, val, NULL);
>  }
>  
> +static const struct og0ve1b_sensor_data og0ve1b_data = {
> +	.chip_id = OG0VE1B_CHIP_ID,
> +	.mclk_freq = OG0VE1B_MCLK_FREQ_24MHZ,
> +	.enable_test_pattern = og0ve1b_enable_test_pattern,
> +	.link_freq_menu = og0ve1b_link_freq_menu,
> +	.num_link_freqs = ARRAY_SIZE(og0ve1b_link_freq_menu),
> +	.modes = og0ve1b_supported_modes,
> +	.num_modes = ARRAY_SIZE(og0ve1b_supported_modes),
> +};
> +
>  static int og0ve1b_set_ctrl(struct v4l2_ctrl *ctrl)
>  {
>  	struct og0ve1b *og0ve1b = container_of(ctrl->handler, struct og0ve1b,
>  					       ctrl_handler);
> -	const struct og0ve1b_mode *mode = &supported_modes[0];
> +	const struct og0ve1b_mode *mode = &og0ve1b->data->modes[0];
>  	s64 exposure_max;
>  	int ret;
>  

[Severity: High]
This is a pre-existing issue, but does the pm_runtime_get_if_active()
check later in og0ve1b_set_ctrl() properly handle negative error codes?

The function currently checks the runtime PM state with:

	if (!pm_runtime_get_if_active(og0ve1b->dev))
		return 0;

If Runtime PM is disabled, pm_runtime_get_if_active() returns -EINVAL.
Since the logical NOT operator evaluates -EINVAL as false, the code
bypasses the early return and proceeds to the hardware accesses and the
pm_runtime_put() call at the end of the function.

Could this lead to usage counter underflows and unpowered hardware
accesses when the sensor isn't powered up? Should this be checked as
<= 0 instead?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260708-og0va1b-v3-0-de8e44455a42@oss.qualcomm.com?part=2

  reply	other threads:[~2026-07-08 14:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 14:33 [PATCH v3 0/3] media: i2c: Add OmniVision OG0VA1B camera sensor driver Wenmeng Liu
2026-07-08 14:33 ` [PATCH v3 1/3] dt-bindings: media: i2c: og0ve1b: Add OmniVision OG0VA1B camera sensor Wenmeng Liu
2026-07-08 14:33 ` [PATCH v3 2/3] media: i2c: og0ve1b: Introduce per-sensor data structure Wenmeng Liu
2026-07-08 14:45   ` sashiko-bot [this message]
2026-07-08 14:33 ` [PATCH v3 3/3] media: i2c: og0ve1b: Add support for OmniVision OG0VA1B Wenmeng Liu

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=20260708144534.1DE821F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wenmeng.liu@oss.qualcomm.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