Re: [PATCH 5/8] media: rzg2l-cru: csi2: Use temporary variable for struct device in rzg2l_csi2_probe()

Laurent Pinchart
2025-02-14T00:47:43Z

Hi Tommaso, Prabhakar,

Thank you for the patch.

On Mon, Feb 10, 2025 at 12:45:37PM +0100, Tommaso Merciai wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Use a temporary variable for the struct device pointers to avoid

s/temporary/local/ (in the subject message too).

> dereferencing.

The only advantage of this is shortened lines. That's a coding style
preference, and I'm fine with this patch, but the commit message should
mention this, not "avoid dereferencing".

> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> ---
> .../platform/renesas/rzg2l-cru/rzg2l-csi2.c | 31 ++++++++++---------
> 1 file changed, 16 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> index 881e910dce02..948f1917b830 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> @@ -764,10 +764,11 @@ static const struct media_entity_operations rzg2l_csi2_entity_ops = {
>
> static int rzg2l_csi2_probe(struct platform_device *pdev)
> {
> + struct device *dev = &pdev->dev;
> struct rzg2l_csi2 *csi2;
> int ret;
>
> - csi2 = devm_kzalloc(&pdev->dev, sizeof(*csi2), GFP_KERNEL);
> + csi2 = devm_kzalloc(dev, sizeof(*csi2), GFP_KERNEL);
> if (!csi2)
> return -ENOMEM;
>
> @@ -775,28 +776,28 @@ static int rzg2l_csi2_probe(struct platform_device *pdev)
> if (IS_ERR(csi2->base))
> return PTR_ERR(csi2->base);
>
> - csi2->cmn_rstb = devm_reset_control_get_exclusive(&pdev->dev, "cmn-rstb");
> + csi2->cmn_rstb = devm_reset_control_get_exclusive(dev, "cmn-rstb");
> if (IS_ERR(csi2->cmn_rstb))
> - return dev_err_probe(&pdev->dev, PTR_ERR(csi2->cmn_rstb),
> + return dev_err_probe(dev, PTR_ERR(csi2->cmn_rstb),
> "Failed to get cpg cmn-rstb\n");
>
> - csi2->presetn = devm_reset_control_get_shared(&pdev->dev, "presetn");
> + csi2->presetn = devm_reset_control_get_shared(dev, "presetn");
> if (IS_ERR(csi2->presetn))
> - return dev_err_probe(&pdev->dev, PTR_ERR(csi2->presetn),
> + return dev_err_probe(dev, PTR_ERR(csi2->presetn),
> "Failed to get cpg presetn\n");
>
> - csi2->sysclk = devm_clk_get(&pdev->dev, "system");
> + csi2->sysclk = devm_clk_get(dev, "system");
> if (IS_ERR(csi2->sysclk))
> - return dev_err_probe(&pdev->dev, PTR_ERR(csi2->sysclk),
> + return dev_err_probe(dev, PTR_ERR(csi2->sysclk),
> "Failed to get system clk\n");
>
> - csi2->vclk = devm_clk_get(&pdev->dev, "video");
> + csi2->vclk = devm_clk_get(dev, "video");
> if (IS_ERR(csi2->vclk))
> - return dev_err_probe(&pdev->dev, PTR_ERR(csi2->vclk),
> + return dev_err_probe(dev, PTR_ERR(csi2->vclk),
> "Failed to get video clock\n");
> csi2->vclk_rate = clk_get_rate(csi2->vclk);
>
> - csi2->dev = &pdev->dev;
> + csi2->dev = dev;
>
> platform_set_drvdata(pdev, csi2);
>
> @@ -804,18 +805,18 @@ static int rzg2l_csi2_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> - pm_runtime_enable(&pdev->dev);
> + pm_runtime_enable(dev);
>
> ret = rzg2l_validate_csi2_lanes(csi2);
> if (ret)
> goto error_pm;
>
> - csi2->subdev.dev = &pdev->dev;
> + csi2->subdev.dev = dev;
> v4l2_subdev_init(&csi2->subdev, &rzg2l_csi2_subdev_ops);
> csi2->subdev.internal_ops = &rzg2l_csi2_internal_ops;
> - v4l2_set_subdevdata(&csi2->subdev, &pdev->dev);
> + v4l2_set_subdevdata(&csi2->subdev, dev);
> snprintf(csi2->subdev.name, sizeof(csi2->subdev.name),
> - "csi-%s", dev_name(&pdev->dev));
> + "csi-%s", dev_name(dev));
> csi2->subdev.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
>
> csi2->subdev.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
> @@ -852,7 +853,7 @@ static int rzg2l_csi2_probe(struct platform_device *pdev)
> v4l2_async_nf_cleanup(&csi2->notifier);
> media_entity_cleanup(&csi2->subdev.entity);
> error_pm:
> - pm_runtime_disable(&pdev->dev);
> + pm_runtime_disable(dev);
>
> return ret;
> }
>

--
Regards,

Laurent Pinchart