Re: [PATCH v2 2/2] media: i2c: ov8856: parse and register V4L2 device tree properties
From: Sakari Ailus
Date: Tue Mar 10 2026 - 03:48:21 EST
Hi Alexander,
On Tue, Mar 10, 2026 at 04:21:34AM +0000, Alexander Koskovich wrote:
> Parse V4L2 device tree properties and register controls for them.
>
> Signed-off-by: Alexander Koskovich <akoskovich@xxxxx>
> ---
> drivers/media/i2c/ov8856.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/i2c/ov8856.c b/drivers/media/i2c/ov8856.c
> index e2998cfa0d18..9d7d16ba8911 100644
> --- a/drivers/media/i2c/ov8856.c
> +++ b/drivers/media/i2c/ov8856.c
> @@ -1887,12 +1887,14 @@ static const struct v4l2_ctrl_ops ov8856_ctrl_ops = {
>
> static int ov8856_init_controls(struct ov8856 *ov8856)
> {
> + struct i2c_client *client = v4l2_get_subdevdata(&ov8856->sd);
> + struct v4l2_fwnode_device_properties props;
> struct v4l2_ctrl_handler *ctrl_hdlr;
> s64 exposure_max, h_blank;
> int ret;
>
> ctrl_hdlr = &ov8856->ctrl_handler;
> - ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8);
> + ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10);
> if (ret)
> return ret;
>
> @@ -1954,6 +1956,15 @@ static int ov8856_init_controls(struct ov8856 *ov8856)
> if (ctrl_hdlr->error)
> return ctrl_hdlr->error;
>
> + ret = v4l2_fwnode_device_parse(&client->dev, &props);
> + if (ret)
> + return ret;
> +
> + ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov8856_ctrl_ops,
> + &props);
> + if (ret)
> + return ret;
> +
It's not a bug introduced in this patch, but freeing the control handler on
error path was broken to begin with: it was never set to the sub-device on
error so the caller can't release it.
Could you fix that before this patch so we can get it backported?
I think it'd be cleanest to add a new label for freeing it and change all
existing returns to gotos.
> ov8856->sd.ctrl_handler = ctrl_hdlr;
>
> return 0;
>
--
Kind regards,
Sakari Ailus