Linux Media Controller development
 help / color / mirror / Atom feed
From: xiaolei wang <xiaolei.wang@windriver.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: laurent.pinchart@ideasonboard.com,
	dave.stevenson@raspberrypi.com, jacopo@jmondi.org,
	mchehab@kernel.org, prabhakar.mahadev-lad.rj@bp.renesas.com,
	hverkuil+cisco@kernel.org, johannes.goede@oss.qualcomm.com,
	hverkuil-cisco@xs4all.nl, jai.luthra@ideasonboard.com,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] media: i2c: ov5647: Switch to using the sub-device state lock
Date: Wed, 31 Dec 2025 10:58:53 +0800	[thread overview]
Message-ID: <f3807d3e-cffe-4ccc-8e6d-dc306da362fe@windriver.com> (raw)
In-Reply-To: <aVLOlkqSHn-N5Wi0@kekkonen.localdomain>


On 12/30/25 02:55, Sakari Ailus wrote:
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> Hi Xiaolei,
>
> On Mon, Dec 29, 2025 at 10:30:17AM +0800, Xiaolei Wang wrote:
>> Switch to using the sub-device state lock and properly call
>> v4l2_subdev_init_finalize() / v4l2_subdev_cleanup() on probe() /
>> remove().
>>
>> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
>> ---
>>   drivers/media/i2c/ov5647.c | 40 +++++++++++++-------------------------
>>   1 file changed, 14 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
>> index fd69f1616794..f0ca8cc14794 100644
>> --- a/drivers/media/i2c/ov5647.c
>> +++ b/drivers/media/i2c/ov5647.c
>> @@ -91,7 +91,6 @@ struct ov5647 {
>>        struct v4l2_subdev              sd;
>>        struct regmap                   *regmap;
>>        struct media_pad                pad;
>> -     struct mutex                    lock;
>>        struct clk                      *xclk;
>>        struct gpio_desc                *pwdn;
>>        bool                            clock_ncont;
>> @@ -652,7 +651,7 @@ static int ov5647_stream_on(struct v4l2_subdev *sd)
>>        }
>>
>>        /* Apply customized values from user when stream starts. */
>> -     ret =  __v4l2_ctrl_handler_setup(sd->ctrl_handler);
>> +     ret =  v4l2_ctrl_handler_setup(sd->ctrl_handler);
>>        if (ret)
>>                return ret;
>>
>> @@ -807,15 +806,12 @@ __ov5647_get_pad_crop(struct ov5647 *ov5647,
>>   static int ov5647_s_stream(struct v4l2_subdev *sd, int enable)
>>   {
>>        struct i2c_client *client = v4l2_get_subdevdata(sd);
>> -     struct ov5647 *sensor = to_sensor(sd);
>>        int ret;
>>
>> -     mutex_lock(&sensor->lock);
> Note that you shouldn't remove mutex_lock() here quite yet -- s_stream()
> callback won't involve sub-device state and thus the caller won't take the
> state lock either. In other words, the end result is fine after the third
> patch so you should explicitly lock the active state and remove that in the
> third patch (see e.g. v4l2_subdev_lock_and_get_active_state() in
> drivers/media/i2c/imx290.c).
Hi Hans,

Thank you for the detailed review and suggestions.

You're absolutely right about the approach. Using regmap_multi_reg_write()
with struct reg_sequence would indeed be cleaner and result in a much
smaller, more reviewable diff.

I'll revise the patch to:
- Use struct reg_sequence instead of struct cci_reg_sequence
- Call regmap_multi_reg_write() instead of cci_multi_reg_write()
- Keep the existing array initializer values unchanged

This will maintain the same functionality while making the conversion
more straightforward and consistent with other driver conversions.

I'll send v3 shortly.
>
>> -
>>        if (enable) {
>>                ret = pm_runtime_resume_and_get(&client->dev);
>>                if (ret < 0)
>> -                     goto error_unlock;
>> +                     return ret;
>>
>>                ret = ov5647_stream_on(sd);
>>                if (ret < 0) {
>> @@ -831,14 +827,10 @@ static int ov5647_s_stream(struct v4l2_subdev *sd, int enable)
>>                pm_runtime_put(&client->dev);
>>        }
>>
>> -     mutex_unlock(&sensor->lock);
>> -
>>        return 0;
>>
>>   error_pm:
>>        pm_runtime_put(&client->dev);
>> -error_unlock:
>> -     mutex_unlock(&sensor->lock);
>>
>>        return ret;
>>   }
> --
> Kind regards,
>
> Sakari Ailus

  reply	other threads:[~2025-12-31  2:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-29  2:30 [PATCH v2 0/3] media: i2c: ov5647: Modernize driver with CCI and new stream APIs Xiaolei Wang
2025-12-29  2:30 ` [PATCH v2 1/3] media: i2c: ov5647: Convert to CCI register access helpers Xiaolei Wang
2025-12-29 12:37   ` Tarang Raval
2025-12-29 13:01     ` Laurent Pinchart
2025-12-29 13:26       ` Tarang Raval
2025-12-31  2:57       ` xiaolei wang
2025-12-29 13:26   ` johannes.goede
2025-12-29 14:52   ` Tarang Raval
2025-12-29  2:30 ` [PATCH v2 2/3] media: i2c: ov5647: Switch to using the sub-device state lock Xiaolei Wang
2025-12-29 18:55   ` Sakari Ailus
2025-12-31  2:58     ` xiaolei wang [this message]
2025-12-29  2:30 ` [PATCH v2 3/3] media: i2c: ov5647: switch to {enable,disable}_streams Xiaolei Wang
2025-12-29 13:43   ` Laurent Pinchart
2025-12-31  3:02     ` xiaolei wang

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=f3807d3e-cffe-4ccc-8e6d-dc306da362fe@windriver.com \
    --to=xiaolei.wang@windriver.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jacopo@jmondi.org \
    --cc=jai.luthra@ideasonboard.com \
    --cc=johannes.goede@oss.qualcomm.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=sakari.ailus@linux.intel.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