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: ad7192: Simplify using devm_clk_get_optional_enabled()

If st->mclk is not NULL, then st->clock_sel is either AD7192_CLK_EXT_MCLK2
or AD7192_CLK_EXT_MCLK1_2.

So devm_clk_get_optional_enabled() can be used instead of hand writing it.
This saves some line of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/7dbe973905f1fdae5d2f5ae5a3b01dd1d6a9925b.1686774340.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Christophe JAILLET and committed by
Jonathan Cameron
478baae9 5a910007

+1 -15
+1 -15
drivers/iio/adc/ad7192.c
··· 972 972 regulator_disable(reg); 973 973 } 974 974 975 - static void ad7192_clk_disable(void *clk) 976 - { 977 - clk_disable_unprepare(clk); 978 - } 979 - 980 975 static int ad7192_probe(struct spi_device *spi) 981 976 { 982 977 struct ad7192_state *st; ··· 1039 1044 1040 1045 st->fclk = AD7192_INT_FREQ_MHZ; 1041 1046 1042 - st->mclk = devm_clk_get_optional(&spi->dev, "mclk"); 1047 + st->mclk = devm_clk_get_optional_enabled(&spi->dev, "mclk"); 1043 1048 if (IS_ERR(st->mclk)) 1044 1049 return PTR_ERR(st->mclk); 1045 1050 ··· 1047 1052 1048 1053 if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 || 1049 1054 st->clock_sel == AD7192_CLK_EXT_MCLK2) { 1050 - ret = clk_prepare_enable(st->mclk); 1051 - if (ret < 0) 1052 - return ret; 1053 - 1054 - ret = devm_add_action_or_reset(&spi->dev, ad7192_clk_disable, 1055 - st->mclk); 1056 - if (ret) 1057 - return ret; 1058 - 1059 1055 st->fclk = clk_get_rate(st->mclk); 1060 1056 if (!ad7192_valid_external_frequency(st->fclk)) { 1061 1057 dev_err(&spi->dev,