Skip to content

Commit d571452

Browse files
Huan Yangdlezcano
authored andcommitted
thermal/drivers/sprd: Use devm_clk_get_enabled() helpers
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(). Signed-off-by: Huan Yang <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent f41e647 commit d571452

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

drivers/thermal/sprd_thermal.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -359,21 +359,17 @@ static int sprd_thm_probe(struct platform_device *pdev)
359359
return -EINVAL;
360360
}
361361

362-
thm->clk = devm_clk_get(&pdev->dev, "enable");
362+
thm->clk = devm_clk_get_enabled(&pdev->dev, "enable");
363363
if (IS_ERR(thm->clk)) {
364364
dev_err(&pdev->dev, "failed to get enable clock\n");
365365
return PTR_ERR(thm->clk);
366366
}
367367

368-
ret = clk_prepare_enable(thm->clk);
369-
if (ret)
370-
return ret;
371-
372368
sprd_thm_para_config(thm);
373369

374370
ret = sprd_thm_cal_read(np, "thm_sign_cal", &val);
375371
if (ret)
376-
goto disable_clk;
372+
return ret;
377373

378374
if (val > 0)
379375
thm->ratio_sign = -1;
@@ -382,7 +378,7 @@ static int sprd_thm_probe(struct platform_device *pdev)
382378

383379
ret = sprd_thm_cal_read(np, "thm_ratio_cal", &thm->ratio_off);
384380
if (ret)
385-
goto disable_clk;
381+
return ret;
386382

387383
for_each_child_of_node(np, sen_child) {
388384
sen = devm_kzalloc(&pdev->dev, sizeof(*sen), GFP_KERNEL);
@@ -439,8 +435,6 @@ static int sprd_thm_probe(struct platform_device *pdev)
439435

440436
of_put:
441437
of_node_put(sen_child);
442-
disable_clk:
443-
clk_disable_unprepare(thm->clk);
444438
return ret;
445439
}
446440

@@ -526,8 +520,6 @@ static void sprd_thm_remove(struct platform_device *pdev)
526520
devm_thermal_of_zone_unregister(&pdev->dev,
527521
thm->sensor[i]->tzd);
528522
}
529-
530-
clk_disable_unprepare(thm->clk);
531523
}
532524

533525
static const struct of_device_id sprd_thermal_of_match[] = {

0 commit comments

Comments
 (0)