Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (lan966x) Use the devm_clk_get_enabled() helper function

Use the devm_clk_get_enabled() helper function instead of hand-writing it.
It saves some line of codes.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/25f2ab4c61d4fc48e8200f8754bb446f2b89ea89.1688795527.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Christophe JAILLET and committed by
Guenter Roeck
6698cbd6 c15a8edd

+1 -23
+1 -23
drivers/hwmon/lan966x-hwmon.c
··· 334 334 return devm_regmap_init_mmio(&pdev->dev, base, &regmap_config); 335 335 } 336 336 337 - static void lan966x_clk_disable(void *data) 338 - { 339 - struct lan966x_hwmon *hwmon = data; 340 - 341 - clk_disable_unprepare(hwmon->clk); 342 - } 343 - 344 - static int lan966x_clk_enable(struct device *dev, struct lan966x_hwmon *hwmon) 345 - { 346 - int ret; 347 - 348 - ret = clk_prepare_enable(hwmon->clk); 349 - if (ret) 350 - return ret; 351 - 352 - return devm_add_action_or_reset(dev, lan966x_clk_disable, hwmon); 353 - } 354 - 355 337 static int lan966x_hwmon_probe(struct platform_device *pdev) 356 338 { 357 339 struct device *dev = &pdev->dev; ··· 345 363 if (!hwmon) 346 364 return -ENOMEM; 347 365 348 - hwmon->clk = devm_clk_get(dev, NULL); 366 + hwmon->clk = devm_clk_get_enabled(dev, NULL); 349 367 if (IS_ERR(hwmon->clk)) 350 368 return dev_err_probe(dev, PTR_ERR(hwmon->clk), 351 369 "failed to get clock\n"); 352 - 353 - ret = lan966x_clk_enable(dev, hwmon); 354 - if (ret) 355 - return dev_err_probe(dev, ret, "failed to enable clock\n"); 356 370 357 371 hwmon->clk_rate = clk_get_rate(hwmon->clk); 358 372