linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Santosh Shilimkar <ssantosh@kernel.org>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Roger Quadros <rogerq@kernel.org>,
	Tony Lindgren <tony@atomide.com>,
	Vladimir Zapolskiy <vz@mleia.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Michal Simek <michal.simek@amd.com>,
	<linux-kernel@vger.kernel.org>, <linux-omap@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 7/7] memory: pl353-smc: simplify with devm_clk_get_enabled()
Date: Fri, 23 Aug 2024 12:56:37 +0100	[thread overview]
Message-ID: <20240823125637.00007fe4@Huawei.com> (raw)
In-Reply-To: <20240823-b4-cleanup-h-guard-v1-7-01668915bd55@linaro.org>

On Fri, 23 Aug 2024 12:16:02 +0200
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> wrote:

> Use devm_clk_get_enabled() to drop clock prepare/unprepare parts and
> make code simpler.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
LGTM.
Follow up suggestion inline.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/memory/pl353-smc.c | 36 +++---------------------------------
>  1 file changed, 3 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/memory/pl353-smc.c b/drivers/memory/pl353-smc.c
> index c75b99e49970..994c7a792e34 100644
> --- a/drivers/memory/pl353-smc.c
> +++ b/drivers/memory/pl353-smc.c
> @@ -75,34 +75,21 @@ static int pl353_smc_probe(struct amba_device *adev, const struct amba_id *id)
>  	const struct of_device_id *match = NULL;
>  	struct pl353_smc_data *pl353_smc;
>  	struct device_node *child;
> -	int err;
>  
>  	pl353_smc = devm_kzalloc(&adev->dev, sizeof(*pl353_smc), GFP_KERNEL);
>  	if (!pl353_smc)
>  		return -ENOMEM;
>  
> -	pl353_smc->aclk = devm_clk_get(&adev->dev, "apb_pclk");
> +	pl353_smc->aclk = devm_clk_get_enabled(&adev->dev, "apb_pclk");
>  	if (IS_ERR(pl353_smc->aclk))
>  		return dev_err_probe(&adev->dev, PTR_ERR(pl353_smc->aclk),
>  				     "aclk clock not found.\n");
>  
> -	pl353_smc->memclk = devm_clk_get(&adev->dev, "memclk");
> +	pl353_smc->memclk = devm_clk_get_enabled(&adev->dev, "memclk");
>  	if (IS_ERR(pl353_smc->memclk))
>  		return dev_err_probe(&adev->dev, PTR_ERR(pl353_smc->memclk),
>  				     "memclk clock not found.\n");
>  
> -	err = clk_prepare_enable(pl353_smc->aclk);
> -	if (err) {
> -		dev_err(&adev->dev, "Unable to enable AXI clock.\n");
> -		return err;
> -	}
> -
> -	err = clk_prepare_enable(pl353_smc->memclk);
> -	if (err) {
> -		dev_err(&adev->dev, "Unable to enable memory clock.\n");
> -		goto disable_axi_clk;
> -	}
> -
>  	amba_set_drvdata(adev, pl353_smc);
>  
>  	/* Find compatible children. Only a single child is supported */
> @@ -115,30 +102,14 @@ static int pl353_smc_probe(struct amba_device *adev, const struct amba_id *id)
>  		break;
>  	}
>  	if (!match) {
With change below this becomes unconditional as we'll have already
returned in the loop for the good path.

Might as well use dev_err_probe() here as well to save a few lines.

> -		err = -ENODEV;
>  		dev_err(&adev->dev, "no matching children\n");
> -		goto disable_mem_clk;
> +		return -ENODEV;
>  	}
>  
>  	of_platform_device_create(child, NULL, &adev->dev);
>  	of_node_put(child);

An additional cleanup looks sensible here.

Push this last bit into the loop and use 

for_each_available_child_of_node_scoped()

Assuming you don't already have a patch doing that :)

>  
>  	return 0;
> -
> -disable_mem_clk:
> -	clk_disable_unprepare(pl353_smc->memclk);
> -disable_axi_clk:
> -	clk_disable_unprepare(pl353_smc->aclk);
> -
> -	return err;
> -}
> -
> -static void pl353_smc_remove(struct amba_device *adev)
> -{
> -	struct pl353_smc_data *pl353_smc = amba_get_drvdata(adev);
> -
> -	clk_disable_unprepare(pl353_smc->memclk);
> -	clk_disable_unprepare(pl353_smc->aclk);
>  }
>  
>  static const struct amba_id pl353_ids[] = {
> @@ -157,7 +128,6 @@ static struct amba_driver pl353_smc_driver = {
>  	},
>  	.id_table = pl353_ids,
>  	.probe = pl353_smc_probe,
> -	.remove = pl353_smc_remove,
>  };
>  
>  module_amba_driver(pl353_smc_driver);
> 



  parent reply	other threads:[~2024-08-23 11:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23 10:15 [PATCH 0/7] memory: simplify with devm() and guard() Krzysztof Kozlowski
2024-08-23 10:15 ` [PATCH 1/7] memory: emif: drop unused 'irq_state' member Krzysztof Kozlowski
2024-08-23 10:15 ` [PATCH 2/7] memory: emif: simplify locking with guard() Krzysztof Kozlowski
2024-08-23 11:40   ` Jonathan Cameron
2024-08-23 10:15 ` [PATCH 3/7] memory: omap-gpmc: " Krzysztof Kozlowski
2024-08-23 11:42   ` Jonathan Cameron
2024-08-23 10:15 ` [PATCH 4/7] memory: pl172: simplify with dev_err_probe() Krzysztof Kozlowski
2024-08-23 11:46   ` Jonathan Cameron
2024-08-23 12:22   ` Vladimir Zapolskiy
2024-08-23 10:16 ` [PATCH 5/7] memory: pl172: simplify with devm_clk_get_enabled() Krzysztof Kozlowski
2024-08-23 11:51   ` Jonathan Cameron
2024-08-23 12:22   ` Vladimir Zapolskiy
2024-08-23 10:16 ` [PATCH 6/7] memory: pl353-smc: simplify with dev_err_probe() Krzysztof Kozlowski
2024-08-23 11:22   ` Miquel Raynal
2024-08-23 11:53   ` Jonathan Cameron
2024-08-23 10:16 ` [PATCH 7/7] memory: pl353-smc: simplify with devm_clk_get_enabled() Krzysztof Kozlowski
2024-08-23 11:23   ` Miquel Raynal
2024-08-23 11:56   ` Jonathan Cameron [this message]
2024-08-25  8:13     ` Krzysztof Kozlowski
2024-08-25 12:22 ` [PATCH 0/7] memory: simplify with devm() and guard() Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240823125637.00007fe4@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=krzk@kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=rogerq@kernel.org \
    --cc=ssantosh@kernel.org \
    --cc=tony@atomide.com \
    --cc=vz@mleia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).