From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Hermes.wu@ite.com.tw
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 19/21] media: i2c: it6625: fold subdev initialization into probe
Date: Fri, 18 Sep 2026 13:13:11 +0300 [thread overview]
Message-ID: <aq0Ot1n9q6f_AtpX@kekkonen.localdomain> (raw)
In-Reply-To: <20260918-upstream-it6625-follow-up-patch-v1-19-78d72d7886a5@ite.com.tw>
Hi Hermes,
Overall the patches are nice, thank you. One comment below...
On Fri, Sep 18, 2026 at 04:57:34PM +0800, Hermes Wu via B4 Relay wrote:
> From: Hermes Wu <Hermes.wu@ite.com.tw>
>
> it6625_init_v4l2_subdev() split subdev/control-handler/media-entity
> initialization out of probe(), which made error handling harder to
> follow across the two functions and forced probe() to normalize every
> init_v4l2_subdev() failure to -ENOMEM regardless of the real error
> (e.g. a media_entity_pads_init() failure was reported to the caller as
> -ENOMEM instead of its actual code).
>
> Inline it into it6625_probe() so initialization and its unwind path
> are visible together, and propagate the real error from
> it6625_v4l2_init_controls() instead of replacing it. Cleanup behavior
> on each failure path is unchanged: it6625_v4l2_init_controls() already
> frees the control handler internally before returning an error, and a
> media_entity_pads_init() failure still frees it explicitly before
> unwinding, so neither path double-frees it through the later
> err_clean_hdl label.
>
> State finalization (v4l2_subdev_init_finalize()/cleanup()) is
> deliberately left for a follow-up change, to keep this a pure
> restructuring and keep the locking-model transition atomic on its own.
>
> Signed-off-by: Hermes Wu <Hermes.wu@ite.com.tw>
> ---
> drivers/media/i2c/it6625.c | 46 +++++++++++++++++-----------------------------
> 1 file changed, 17 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/media/i2c/it6625.c b/drivers/media/i2c/it6625.c
> index 40cd413e0ed49c118421ce3dec77bb2df08cf042..ec6aaa878471ff210264a35e4aa66dfb1e63ed3b 100644
> --- a/drivers/media/i2c/it6625.c
> +++ b/drivers/media/i2c/it6625.c
> @@ -2142,33 +2142,6 @@ static int it6625_parse_dt(struct it6625 *it6625)
> return it6625_parse_endpoint(it6625);
> }
>
> -static int it6625_init_v4l2_subdev(struct it6625 *it6625)
> -{
> - struct v4l2_subdev *sd = &it6625->sd;
> - int err;
> -
> - sd->dev = it6625->dev;
> -
> - v4l2_i2c_subdev_init(sd, it6625->i2c_client, &it6625_ops);
> - sd->internal_ops = &it6625_internal_ops;
> - sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
> - if (it6625_v4l2_init_controls(sd)) {
> - dev_err(it6625->dev, "Failed to initialize v4l2 controls");
> - return -ENOMEM;
> - }
> -
> - it6625->pad.flags = MEDIA_PAD_FL_SOURCE;
> - sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
> - err = media_entity_pads_init(&sd->entity, 1, &it6625->pad);
> - if (err < 0) {
> - dev_err(it6625->dev, "%s %d err=%d", __func__, __LINE__, err);
> - v4l2_ctrl_handler_free(sd->ctrl_handler);
> - return err;
> - }
> -
> - return 0;
> -}
> -
> static int it6625_check_device(struct it6625 *it6625)
> {
> static const u8 chip_ids[][2] = {
> @@ -2254,9 +2227,24 @@ static int it6625_probe(struct i2c_client *client)
> }
>
> sd = &it6625->sd;
> - err = it6625_init_v4l2_subdev(it6625);
> - if (err)
> + v4l2_i2c_subdev_init(sd, it6625->i2c_client, &it6625_ops);
> + sd->internal_ops = &it6625_internal_ops;
> + sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
> +
> + err = it6625_v4l2_init_controls(sd);
> + if (err) {
> + dev_err(it6625->dev, "failed to initialize v4l2 controls: %d", err);
> goto err_clean_work_queues;
> + }
> +
> + it6625->pad.flags = MEDIA_PAD_FL_SOURCE;
> + sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
> + err = media_entity_pads_init(&sd->entity, 1, &it6625->pad);
> + if (err < 0) {
> + dev_err(it6625->dev, "%s %d err=%d", __func__, __LINE__, err);
> + v4l2_ctrl_handler_free(sd->ctrl_handler);
Please add a new label instead of freeing the control handler here.
> + goto err_clean_work_queues;
> + }
>
> err = v4l2_ctrl_handler_setup(sd->ctrl_handler);
> if (err)
>
--
Kind regards,
Sakari Ailus
next prev parent reply other threads:[~2026-09-18 10:13 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 8:57 [PATCH 00/21] media: i2c: it6625: address review feedback and adopt subdev state Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 01/21] media: dt-bindings: ite,it6625: document the default CSI-2 bus type Hermes Wu via B4 Relay
2026-09-28 19:21 ` Rob Herring (Arm)
2026-09-18 8:57 ` [PATCH 02/21] media: i2c: it6625: propagate control-update errors Hermes Wu via B4 Relay
2026-09-18 10:05 ` Sakari Ailus
2026-09-18 11:05 ` Hermes.Wu
2026-09-18 8:57 ` [PATCH 03/21] media: i2c: it6625: default the debug module parameter to 0 Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 04/21] media: i2c: it6625: drop unused bus field from struct it6625 Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 05/21] media: i2c: it6625: drop stale GCC < 4.4.6 workaround Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 06/21] media: i2c: it6625: use unsigned int loop indices in table lookups Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 07/21] media: i2c: it6625: drop redundant parentheses in status helpers Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 08/21] media: i2c: it6625: make the audio sampling-rate table static const Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 09/21] media: i2c: it6625: tidy CEC buffer init and a continuation line Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 10/21] media: i2c: it6625: clean up it6625_wait_for_status() Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 11/21] media: i2c: it6625: use unsigned int indices in EDID read/write Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 12/21] media: i2c: it6625: use unaligned/units helpers to decode pixel clock Hermes Wu via B4 Relay
2026-09-18 9:11 ` sashiko-bot
2026-09-18 8:57 ` [PATCH 13/21] media: i2c: it6625: decode detected timings via typed register structs Hermes Wu via B4 Relay
2026-09-18 10:09 ` Sakari Ailus
2026-09-18 8:57 ` [PATCH 14/21] media: i2c: it6625: fix link-frequency reporting for one-/two-trio C-PHY Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 15/21] media: i2c: it6625: use early returns in it6625_update_timings_if_changed() Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 16/21] media: i2c: it6625: drop the private CSI-format name table Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 17/21] media: i2c: it6625: require a DT endpoint and simplify endpoint parsing Hermes Wu via B4 Relay
2026-09-18 9:16 ` sashiko-bot
2026-09-18 8:57 ` [PATCH 18/21] media: i2c: it6625: finish reverse fir-tree declaration order Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 19/21] media: i2c: it6625: fold subdev initialization into probe Hermes Wu via B4 Relay
2026-09-18 10:13 ` Sakari Ailus [this message]
2026-09-18 8:57 ` [PATCH 20/21] media: i2c: it6625: use centrally managed active state Hermes Wu via B4 Relay
2026-09-18 10:24 ` Sakari Ailus
2026-09-18 11:19 ` Hermes.Wu
2026-09-18 15:28 ` Sakari Ailus
2026-09-21 2:24 ` Hermes.Wu
2026-09-25 11:35 ` Sakari Ailus
2026-09-18 8:57 ` [PATCH 21/21] media: i2c: it6625: use enable_streams and disable_streams Hermes Wu via B4 Relay
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=aq0Ot1n9q6f_AtpX@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=Hermes.wu@ite.com.tw \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=robh@kernel.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