The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
To: Tarang Raval <tarang.raval@siliconsignals.io>,
	sakari.ailus@linux.intel.com, mehdi.djait@linux.intel.com
Cc: Himanshu Bhavani <himanshu.bhavani@siliconsignals.io>,
	Elgin Perumbilly <elgin.perumbilly@siliconsignals.io>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil+cisco@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 17/17] media: i2c: os05b10: remove unused control fields, simplify error handling
Date: Sat, 25 Jul 2026 14:33:11 +0300	[thread overview]
Message-ID: <141c9f00-6fe9-4003-af7e-182cebcce22e@linaro.org> (raw)
In-Reply-To: <20260718200912.16001-18-tarang.raval@siliconsignals.io>

On 7/18/26 23:09, Tarang Raval wrote:
> link_freq and gain don't need to be stored in struct os05b10; make
> them local.
> 
> Parse the fwnode properties up front and register them before the
> single ctrl_hdlr->error check, so all controls are covered by one
> check and the per-control NULL guards before setting flags can be
> dropped.
> 
> Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
> ---
>   drivers/media/i2c/os05b10.c | 55 +++++++++++++++++--------------------
>   1 file changed, 25 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
> index b4dd3137ad5c..c355ac197eb2 100644
> --- a/drivers/media/i2c/os05b10.c
> +++ b/drivers/media/i2c/os05b10.c
> @@ -557,11 +557,9 @@ struct os05b10 {
>   
>   	/* 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 *vflip;
>   	struct v4l2_ctrl *hflip;
> @@ -1276,9 +1274,14 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
>   	struct v4l2_fwnode_device_properties props;
>   	struct v4l2_ctrl_handler *ctrl_hdlr;
>   	u64 vblank_def, exp_max, pixel_rate;
> +	struct v4l2_ctrl *link_freq;
>   	s64 hblank_def;
>   	int ret;
>   
> +	ret = v4l2_fwnode_device_parse(os05b10->dev, &props);
> +	if (ret)
> +		return ret;
> +
>   	ctrl_hdlr = &os05b10->handler;
>   	v4l2_ctrl_handler_init(ctrl_hdlr, 12);
>   
> @@ -1287,22 +1290,18 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
>   						V4L2_CID_PIXEL_RATE, pixel_rate,
>   						pixel_rate, 1, pixel_rate);
>   
> -	os05b10->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &os05b10_ctrl_ops,
> -						    V4L2_CID_LINK_FREQ,
> -						    ARRAY_SIZE(link_frequencies_4lane) - 1,
> -						    os05b10->link_freq_index,
> -						    (os05b10->data_lanes == 2) ?
> -						    link_frequencies_2lane :
> -						    link_frequencies_4lane);
> -	if (os05b10->link_freq)
> -		os05b10->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
> +	link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &os05b10_ctrl_ops,
> +					   V4L2_CID_LINK_FREQ,
> +					   ARRAY_SIZE(link_frequencies_4lane) - 1,
> +					   os05b10->link_freq_index,
> +					   (os05b10->data_lanes == 2) ?
> +					   link_frequencies_2lane :
> +					   link_frequencies_4lane);
>   
>   	hblank_def = (s64)mode->hts -(s64)mode->width;
>   	os05b10->hblank = v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_HBLANK,
>   					    hblank_def, hblank_def,
>   					    1, hblank_def);
> -	if (os05b10->hblank)
> -		os05b10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
>   
>   	vblank_def = mode->vts - mode->height;
>   	os05b10->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
> @@ -1317,12 +1316,10 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
>   					      exp_max, OS05B10_EXPOSURE_STEP,
>   					      mode->exp);
>   
> -	os05b10->gain = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
> -					  V4L2_CID_ANALOGUE_GAIN,
> -					  OS05B10_ANALOG_GAIN_MIN,
> -					  OS05B10_ANALOG_GAIN_MAX,
> -					  OS05B10_ANALOG_GAIN_STEP,
> -					  OS05B10_ANALOG_GAIN_DEFAULT);
> +	v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
> +			  V4L2_CID_ANALOGUE_GAIN, OS05B10_ANALOG_GAIN_MIN,
> +			  OS05B10_ANALOG_GAIN_MAX, OS05B10_ANALOG_GAIN_STEP,
> +			  OS05B10_ANALOG_GAIN_DEFAULT);
>   
>   	v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops, V4L2_CID_DIGITAL_GAIN,
>   			  OS05B10_DIGITAL_GAIN_MIN, OS05B10_DIGITAL_GAIN_MAX,
> @@ -1330,33 +1327,31 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
>   
>   	os05b10->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
>   					   V4L2_CID_HFLIP, 0, 1, 1, 0);
> -	if (os05b10->hflip)
> -		os05b10->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
>   
>   	os05b10->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
>   					   V4L2_CID_VFLIP, 0, 1, 1, 0);
> -	if (os05b10->vflip)
> -		os05b10->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
>   
>   	v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &os05b10_ctrl_ops,
>   				     V4L2_CID_TEST_PATTERN,
>   				     ARRAY_SIZE(os05b10_test_pattern_menu) - 1,
>   				     0, 0, os05b10_test_pattern_menu);
>   
> +	ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &os05b10_ctrl_ops,
> +					      &props);
> +	if (ret)
> +		goto error;
> +
>   	if (ctrl_hdlr->error) {
>   		ret = ctrl_hdlr->error;
>   		dev_err(os05b10->dev, "control init failed (%d)\n", ret);
>   		goto error;
>   	}
>   
> -	ret = v4l2_fwnode_device_parse(os05b10->dev, &props);
> -	if (ret)
> -		goto error;
>   
> -	ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &os05b10_ctrl_ops,
> -					      &props);
> -	if (ret)
> -		goto error;
> +	link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
> +	os05b10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
> +	os05b10->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
> +	os05b10->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
>   
>   	os05b10->sd.ctrl_handler = ctrl_hdlr;
>   

Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>


I would suggest to reorganize and reorder changes in the changeset, moving
simple changes like this one to the very top. Also it might be possible to
merge a number of trivial changes earlier, this will save time and efforts.

-- 
Best wishes,
Vladimir

      reply	other threads:[~2026-07-25 11:33 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-18 20:08 [PATCH v3 00/17] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
2026-07-18 20:08 ` [PATCH v3 01/17] media: i2c: os05b10: Use pm_runtime_get_if_active() when applying controls Tarang Raval
2026-07-22  5:58   ` Jai Luthra
2026-07-24  6:47     ` Tarang Raval
2026-07-18 20:08 ` [PATCH v3 02/17] media: i2c: os05b10: drop unused group-hold programming Tarang Raval
2026-07-18 20:08 ` [PATCH v3 03/17] media: i2c: os05b10: add register definitions and use them in init table Tarang Raval
2026-07-21 17:25   ` Mehdi Djait
2026-07-24 13:09   ` Vladimir Zapolskiy
2026-07-18 20:08 ` [PATCH v3 04/17] media: i2c: os05b10: split common and mode-specific init registers Tarang Raval
2026-07-21 17:40   ` Mehdi Djait
2026-07-24 13:15   ` Vladimir Zapolskiy
2026-07-18 20:08 ` [PATCH v3 05/17] media: i2c: os05b10: add V4L2 digital gain control Tarang Raval
2026-07-24 13:19   ` Vladimir Zapolskiy
2026-07-24 14:15     ` Tarang Raval
2026-07-18 20:08 ` [PATCH v3 06/17] media: i2c: os05b10: Add H/V flip support Tarang Raval
2026-07-21 17:43   ` Mehdi Djait
2026-07-22  5:51   ` Jai Luthra
2026-07-24  7:01     ` Tarang Raval
2026-07-24 13:27   ` Vladimir Zapolskiy
2026-07-18 20:08 ` [PATCH v3 07/17] media: i2c: os05b10: Add test pattern options Tarang Raval
2026-07-21 17:50   ` Mehdi Djait
2026-07-24 13:43   ` Vladimir Zapolskiy
2026-07-18 20:08 ` [PATCH v3 08/17] media: i2c: os05b10: add 12-bit RAW mode support Tarang Raval
2026-07-24 14:08   ` Vladimir Zapolskiy
2026-07-24 14:30     ` Tarang Raval
2026-07-24 15:03       ` Vladimir Zapolskiy
2026-07-18 20:09 ` [PATCH v3 09/17] media: i2c: os05b10: update pixel rate on 10/12-bit mode switch Tarang Raval
2026-07-22  6:17   ` Jai Luthra
2026-07-22  6:19     ` Jai Luthra
2026-07-24  9:08       ` Tarang Raval
2026-07-25  7:26   ` Vladimir Zapolskiy
2026-07-18 20:09 ` [PATCH v3 10/17] media: i2c: os05b10: Add 1080p and 2x2 binning 720p modes Tarang Raval
2026-07-22  6:05   ` Jai Luthra
2026-07-24  6:44     ` Tarang Raval
2026-07-18 20:09 ` [PATCH v3 11/17] media: i2c: os05b10: keep vblank and exposure range in sync on mode switch Tarang Raval
2026-07-25  7:30   ` Vladimir Zapolskiy
2026-07-18 20:09 ` [PATCH v3 12/17] media: i2c: os05b10: Update active format before adjusting framing controls Tarang Raval
2026-07-25  7:32   ` Vladimir Zapolskiy
2026-07-18 20:09 ` [PATCH v3 13/17] media: i2c: os05b10: Rename vmax variable in VBLANK control Tarang Raval
2026-07-25  7:33   ` Vladimir Zapolskiy
2026-07-18 20:09 ` [PATCH v3 14/17] media: i2c: os05b10: add 2-lane support Tarang Raval
2026-07-25  7:38   ` Vladimir Zapolskiy
2026-07-18 20:09 ` [PATCH v3 15/17] media: i2c: os05b10: fix negative hblank calculation Tarang Raval
2026-07-22  6:14   ` Jai Luthra
2026-07-24  8:14     ` Tarang Raval
2026-07-18 20:09 ` [PATCH v3 16/17] media: i2c: os05b10: Enable runtime PM autosuspend Tarang Raval
2026-07-22  6:08   ` Jai Luthra
2026-07-24  7:02     ` Tarang Raval
2026-07-24  9:58       ` Jai Luthra
2026-07-18 20:09 ` [PATCH v3 17/17] media: i2c: os05b10: remove unused control fields, simplify error handling Tarang Raval
2026-07-25 11:33   ` Vladimir Zapolskiy [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=141c9f00-6fe9-4003-af7e-182cebcce22e@linaro.org \
    --to=vladimir.zapolskiy@linaro.org \
    --cc=elgin.perumbilly@siliconsignals.io \
    --cc=himanshu.bhavani@siliconsignals.io \
    --cc=hverkuil+cisco@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mehdi.djait@linux.intel.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tarang.raval@siliconsignals.io \
    /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