mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
staging: iio: ad9834: 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 <danascape@gmail.com> Link: https://patch.msgid.link/20250306000459.1554007-1-danascape@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
33220e15ec
commit
cc26591e79
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user