From: Guenter Roeck <linux@roeck-us.net>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Jean Delvare <jdelvare@suse.com>,
Lars Povlsen <lars.povlsen@microchip.com>,
Steen Hegelund <Steen.Hegelund@microchip.com>,
UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org, linux-hwmon@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] hwmon: (sparx5) Use devm_clk_get_enabled() helper
Date: Mon, 29 Aug 2022 06:53:38 -0700 [thread overview]
Message-ID: <20220829135338.GA229655@roeck-us.net> (raw)
In-Reply-To: <cfe4c965074b5ecbe03830b05e038b4594c7b970.1661336689.git.christophe.jaillet@wanadoo.fr>
On Wed, Aug 24, 2022 at 12:25:13PM +0200, Christophe JAILLET wrote:
> The devm_clk_get_enabled() helper:
> - calls devm_clk_get()
> - calls clk_prepare_enable() and registers what is needed in order to
> call clk_disable_unprepare() when needed, as a managed resource.
>
> This simplifies the code, the error handling paths and avoid the need of
> a dedicated function used with devm_add_action_or_reset().
>
> Based on my test with allyesconfig, this reduces the .o size from:
> text data bss dec hex filename
> 2419 1472 0 3891 f33 drivers/hwmon/sparx5-temp.o
> down to:
> 2155 1472 0 3627 e2b drivers/hwmon/sparx5-temp.o
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Applied to hwmon-next.
Thanks,
Guenter
> ---
> devm_clk_get_enabled() is new and is part of 6.0-rc1
> ---
> drivers/hwmon/sparx5-temp.c | 19 +------------------
> 1 file changed, 1 insertion(+), 18 deletions(-)
>
> diff --git a/drivers/hwmon/sparx5-temp.c b/drivers/hwmon/sparx5-temp.c
> index 98be48e3a22a..04fd8505e5d6 100644
> --- a/drivers/hwmon/sparx5-temp.c
> +++ b/drivers/hwmon/sparx5-temp.c
> @@ -26,13 +26,6 @@ struct s5_hwmon {
> struct clk *clk;
> };
>
> -static void s5_temp_clk_disable(void *data)
> -{
> - struct clk *clk = data;
> -
> - clk_disable_unprepare(clk);
> -}
> -
> static void s5_temp_enable(struct s5_hwmon *hwmon)
> {
> u32 val = readl(hwmon->base + TEMP_CFG);
> @@ -113,7 +106,6 @@ static int s5_temp_probe(struct platform_device *pdev)
> {
> struct device *hwmon_dev;
> struct s5_hwmon *hwmon;
> - int ret;
>
> hwmon = devm_kzalloc(&pdev->dev, sizeof(*hwmon), GFP_KERNEL);
> if (!hwmon)
> @@ -123,19 +115,10 @@ static int s5_temp_probe(struct platform_device *pdev)
> if (IS_ERR(hwmon->base))
> return PTR_ERR(hwmon->base);
>
> - hwmon->clk = devm_clk_get(&pdev->dev, NULL);
> + hwmon->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> if (IS_ERR(hwmon->clk))
> return PTR_ERR(hwmon->clk);
>
> - ret = clk_prepare_enable(hwmon->clk);
> - if (ret)
> - return ret;
> -
> - ret = devm_add_action_or_reset(&pdev->dev, s5_temp_clk_disable,
> - hwmon->clk);
> - if (ret)
> - return ret;
> -
> s5_temp_enable(hwmon);
>
> hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev,
WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <linux@roeck-us.net>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Jean Delvare <jdelvare@suse.com>,
Lars Povlsen <lars.povlsen@microchip.com>,
Steen Hegelund <Steen.Hegelund@microchip.com>,
UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org, linux-hwmon@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] hwmon: (sparx5) Use devm_clk_get_enabled() helper
Date: Mon, 29 Aug 2022 06:53:38 -0700 [thread overview]
Message-ID: <20220829135338.GA229655@roeck-us.net> (raw)
In-Reply-To: <cfe4c965074b5ecbe03830b05e038b4594c7b970.1661336689.git.christophe.jaillet@wanadoo.fr>
On Wed, Aug 24, 2022 at 12:25:13PM +0200, Christophe JAILLET wrote:
> The devm_clk_get_enabled() helper:
> - calls devm_clk_get()
> - calls clk_prepare_enable() and registers what is needed in order to
> call clk_disable_unprepare() when needed, as a managed resource.
>
> This simplifies the code, the error handling paths and avoid the need of
> a dedicated function used with devm_add_action_or_reset().
>
> Based on my test with allyesconfig, this reduces the .o size from:
> text data bss dec hex filename
> 2419 1472 0 3891 f33 drivers/hwmon/sparx5-temp.o
> down to:
> 2155 1472 0 3627 e2b drivers/hwmon/sparx5-temp.o
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Applied to hwmon-next.
Thanks,
Guenter
> ---
> devm_clk_get_enabled() is new and is part of 6.0-rc1
> ---
> drivers/hwmon/sparx5-temp.c | 19 +------------------
> 1 file changed, 1 insertion(+), 18 deletions(-)
>
> diff --git a/drivers/hwmon/sparx5-temp.c b/drivers/hwmon/sparx5-temp.c
> index 98be48e3a22a..04fd8505e5d6 100644
> --- a/drivers/hwmon/sparx5-temp.c
> +++ b/drivers/hwmon/sparx5-temp.c
> @@ -26,13 +26,6 @@ struct s5_hwmon {
> struct clk *clk;
> };
>
> -static void s5_temp_clk_disable(void *data)
> -{
> - struct clk *clk = data;
> -
> - clk_disable_unprepare(clk);
> -}
> -
> static void s5_temp_enable(struct s5_hwmon *hwmon)
> {
> u32 val = readl(hwmon->base + TEMP_CFG);
> @@ -113,7 +106,6 @@ static int s5_temp_probe(struct platform_device *pdev)
> {
> struct device *hwmon_dev;
> struct s5_hwmon *hwmon;
> - int ret;
>
> hwmon = devm_kzalloc(&pdev->dev, sizeof(*hwmon), GFP_KERNEL);
> if (!hwmon)
> @@ -123,19 +115,10 @@ static int s5_temp_probe(struct platform_device *pdev)
> if (IS_ERR(hwmon->base))
> return PTR_ERR(hwmon->base);
>
> - hwmon->clk = devm_clk_get(&pdev->dev, NULL);
> + hwmon->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> if (IS_ERR(hwmon->clk))
> return PTR_ERR(hwmon->clk);
>
> - ret = clk_prepare_enable(hwmon->clk);
> - if (ret)
> - return ret;
> -
> - ret = devm_add_action_or_reset(&pdev->dev, s5_temp_clk_disable,
> - hwmon->clk);
> - if (ret)
> - return ret;
> -
> s5_temp_enable(hwmon);
>
> hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev,
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-08-29 13:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 10:25 [PATCH] hwmon: (sparx5) Use devm_clk_get_enabled() helper Christophe JAILLET
2022-08-24 10:25 ` Christophe JAILLET
2022-08-29 13:53 ` Guenter Roeck [this message]
2022-08-29 13:53 ` Guenter Roeck
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=20220829135338.GA229655@roeck-us.net \
--to=linux@roeck-us.net \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=jdelvare@suse.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lars.povlsen@microchip.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.