* [PATCH] iio: adc: ad7173: simplify clock enable/disable
@ 2025-06-20 14:30 David Lechner
2025-06-22 14:26 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: David Lechner @ 2025-06-20 14:30 UTC (permalink / raw)
To: Michael Hennerich, Jonathan Cameron, Nuno Sá,
Andy Shevchenko
Cc: linux-iio, linux-kernel, David Lechner
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>
---
drivers/iio/adc/ad7173.c | 24 +++++-------------------
1 file changed, 5 insertions(+), 19 deletions(-)
diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c
index d75adb88af206f6123f5d556c2f5426dc313b662..dd9fa35555c79ead5a1b88d1dc6cc3db122502be 100644
--- a/drivers/iio/adc/ad7173.c
+++ b/drivers/iio/adc/ad7173.c
@@ -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);
---
base-commit: 7461179e080df770240850a126cc7dbffad195c8
change-id: 20250620-iio-adc-ad7173-simplify-clock-enable-disable-b38d038c7710
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: adc: ad7173: simplify clock enable/disable
2025-06-20 14:30 [PATCH] iio: adc: ad7173: simplify clock enable/disable David Lechner
@ 2025-06-22 14:26 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2025-06-22 14:26 UTC (permalink / raw)
To: David Lechner
Cc: Michael Hennerich, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
On Fri, 20 Jun 2025 09:30:46 -0500
David Lechner <dlechner@baylibre.com> wrote:
> 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>
Applied.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-22 14:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-20 14:30 [PATCH] iio: adc: ad7173: simplify clock enable/disable David Lechner
2025-06-22 14:26 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).