Commit c367982a authored by Sachin Kamat's avatar Sachin Kamat Committed by Jonathan Cameron

iio: dac: ad5064: Use devm_* APIs

devm_* APIs are device managed and make code simpler.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent fa659a40
...@@ -442,7 +442,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, ...@@ -442,7 +442,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
unsigned int i; unsigned int i;
int ret; int ret;
indio_dev = iio_device_alloc(sizeof(*st)); indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
if (indio_dev == NULL) if (indio_dev == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -456,23 +456,23 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, ...@@ -456,23 +456,23 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
for (i = 0; i < ad5064_num_vref(st); ++i) for (i = 0; i < ad5064_num_vref(st); ++i)
st->vref_reg[i].supply = ad5064_vref_name(st, i); st->vref_reg[i].supply = ad5064_vref_name(st, i);
ret = regulator_bulk_get(dev, ad5064_num_vref(st), ret = devm_regulator_bulk_get(dev, ad5064_num_vref(st),
st->vref_reg); st->vref_reg);
if (ret) { if (ret) {
if (!st->chip_info->internal_vref) if (!st->chip_info->internal_vref)
goto error_free; return ret;
st->use_internal_vref = true; st->use_internal_vref = true;
ret = ad5064_write(st, AD5064_CMD_CONFIG, 0, ret = ad5064_write(st, AD5064_CMD_CONFIG, 0,
AD5064_CONFIG_INT_VREF_ENABLE, 0); AD5064_CONFIG_INT_VREF_ENABLE, 0);
if (ret) { if (ret) {
dev_err(dev, "Failed to enable internal vref: %d\n", dev_err(dev, "Failed to enable internal vref: %d\n",
ret); ret);
goto error_free; return ret;
} }
} else { } else {
ret = regulator_bulk_enable(ad5064_num_vref(st), st->vref_reg); ret = regulator_bulk_enable(ad5064_num_vref(st), st->vref_reg);
if (ret) if (ret)
goto error_free_reg; return ret;
} }
indio_dev->dev.parent = dev; indio_dev->dev.parent = dev;
...@@ -498,11 +498,6 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, ...@@ -498,11 +498,6 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
error_disable_reg: error_disable_reg:
if (!st->use_internal_vref) if (!st->use_internal_vref)
regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg);
error_free_reg:
if (!st->use_internal_vref)
regulator_bulk_free(ad5064_num_vref(st), st->vref_reg);
error_free:
iio_device_free(indio_dev);
return ret; return ret;
} }
...@@ -514,12 +509,8 @@ static int ad5064_remove(struct device *dev) ...@@ -514,12 +509,8 @@ static int ad5064_remove(struct device *dev)
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
if (!st->use_internal_vref) { if (!st->use_internal_vref)
regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg);
regulator_bulk_free(ad5064_num_vref(st), st->vref_reg);
}
iio_device_free(indio_dev);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment