From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Tarang Raval <tarang.raval@siliconsignals.io>
Cc: jai.luthra@ideasonboard.com,
Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>,
Himanshu Bhavani <himanshu.bhavani@siliconsignals.io>,
Elgin Perumbilly <elgin.perumbilly@siliconsignals.io>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil+cisco@kernel.org>,
Mehdi Djait <mehdi.djait@linux.intel.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 07/15] media: i2c: os05b10: remove unused control fields, simplify error handling
Date: Fri, 30 Oct 2026 13:15:48 +0200 [thread overview]
Message-ID: <auR8ZL9cFjznhUgs@kekkonen.localdomain> (raw)
In-Reply-To: <20261030104806.1223991-8-tarang.raval@siliconsignals.io>
Hi Tarang,
On Fri, Oct 30, 2026 at 04:17:56PM +0530, 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>
> Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
> ---
> drivers/media/i2c/os05b10.c | 46 +++++++++++++++----------------------
> 1 file changed, 18 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
> index 46d514d2a479..abcb7c766754 100644
> --- a/drivers/media/i2c/os05b10.c
> +++ b/drivers/media/i2c/os05b10.c
> @@ -457,10 +457,8 @@ struct os05b10 {
>
> /* V4L2 Controls */
> struct v4l2_ctrl_handler handler;
> - struct v4l2_ctrl *link_freq;
> struct v4l2_ctrl *hblank;
> struct v4l2_ctrl *vblank;
> - struct v4l2_ctrl *gain;
> struct v4l2_ctrl *exposure;
>
> u32 link_freq_index;
> @@ -920,8 +918,13 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
> u64 hblank_def, vblank_def, exp_max, pixel_rate;
> struct v4l2_fwnode_device_properties props;
> struct v4l2_ctrl_handler *ctrl_hdlr;
> + struct v4l2_ctrl *link_freq;
> int ret;
>
> + ret = v4l2_fwnode_device_parse(os05b10->dev, &props);
> + if (ret)
> + return ret;
> +
> ctrl_hdlr = &os05b10->handler;
> v4l2_ctrl_handler_init(ctrl_hdlr, 8);
>
> @@ -929,21 +932,16 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
> v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops, 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) - 1,
> - os05b10->link_freq_index,
> - link_frequencies);
> -
> - 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) - 1,
> + os05b10->link_freq_index,
> + link_frequencies);
>
> hblank_def = mode->hts - 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,
> @@ -958,27 +956,19 @@ 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);
>
> - if (ctrl_hdlr->error) {
> - ret = ctrl_hdlr->error;
> + ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &os05b10_ctrl_ops,
> + &props);
> + if (ret) {
> dev_err(os05b10->dev, "control init failed (%d)\n", ret);
> goto error;
If you're left with a single goto (hopefully that's the case), you can just
handle the error here (and avoid the goto).
> }
>
> - 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->sd.ctrl_handler = ctrl_hdlr;
>
--
Regards,
Sakari Ailus
next prev parent reply other threads:[~2026-10-30 11:15 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
2026-10-30 10:47 ` [PATCH v5 01/15] media: i2c: os05b10: drop unused group-hold programming Tarang Raval
2026-10-30 10:47 ` [PATCH v5 02/15] media: i2c: os05b10: Rename vmax variable in VBLANK control Tarang Raval
2026-10-30 10:47 ` [PATCH v5 03/15] media: i2c: os05b10: Update active format before adjusting framing controls Tarang Raval
2026-10-30 10:47 ` [PATCH v5 04/15] media: i2c: os05b10: Enable runtime PM autosuspend Tarang Raval
2026-10-30 10:47 ` [PATCH v5 05/15] media: i2c: os05b10: add register definitions and use them in init table Tarang Raval
2026-10-30 10:47 ` [PATCH v5 06/15] media: i2c: os05b10: split common and mode-specific init registers Tarang Raval
2026-10-30 10:47 ` [PATCH v5 07/15] media: i2c: os05b10: remove unused control fields, simplify error handling Tarang Raval
2026-10-30 11:15 ` Sakari Ailus [this message]
2026-10-30 10:47 ` [PATCH v5 08/15] media: i2c: os05b10: add V4L2 digital gain control Tarang Raval
2026-10-30 10:47 ` [PATCH v5 09/15] media: i2c: os05b10: Add H/V flip support Tarang Raval
2026-11-02 12:33 ` Sakari Ailus
2026-10-30 10:47 ` [PATCH v5 10/15] media: i2c: os05b10: Add test pattern options Tarang Raval
2026-10-30 10:48 ` [PATCH v5 11/15] media: i2c: os05b10: add 12-bit RAW mode support Tarang Raval
2026-10-30 10:48 ` [PATCH v5 12/15] media: i2c: os05b10: Add 1080p and 2x2 binning 720p modes Tarang Raval
2026-10-30 10:48 ` [PATCH v5 13/15] media: i2c: os05b10: keep exposure default in sync with the active mode on VBLANK changes Tarang Raval
2026-10-30 10:48 ` [PATCH v5 14/15] media: i2c: os05b10: add 2-lane support Tarang Raval
2026-11-04 16:55 ` kernel test robot
2026-10-30 10:48 ` [PATCH v5 15/15] media: i2c: os05b10: fix horizontal blanking calculation Tarang Raval
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=auR8ZL9cFjznhUgs@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=elgin.perumbilly@siliconsignals.io \
--cc=himanshu.bhavani@siliconsignals.io \
--cc=hverkuil+cisco@kernel.org \
--cc=jai.luthra@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mehdi.djait@linux.intel.com \
--cc=tarang.raval@siliconsignals.io \
--cc=vladimir.zapolskiy@linaro.org \
/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
all inboxes | Powered by JetHome®