Skip to content

Commit

Permalink
staging: iio: ad9834: Use devm_regulator_get_enable()
Browse files Browse the repository at this point in the history
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 <danascape@gmail.com>
Link: https://patch.msgid.link/20250306000459.1554007-1-danascape@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Saalim Quadri authored and Jonathan Cameron committed Mar 11, 2025
1 parent 33220e1 commit cc26591
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions drivers/staging/iio/frequency/ad9834.c
Original file line number Diff line number Diff line change
@@ -387,33 +387,15 @@ static const struct iio_info ad9833_info = {
.attrs = &ad9833_attribute_group,
};

static void ad9834_disable_reg(void *data)
{
struct regulator *reg = data;

regulator_disable(reg);
}

static int ad9834_probe(struct spi_device *spi)
{
struct ad9834_state *st;
struct iio_dev *indio_dev;
struct regulator *reg;
int ret;

reg = devm_regulator_get(&spi->dev, "avdd");
if (IS_ERR(reg))
return PTR_ERR(reg);

ret = regulator_enable(reg);
if (ret) {
dev_err(&spi->dev, "Failed to enable specified AVDD supply\n");
return ret;
}

ret = devm_add_action_or_reset(&spi->dev, ad9834_disable_reg, reg);
ret = devm_regulator_get_enable(&spi->dev, "avdd");
if (ret)
return ret;
return dev_err_probe(&spi->dev, ret, "Failed to enable specified AVDD supply\n");

indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (!indio_dev) {

0 comments on commit cc26591

Please sign in to comment.