mirror of
https://github.com/torvalds/linux.git
synced 2026-05-26 16:12:59 +02:00
iio: adc: ad7173: simplify clock enable/disable
Use devm_clk_get_enabled() instead of devm_clk_get(), clk_prepare_enable(), devm_add_action_or_reset() to simplify the code as it effectively does the same thing. We can also drop ext_clk from struct ad7173_state since it is not used anywhere else. Signed-off-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/20250620-iio-adc-ad7173-simplify-clock-enable-disable-v1-1-8bc693b190ec@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
e602ee3998
commit
b1c5f11dd1
|
|
@ -228,7 +228,6 @@ struct ad7173_state {
|
|||
struct ida cfg_slots_status;
|
||||
unsigned long long config_usage_counter;
|
||||
unsigned long long *config_cnts;
|
||||
struct clk *ext_clk;
|
||||
struct clk_hw int_clk_hw;
|
||||
struct regmap *reg_gpiocon_regmap;
|
||||
struct gpio_regmap *gpio_regmap;
|
||||
|
|
@ -1344,11 +1343,6 @@ static void ad7173_disable_regulators(void *data)
|
|||
regulator_bulk_disable(ARRAY_SIZE(st->regulators), st->regulators);
|
||||
}
|
||||
|
||||
static void ad7173_clk_disable_unprepare(void *clk)
|
||||
{
|
||||
clk_disable_unprepare(clk);
|
||||
}
|
||||
|
||||
static unsigned long ad7173_sel_clk(struct ad7173_state *st,
|
||||
unsigned int clk_sel)
|
||||
{
|
||||
|
|
@ -1718,22 +1712,14 @@ static int ad7173_fw_parse_device_config(struct iio_dev *indio_dev)
|
|||
AD7173_ADC_MODE_CLOCKSEL_INT);
|
||||
ad7173_register_clk_provider(indio_dev);
|
||||
} else {
|
||||
struct clk *clk;
|
||||
|
||||
st->adc_mode |= FIELD_PREP(AD7173_ADC_MODE_CLOCKSEL_MASK,
|
||||
AD7173_ADC_MODE_CLOCKSEL_EXT + ret);
|
||||
st->ext_clk = devm_clk_get(dev, ad7173_clk_sel[ret]);
|
||||
if (IS_ERR(st->ext_clk))
|
||||
return dev_err_probe(dev, PTR_ERR(st->ext_clk),
|
||||
clk = devm_clk_get_enabled(dev, ad7173_clk_sel[ret]);
|
||||
if (IS_ERR(clk))
|
||||
return dev_err_probe(dev, PTR_ERR(clk),
|
||||
"Failed to get external clock\n");
|
||||
|
||||
ret = clk_prepare_enable(st->ext_clk);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret,
|
||||
"Failed to enable external clock\n");
|
||||
|
||||
ret = devm_add_action_or_reset(dev, ad7173_clk_disable_unprepare,
|
||||
st->ext_clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ad7173_fw_parse_channel_config(indio_dev);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user