Skip to content

Commit 33220e1

Browse files
danascapejic23
authored andcommitted
staging: iio: ad9832: Use devm_regulator_get_enable()
The regulators are only enabled at probe(), hence replace the boilerplate code by making use of devm_regulator_get_enable() helper. Signed-off-by: Saalim Quadri <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 85a1159 commit 33220e1

File tree

1 file changed

+4
-33
lines changed

1 file changed

+4
-33
lines changed

drivers/staging/iio/frequency/ad9832.c

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@
7474
/**
7575
* struct ad9832_state - driver instance specific data
7676
* @spi: spi_device
77-
* @avdd: supply regulator for the analog section
78-
* @dvdd: supply regulator for the digital section
7977
* @mclk: external master clock
8078
* @ctrl_fp: cached frequency/phase control word
8179
* @ctrl_ss: cached sync/selsrc control word
@@ -94,8 +92,6 @@
9492

9593
struct ad9832_state {
9694
struct spi_device *spi;
97-
struct regulator *avdd;
98-
struct regulator *dvdd;
9995
struct clk *mclk;
10096
unsigned short ctrl_fp;
10197
unsigned short ctrl_ss;
@@ -297,11 +293,6 @@ static const struct iio_info ad9832_info = {
297293
.attrs = &ad9832_attribute_group,
298294
};
299295

300-
static void ad9832_reg_disable(void *reg)
301-
{
302-
regulator_disable(reg);
303-
}
304-
305296
static int ad9832_probe(struct spi_device *spi)
306297
{
307298
struct ad9832_platform_data *pdata = dev_get_platdata(&spi->dev);
@@ -320,33 +311,13 @@ static int ad9832_probe(struct spi_device *spi)
320311

321312
st = iio_priv(indio_dev);
322313

323-
st->avdd = devm_regulator_get(&spi->dev, "avdd");
324-
if (IS_ERR(st->avdd))
325-
return PTR_ERR(st->avdd);
326-
327-
ret = regulator_enable(st->avdd);
328-
if (ret) {
329-
dev_err(&spi->dev, "Failed to enable specified AVDD supply\n");
330-
return ret;
331-
}
332-
333-
ret = devm_add_action_or_reset(&spi->dev, ad9832_reg_disable, st->avdd);
314+
ret = devm_regulator_get_enable(&spi->dev, "avdd");
334315
if (ret)
335-
return ret;
336-
337-
st->dvdd = devm_regulator_get(&spi->dev, "dvdd");
338-
if (IS_ERR(st->dvdd))
339-
return PTR_ERR(st->dvdd);
316+
return dev_err_probe(&spi->dev, ret, "failed to enable specified AVDD voltage\n");
340317

341-
ret = regulator_enable(st->dvdd);
342-
if (ret) {
343-
dev_err(&spi->dev, "Failed to enable specified DVDD supply\n");
344-
return ret;
345-
}
346-
347-
ret = devm_add_action_or_reset(&spi->dev, ad9832_reg_disable, st->dvdd);
318+
ret = devm_regulator_get_enable(&spi->dev, "dvdd");
348319
if (ret)
349-
return ret;
320+
return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVDD supply\n");
350321

351322
st->mclk = devm_clk_get_enabled(&spi->dev, "mclk");
352323
if (IS_ERR(st->mclk))

0 commit comments

Comments
 (0)