Commit 4968f672 authored by Huan Yang's avatar Huan Yang Committed by Lee Jones

leds: lp55xx: Use devm_clk_get_enabled() helpers

Simplify the code a bunch by using managed resource helpers.

Also, there is no need to save clk pointer anymore.
Suggested-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarHuan Yang <link@vivo.com>
Link: https://lore.kernel.org/r/20240821013725.785956-1-link@vivo.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent 77b2b475
......@@ -965,24 +965,16 @@ EXPORT_SYMBOL_GPL(lp55xx_update_bits);
bool lp55xx_is_extclk_used(struct lp55xx_chip *chip)
{
struct clk *clk;
int err;
clk = devm_clk_get(&chip->cl->dev, "32k_clk");
clk = devm_clk_get_enabled(&chip->cl->dev, "32k_clk");
if (IS_ERR(clk))
goto use_internal_clk;
err = clk_prepare_enable(clk);
if (err)
if (clk_get_rate(clk) != LP55XX_CLK_32K)
goto use_internal_clk;
if (clk_get_rate(clk) != LP55XX_CLK_32K) {
clk_disable_unprepare(clk);
goto use_internal_clk;
}
dev_info(&chip->cl->dev, "%dHz external clock used\n", LP55XX_CLK_32K);
chip->clk = clk;
return true;
use_internal_clk:
......@@ -995,9 +987,6 @@ static void lp55xx_deinit_device(struct lp55xx_chip *chip)
{
struct lp55xx_platform_data *pdata = chip->pdata;
if (chip->clk)
clk_disable_unprepare(chip->clk);
if (pdata->enable_gpiod)
gpiod_set_value(pdata->enable_gpiod, 0);
}
......
......@@ -193,7 +193,6 @@ struct lp55xx_engine {
*/
struct lp55xx_chip {
struct i2c_client *cl;
struct clk *clk;
struct lp55xx_platform_data *pdata;
struct mutex lock; /* lock for user-space interface */
int num_leds;
......
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