Skip to content

Commit 2fd7285

Browse files
mhennerichnunojsa
authored andcommitted
iio: frequency: ad9528: Fix vcc regulator EPROBE_DEFER handling
Use devm_regulator_get_enable() and eliminate some boilerplate code. This will also allow the deferred probe mechanism to re-probe if the regulator is not yet available. Signed-off-by: Michael Hennerich <[email protected]>
1 parent 9197af5 commit 2fd7285

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

drivers/iio/frequency/ad9528.c

+5-20
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ struct ad9528_outputs {
268268

269269
struct ad9528_state {
270270
struct spi_device *spi;
271-
struct regulator *reg;
272271
struct ad9528_platform_data *pdata;
273272
struct ad9528_outputs output[AD9528_NUM_CHAN];
274273
struct iio_chan_spec ad9528_channels[AD9528_NUM_CHAN];
@@ -1656,13 +1655,6 @@ struct ad9528_platform_data *ad9528_parse_dt(struct device *dev)
16561655
}
16571656
#endif
16581657

1659-
static void ad9528_reg_disable(void *data)
1660-
{
1661-
struct regulator *reg = data;
1662-
1663-
regulator_disable(reg);
1664-
}
1665-
16661658
static int ad9528_probe(struct spi_device *spi)
16671659
{
16681660
struct ad9528_platform_data *pdata;
@@ -1677,6 +1669,11 @@ static int ad9528_probe(struct spi_device *spi)
16771669
if (PTR_ERR(clk) == -EPROBE_DEFER)
16781670
return -EPROBE_DEFER;
16791671

1672+
ret = devm_regulator_get_enable(&spi->dev, "vcc");
1673+
if (ret)
1674+
return dev_err_probe(&spi->dev, ret,
1675+
"Failed to get vcc regulator");
1676+
16801677
if (spi->dev.of_node)
16811678
pdata = ad9528_parse_dt(&spi->dev);
16821679
else
@@ -1699,18 +1696,6 @@ static int ad9528_probe(struct spi_device *spi)
16991696

17001697
mutex_init(&st->lock);
17011698

1702-
st->reg = devm_regulator_get(&spi->dev, "vcc");
1703-
if (!IS_ERR(st->reg)) {
1704-
ret = regulator_enable(st->reg);
1705-
if (ret)
1706-
return ret;
1707-
1708-
ret = devm_add_action_or_reset(&spi->dev, ad9528_reg_disable,
1709-
st->reg);
1710-
if (ret)
1711-
return ret;
1712-
}
1713-
17141699
st->sysref_req_gpio = devm_gpiod_get_optional(&spi->dev, "sysref-req",
17151700
GPIOD_OUT_LOW);
17161701
if (IS_ERR(st->sysref_req_gpio))

0 commit comments

Comments
 (0)