Re: [PATCH] drm/komeda: Remove unnecessary NULL check before clk_prepare_enable()

From: Liviu Dudau
Date: Thu Mar 13 2025 - 10:09:01 EST


On Thu, Mar 13, 2025 at 04:29:07PM +0800, Chen Ni wrote:
> clk_prepare_enable() already checked NULL clock parameter.
> Remove unneeded NULL check for clk here.

You're not saving anything here. If mdev->aclk is NULL you still end up
calling clk_prepare() and clk_enable() even if they return zero immediately.
And if you don't like the check for mdev->aclk not being NULL, you should
also move the clk_disable_unprepare() call outside the if() {...} block.

Best regards,
Liviu

>
> Signed-off-by: Chen Ni <nichen@xxxxxxxxxxx>
> ---
> drivers/gpu/drm/arm/display/komeda/komeda_dev.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> index 5ba62e637a61..2b59830f0572 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> @@ -282,8 +282,7 @@ void komeda_dev_destroy(struct komeda_dev *mdev)
>
> debugfs_remove_recursive(mdev->debugfs_root);
>
> - if (mdev->aclk)
> - clk_prepare_enable(mdev->aclk);
> + clk_prepare_enable(mdev->aclk);
>
> for (i = 0; i < mdev->n_pipelines; i++) {
> komeda_pipeline_destroy(mdev, mdev->pipelines[i]);
> --
> 2.25.1
>

--
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯