Commit 907f2e4f authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Guenter Roeck

hwmon: (sparx5) Use devm_clk_get_enabled() helper

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: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/cfe4c965074b5ecbe03830b05e038b4594c7b970.1661336689.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 6ebab74e
...@@ -26,13 +26,6 @@ struct s5_hwmon { ...@@ -26,13 +26,6 @@ struct s5_hwmon {
struct clk *clk; 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) static void s5_temp_enable(struct s5_hwmon *hwmon)
{ {
u32 val = readl(hwmon->base + TEMP_CFG); u32 val = readl(hwmon->base + TEMP_CFG);
...@@ -113,7 +106,6 @@ static int s5_temp_probe(struct platform_device *pdev) ...@@ -113,7 +106,6 @@ static int s5_temp_probe(struct platform_device *pdev)
{ {
struct device *hwmon_dev; struct device *hwmon_dev;
struct s5_hwmon *hwmon; struct s5_hwmon *hwmon;
int ret;
hwmon = devm_kzalloc(&pdev->dev, sizeof(*hwmon), GFP_KERNEL); hwmon = devm_kzalloc(&pdev->dev, sizeof(*hwmon), GFP_KERNEL);
if (!hwmon) if (!hwmon)
...@@ -123,19 +115,10 @@ static int s5_temp_probe(struct platform_device *pdev) ...@@ -123,19 +115,10 @@ static int s5_temp_probe(struct platform_device *pdev)
if (IS_ERR(hwmon->base)) if (IS_ERR(hwmon->base))
return PTR_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)) if (IS_ERR(hwmon->clk))
return PTR_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); s5_temp_enable(hwmon);
hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev, hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment