RE: [PATCH 7/8] media: rzg2l-cru: rzg2l-core: Use temporary variable for struct device in rzg2l_cru_probe()

Biju Das
2025-02-10T11:56:58Z

Hi Tommaso Merciai,

> -----Original Message-----
> From: Tommaso Merciai <tomm.merciai@gmail.com>
> Sent: 10 February 2025 11:46
> Subject: [PATCH 7/8] media: rzg2l-cru: rzg2l-core: Use temporary variable for struct device in
> rzg2l_cru_probe()
>
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Use a temporary variable for the struct device pointers to 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>

Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>

Cheers,
Biju

> ---
> .../platform/renesas/rzg2l-cru/rzg2l-core.c | 29 ++++++++++---------
> 1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
> b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
> index 89be584a4988..70fed0ce45ea 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
> @@ -240,10 +240,11 @@ static int rzg2l_cru_media_init(struct rzg2l_cru_dev *cru)
>
> static int rzg2l_cru_probe(struct platform_device *pdev) {
> + struct device *dev = &pdev->dev;
> struct rzg2l_cru_dev *cru;
> int irq, ret;
>
> - cru = devm_kzalloc(&pdev->dev, sizeof(*cru), GFP_KERNEL);
> + cru = devm_kzalloc(dev, sizeof(*cru), GFP_KERNEL);
> if (!cru)
> return -ENOMEM;
>
> @@ -251,32 +252,32 @@ static int rzg2l_cru_probe(struct platform_device *pdev)
> if (IS_ERR(cru->base))
> return PTR_ERR(cru->base);
>
> - cru->presetn = devm_reset_control_get_shared(&pdev->dev, "presetn");
> + cru->presetn = devm_reset_control_get_shared(dev, "presetn");
> if (IS_ERR(cru->presetn))
> - return dev_err_probe(&pdev->dev, PTR_ERR(cru->presetn),
> + return dev_err_probe(dev, PTR_ERR(cru->presetn),
> "Failed to get cpg presetn\n");
>
> - cru->aresetn = devm_reset_control_get_exclusive(&pdev->dev, "aresetn");
> + cru->aresetn = devm_reset_control_get_exclusive(dev, "aresetn");
> if (IS_ERR(cru->aresetn))
> - return dev_err_probe(&pdev->dev, PTR_ERR(cru->aresetn),
> + return dev_err_probe(dev, PTR_ERR(cru->aresetn),
> "Failed to get cpg aresetn\n");
>
> - cru->vclk = devm_clk_get(&pdev->dev, "video");
> + cru->vclk = devm_clk_get(dev, "video");
> if (IS_ERR(cru->vclk))
> - return dev_err_probe(&pdev->dev, PTR_ERR(cru->vclk),
> + return dev_err_probe(dev, PTR_ERR(cru->vclk),
> "Failed to get video clock\n");
>
> - cru->dev = &pdev->dev;
> - cru->info = of_device_get_match_data(&pdev->dev);
> + cru->dev = dev;
> + cru->info = of_device_get_match_data(dev);
>
> irq = platform_get_irq(pdev, 0);
> if (irq < 0)
> return irq;
>
> - ret = devm_request_irq(&pdev->dev, irq, rzg2l_cru_irq, 0,
> + ret = devm_request_irq(dev, irq, rzg2l_cru_irq, 0,
> KBUILD_MODNAME, cru);
> if (ret)
> - return dev_err_probe(&pdev->dev, ret, "failed to request irq\n");
> + return dev_err_probe(dev, ret, "failed to request irq\n");
>
> platform_set_drvdata(pdev, cru);
>
> @@ -285,8 +286,8 @@ static int rzg2l_cru_probe(struct platform_device *pdev)
> return ret;
>
> cru->num_buf = RZG2L_CRU_HW_BUFFER_DEFAULT;
> - pm_suspend_ignore_children(&pdev->dev, true);
> - pm_runtime_enable(&pdev->dev);
> + pm_suspend_ignore_children(dev, true);
> + pm_runtime_enable(dev);
>
> ret = rzg2l_cru_media_init(cru);
> if (ret)
> @@ -296,7 +297,7 @@ static int rzg2l_cru_probe(struct platform_device *pdev)
>
> error_dma_unregister:
> rzg2l_cru_dma_unregister(cru);
> - pm_runtime_disable(&pdev->dev);
> + pm_runtime_disable(dev);
>
> return ret;
> }
> --
> 2.34.1