[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <183e6ca4-f1b4-4b41-bad1-9999df205277@wanadoo.fr>
Date: Wed, 21 Aug 2024 08:53:02 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Huan Yang <link@...o.com>,
Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
linux-kernel@...r.kernel.org
Cc: opensource.kernel@...o.com
Subject: Re: [PATCH v2] nvmem: jz4780-efuse: Use devm_clk_get_enabled()
helpers
Le 21/08/2024 à 03:40, Huan Yang a écrit :
> The devm_clk_get_enabled() helpers:
> - call devm_clk_get()
> - call clk_prepare_enable() and register what is needed in order to
> call clk_disable_unprepare() when needed, as a managed resource.
>
> This simplifies the code and avoids the calls to clk_disable_unprepare().
>
> Due to clk only used when probe, no need to save it into jz4780_efuse.
>
> Signed-off-by: Huan Yang <link@...o.com>
> Suggested-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Nitpick: no need to add this S-b. I just made a comment when looking at
your patch in order to improve it. I'm not the one that suggested the
initial change. All merit is yours.
Reviewed-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> ---
> v1 -> v2: remove clk pointer from jz4780_efuse
>
> drivers/nvmem/jz4780-efuse.c | 26 +++++---------------------
> 1 file changed, 5 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/nvmem/jz4780-efuse.c b/drivers/nvmem/jz4780-efuse.c
> index 0b01b840edd9..99c43c93f4a5 100644
> --- a/drivers/nvmem/jz4780-efuse.c
> +++ b/drivers/nvmem/jz4780-efuse.c
> @@ -62,7 +62,6 @@
> struct jz4780_efuse {
> struct device *dev;
> struct regmap *map;
> - struct clk *clk;
> };
>
> /* main entry point */
> @@ -131,11 +130,6 @@ static const struct regmap_config jz4780_efuse_regmap_config = {
> .max_register = JZ_EFUDATA(7),
> };
>
> -static void clk_disable_unprepare_helper(void *clock)
> -{
> - clk_disable_unprepare(clock);
> -}
> -
> static int jz4780_efuse_probe(struct platform_device *pdev)
> {
> struct nvmem_device *nvmem;
> @@ -146,7 +140,7 @@ static int jz4780_efuse_probe(struct platform_device *pdev)
> unsigned long rd_strobe;
> struct device *dev = &pdev->dev;
> void __iomem *regs;
> - int ret;
> + struct clk *clk;
>
> efuse = devm_kzalloc(dev, sizeof(*efuse), GFP_KERNEL);
> if (!efuse)
> @@ -161,21 +155,11 @@ static int jz4780_efuse_probe(struct platform_device *pdev)
> if (IS_ERR(efuse->map))
> return PTR_ERR(efuse->map);
>
> - efuse->clk = devm_clk_get(&pdev->dev, NULL);
> - if (IS_ERR(efuse->clk))
> - return PTR_ERR(efuse->clk);
> -
> - ret = clk_prepare_enable(efuse->clk);
> - if (ret < 0)
> - return ret;
> -
> - ret = devm_add_action_or_reset(&pdev->dev,
> - clk_disable_unprepare_helper,
> - efuse->clk);
> - if (ret < 0)
> - return ret;
> + clk = devm_clk_get_enabled(&pdev->dev, NULL);
> + if (IS_ERR(clk))
> + return PTR_ERR(clk);
>
> - clk_rate = clk_get_rate(efuse->clk);
> + clk_rate = clk_get_rate(clk);
>
> efuse->dev = dev;
>
Powered by blists - more mailing lists