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

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

David Lechner and committed by
Jonathan Cameron
b1c5f11d e602ee39

+5 -19
+5 -19
drivers/iio/adc/ad7173.c
··· 228 228 struct ida cfg_slots_status; 229 229 unsigned long long config_usage_counter; 230 230 unsigned long long *config_cnts; 231 - struct clk *ext_clk; 232 231 struct clk_hw int_clk_hw; 233 232 struct regmap *reg_gpiocon_regmap; 234 233 struct gpio_regmap *gpio_regmap; ··· 1343 1344 regulator_bulk_disable(ARRAY_SIZE(st->regulators), st->regulators); 1344 1345 } 1345 1346 1346 - static void ad7173_clk_disable_unprepare(void *clk) 1347 - { 1348 - clk_disable_unprepare(clk); 1349 - } 1350 - 1351 1347 static unsigned long ad7173_sel_clk(struct ad7173_state *st, 1352 1348 unsigned int clk_sel) 1353 1349 { ··· 1712 1718 AD7173_ADC_MODE_CLOCKSEL_INT); 1713 1719 ad7173_register_clk_provider(indio_dev); 1714 1720 } else { 1721 + struct clk *clk; 1722 + 1715 1723 st->adc_mode |= FIELD_PREP(AD7173_ADC_MODE_CLOCKSEL_MASK, 1716 1724 AD7173_ADC_MODE_CLOCKSEL_EXT + ret); 1717 - st->ext_clk = devm_clk_get(dev, ad7173_clk_sel[ret]); 1718 - if (IS_ERR(st->ext_clk)) 1719 - return dev_err_probe(dev, PTR_ERR(st->ext_clk), 1725 + clk = devm_clk_get_enabled(dev, ad7173_clk_sel[ret]); 1726 + if (IS_ERR(clk)) 1727 + return dev_err_probe(dev, PTR_ERR(clk), 1720 1728 "Failed to get external clock\n"); 1721 - 1722 - ret = clk_prepare_enable(st->ext_clk); 1723 - if (ret) 1724 - return dev_err_probe(dev, ret, 1725 - "Failed to enable external clock\n"); 1726 - 1727 - ret = devm_add_action_or_reset(dev, ad7173_clk_disable_unprepare, 1728 - st->ext_clk); 1729 - if (ret) 1730 - return ret; 1731 1729 } 1732 1730 1733 1731 return ad7173_fw_parse_channel_config(indio_dev);