Re: [PATCH 03/13] media: i2c: imx214: Simplify with dev_err_probe()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 2, 2024 at 11:53 PM André Apitzsch via B4 Relay
<devnull+git.apitzsch.eu@xxxxxxxxxx> wrote:
>
> From: André Apitzsch <git@xxxxxxxxxxx>
>
> Error handling in probe() can be a bit simpler with dev_err_probe().
>
Acked-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>

> Signed-off-by: André Apitzsch <git@xxxxxxxxxxx>
> ---
>  drivers/media/i2c/imx214.c | 52 ++++++++++++++++++++--------------------------
>  1 file changed, 22 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c
> index 283d4783c22e..ad2f1db6baeb 100644
> --- a/drivers/media/i2c/imx214.c
> +++ b/drivers/media/i2c/imx214.c
> @@ -931,14 +931,12 @@ static int imx214_parse_fwnode(struct device *dev)
>         int ret;
>
>         endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(dev), NULL);
> -       if (!endpoint) {
> -               dev_err(dev, "endpoint node not found\n");
> -               return -EINVAL;
> -       }
> +       if (!endpoint)
> +               return dev_err_probe(dev, -EINVAL, "endpoint node not found\n");
>
>         ret = v4l2_fwnode_endpoint_alloc_parse(endpoint, &bus_cfg);
>         if (ret) {
> -               dev_err(dev, "parsing endpoint node failed\n");
> +               dev_err_probe(dev, ret, "parsing endpoint node failed\n");
>                 goto done;
>         }
>
> @@ -947,8 +945,9 @@ static int imx214_parse_fwnode(struct device *dev)
>                         break;
>
>         if (i == bus_cfg.nr_of_link_frequencies) {
> -               dev_err(dev, "link-frequencies %d not supported, Please review your DT\n",
> -                       IMX214_DEFAULT_LINK_FREQ);
> +               dev_err_probe(dev, -EINVAL,
> +                             "link-frequencies %d not supported, Please review your DT\n",
> +                             IMX214_DEFAULT_LINK_FREQ);
>                 ret = -EINVAL;
>                 goto done;
>         }
> @@ -976,34 +975,27 @@ static int imx214_probe(struct i2c_client *client)
>         imx214->dev = dev;
>
>         imx214->xclk = devm_clk_get(dev, NULL);
> -       if (IS_ERR(imx214->xclk)) {
> -               dev_err(dev, "could not get xclk");
> -               return PTR_ERR(imx214->xclk);
> -       }
> +       if (IS_ERR(imx214->xclk))
> +               return dev_err_probe(dev, PTR_ERR(imx214->xclk),
> +                                    "failed to get xclk\n");
>
>         ret = clk_set_rate(imx214->xclk, IMX214_DEFAULT_CLK_FREQ);
> -       if (ret) {
> -               dev_err(dev, "could not set xclk frequency\n");
> -               return ret;
> -       }
> +       if (ret)
> +               return dev_err_probe(dev, ret, "failed to set xclk frequency\n");
>
>         ret = imx214_get_regulators(dev, imx214);
> -       if (ret < 0) {
> -               dev_err(dev, "cannot get regulators\n");
> -               return ret;
> -       }
> +       if (ret < 0)
> +               return dev_err_probe(dev, ret, "failed to get regulators\n");
>
>         imx214->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
> -       if (IS_ERR(imx214->enable_gpio)) {
> -               dev_err(dev, "cannot get enable gpio\n");
> -               return PTR_ERR(imx214->enable_gpio);
> -       }
> +       if (IS_ERR(imx214->enable_gpio))
> +               return dev_err_probe(dev, PTR_ERR(imx214->enable_gpio),
> +                                    "failed to get enable gpio\n");
>
>         imx214->regmap = devm_regmap_init_i2c(client, &sensor_regmap_config);
> -       if (IS_ERR(imx214->regmap)) {
> -               dev_err(dev, "regmap init failed\n");
> -               return PTR_ERR(imx214->regmap);
> -       }
> +       if (IS_ERR(imx214->regmap))
> +               return dev_err_probe(dev, PTR_ERR(imx214->regmap),
> +                                    "regmap init failed\n");
>
>         v4l2_i2c_subdev_init(&imx214->sd, client, &imx214_subdev_ops);
>         imx214->sd.internal_ops = &imx214_internal_ops;
> @@ -1029,20 +1021,20 @@ static int imx214_probe(struct i2c_client *client)
>
>         ret = media_entity_pads_init(&imx214->sd.entity, 1, &imx214->pad);
>         if (ret < 0) {
> -               dev_err(dev, "could not register media entity\n");
> +               dev_err_probe(dev, ret, "failed to init entity pads\n");
>                 goto free_ctrl;
>         }
>
>         imx214->sd.state_lock = imx214->ctrls.lock;
>         ret = v4l2_subdev_init_finalize(&imx214->sd);
>         if (ret < 0) {
> -               dev_err(dev, "subdev init error: %d\n", ret);
> +               dev_err_probe(dev, ret, "subdev init error\n");
>                 goto free_entity;
>         }
>
>         ret = v4l2_async_register_subdev_sensor(&imx214->sd);
>         if (ret < 0) {
> -               dev_err(dev, "could not register v4l2 device\n");
> +               dev_err_probe(dev, ret, "failed to register sensor sub-device\n");
>                 goto error_subdev_cleanup;
>         }
>
>
> --
> 2.46.0
>
>





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux