diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-08-19 07:38:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-08-19 15:29:34 -0400 |
commit | 75238230cce22b99e648e96bbc043725832c6ad5 (patch) | |
tree | 51b836b30110883a94f8df8d97341dc3df3b01a6 /drivers/iio | |
parent | 8571ebf7fc1892beadd83dd7af385c599c3ec0d3 (diff) |
iio: dac: ad5624r_spi: Use devm_* APIs
devm_* APIs are device managed and make code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/dac/ad5624r_spi.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c index bb298aaff321..714af757cd56 100644 --- a/drivers/iio/dac/ad5624r_spi.c +++ b/drivers/iio/dac/ad5624r_spi.c | |||
@@ -226,17 +226,15 @@ static int ad5624r_probe(struct spi_device *spi) | |||
226 | struct iio_dev *indio_dev; | 226 | struct iio_dev *indio_dev; |
227 | int ret, voltage_uv = 0; | 227 | int ret, voltage_uv = 0; |
228 | 228 | ||
229 | indio_dev = iio_device_alloc(sizeof(*st)); | 229 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
230 | if (indio_dev == NULL) { | 230 | if (!indio_dev) |
231 | ret = -ENOMEM; | 231 | return -ENOMEM; |
232 | goto error_ret; | ||
233 | } | ||
234 | st = iio_priv(indio_dev); | 232 | st = iio_priv(indio_dev); |
235 | st->reg = regulator_get(&spi->dev, "vcc"); | 233 | st->reg = devm_regulator_get(&spi->dev, "vcc"); |
236 | if (!IS_ERR(st->reg)) { | 234 | if (!IS_ERR(st->reg)) { |
237 | ret = regulator_enable(st->reg); | 235 | ret = regulator_enable(st->reg); |
238 | if (ret) | 236 | if (ret) |
239 | goto error_put_reg; | 237 | return ret; |
240 | 238 | ||
241 | ret = regulator_get_voltage(st->reg); | 239 | ret = regulator_get_voltage(st->reg); |
242 | if (ret < 0) | 240 | if (ret < 0) |
@@ -277,11 +275,6 @@ static int ad5624r_probe(struct spi_device *spi) | |||
277 | error_disable_reg: | 275 | error_disable_reg: |
278 | if (!IS_ERR(st->reg)) | 276 | if (!IS_ERR(st->reg)) |
279 | regulator_disable(st->reg); | 277 | regulator_disable(st->reg); |
280 | error_put_reg: | ||
281 | if (!IS_ERR(st->reg)) | ||
282 | regulator_put(st->reg); | ||
283 | iio_device_free(indio_dev); | ||
284 | error_ret: | ||
285 | 278 | ||
286 | return ret; | 279 | return ret; |
287 | } | 280 | } |
@@ -292,11 +285,8 @@ static int ad5624r_remove(struct spi_device *spi) | |||
292 | struct ad5624r_state *st = iio_priv(indio_dev); | 285 | struct ad5624r_state *st = iio_priv(indio_dev); |
293 | 286 | ||
294 | iio_device_unregister(indio_dev); | 287 | iio_device_unregister(indio_dev); |
295 | if (!IS_ERR(st->reg)) { | 288 | if (!IS_ERR(st->reg)) |
296 | regulator_disable(st->reg); | 289 | regulator_disable(st->reg); |
297 | regulator_put(st->reg); | ||
298 | } | ||
299 | iio_device_free(indio_dev); | ||
300 | 290 | ||
301 | return 0; | 291 | return 0; |
302 | } | 292 | } |