hwmon: Make use of devm_clk_get_enabled()
Several drivers manually register a devm handler to disable their clk. Convert them to devm_clk_get_enabled(). Acked-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
903882c767
commit
0dee25ebc7
|
@ -394,11 +394,6 @@ static int axi_fan_control_init(struct axi_fan_control_data *ctl,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void axi_fan_control_clk_disable(void *clk)
|
||||
{
|
||||
clk_disable_unprepare(clk);
|
||||
}
|
||||
|
||||
static const struct hwmon_channel_info *axi_fan_control_info[] = {
|
||||
HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT),
|
||||
HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_FAULT | HWMON_F_LABEL),
|
||||
|
@ -478,20 +473,12 @@ static int axi_fan_control_probe(struct platform_device *pdev)
|
|||
if (IS_ERR(ctl->base))
|
||||
return PTR_ERR(ctl->base);
|
||||
|
||||
clk = devm_clk_get(&pdev->dev, NULL);
|
||||
clk = devm_clk_get_enabled(&pdev->dev, NULL);
|
||||
if (IS_ERR(clk)) {
|
||||
dev_err(&pdev->dev, "clk_get failed with %ld\n", PTR_ERR(clk));
|
||||
return PTR_ERR(clk);
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_add_action_or_reset(&pdev->dev, axi_fan_control_clk_disable, clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ctl->clk_rate = clk_get_rate(clk);
|
||||
if (!ctl->clk_rate)
|
||||
return -EINVAL;
|
||||
|
|
|
@ -956,13 +956,6 @@ static struct attribute *ltc2947_attrs[] = {
|
|||
};
|
||||
ATTRIBUTE_GROUPS(ltc2947);
|
||||
|
||||
static void ltc2947_clk_disable(void *data)
|
||||
{
|
||||
struct clk *extclk = data;
|
||||
|
||||
clk_disable_unprepare(extclk);
|
||||
}
|
||||
|
||||
static int ltc2947_setup(struct ltc2947_data *st)
|
||||
{
|
||||
int ret;
|
||||
|
@ -989,7 +982,7 @@ static int ltc2947_setup(struct ltc2947_data *st)
|
|||
return ret;
|
||||
|
||||
/* check external clock presence */
|
||||
extclk = devm_clk_get_optional(st->dev, NULL);
|
||||
extclk = devm_clk_get_optional_enabled(st->dev, NULL);
|
||||
if (IS_ERR(extclk))
|
||||
return dev_err_probe(st->dev, PTR_ERR(extclk),
|
||||
"Failed to get external clock\n");
|
||||
|
@ -1007,14 +1000,6 @@ static int ltc2947_setup(struct ltc2947_data *st)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(extclk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_add_action_or_reset(st->dev, ltc2947_clk_disable,
|
||||
extclk);
|
||||
if (ret)
|
||||
return ret;
|
||||
/* as in table 1 of the datasheet */
|
||||
if (rate_hz >= LTC2947_CLK_MIN && rate_hz <= 1000000)
|
||||
pre = 0;
|
||||
|
|
|
@ -610,24 +610,6 @@ static int pvt_get_regmap(struct platform_device *pdev, char *reg_name,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void pvt_clk_disable(void *data)
|
||||
{
|
||||
struct pvt_device *pvt = data;
|
||||
|
||||
clk_disable_unprepare(pvt->clk);
|
||||
}
|
||||
|
||||
static int pvt_clk_enable(struct device *dev, struct pvt_device *pvt)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = clk_prepare_enable(pvt->clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return devm_add_action_or_reset(dev, pvt_clk_disable, pvt);
|
||||
}
|
||||
|
||||
static void pvt_reset_control_assert(void *data)
|
||||
{
|
||||
struct pvt_device *pvt = data;
|
||||
|
@ -799,16 +781,10 @@ static int mr75203_probe(struct platform_device *pdev)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
pvt->clk = devm_clk_get(dev, NULL);
|
||||
pvt->clk = devm_clk_get_enabled(dev, NULL);
|
||||
if (IS_ERR(pvt->clk))
|
||||
return dev_err_probe(dev, PTR_ERR(pvt->clk), "failed to get clock\n");
|
||||
|
||||
ret = pvt_clk_enable(dev, pvt);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to enable clock\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
pvt->rst = devm_reset_control_get_optional_exclusive(dev, NULL);
|
||||
if (IS_ERR(pvt->rst))
|
||||
return dev_err_probe(dev, PTR_ERR(pvt->rst),
|
||||
|
|
Loading…
Reference in New Issue