diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-08-24 14:48:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-08-28 15:20:25 -0400 |
commit | e8cac7f61452d45cd4bca8cb11c139edc9633f38 (patch) | |
tree | 88720f9d5592758c957ead95d5c5ddccf9d246ec | |
parent | 1868171c5caef74996c3604146e60b976e249344 (diff) |
staging: iio: adis16240: Use devm_iio_device_alloc
Using devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/staging/iio/accel/adis16240_core.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index fd1f0fd0fba8..3a303a03d028 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c | |||
@@ -236,11 +236,9 @@ static int adis16240_probe(struct spi_device *spi) | |||
236 | struct iio_dev *indio_dev; | 236 | struct iio_dev *indio_dev; |
237 | 237 | ||
238 | /* setup the industrialio driver allocated elements */ | 238 | /* setup the industrialio driver allocated elements */ |
239 | indio_dev = iio_device_alloc(sizeof(*st)); | 239 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
240 | if (indio_dev == NULL) { | 240 | if (!indio_dev) |
241 | ret = -ENOMEM; | 241 | return -ENOMEM; |
242 | goto error_ret; | ||
243 | } | ||
244 | st = iio_priv(indio_dev); | 242 | st = iio_priv(indio_dev); |
245 | /* this is only used for removal purposes */ | 243 | /* this is only used for removal purposes */ |
246 | spi_set_drvdata(spi, indio_dev); | 244 | spi_set_drvdata(spi, indio_dev); |
@@ -254,10 +252,10 @@ static int adis16240_probe(struct spi_device *spi) | |||
254 | 252 | ||
255 | ret = adis_init(st, indio_dev, spi, &adis16240_data); | 253 | ret = adis_init(st, indio_dev, spi, &adis16240_data); |
256 | if (ret) | 254 | if (ret) |
257 | goto error_free_dev; | 255 | return ret; |
258 | ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL); | 256 | ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL); |
259 | if (ret) | 257 | if (ret) |
260 | goto error_free_dev; | 258 | return ret; |
261 | 259 | ||
262 | /* Get the device into a sane initial state */ | 260 | /* Get the device into a sane initial state */ |
263 | ret = adis_initial_startup(st); | 261 | ret = adis_initial_startup(st); |
@@ -270,9 +268,6 @@ static int adis16240_probe(struct spi_device *spi) | |||
270 | 268 | ||
271 | error_cleanup_buffer_trigger: | 269 | error_cleanup_buffer_trigger: |
272 | adis_cleanup_buffer_and_trigger(st, indio_dev); | 270 | adis_cleanup_buffer_and_trigger(st, indio_dev); |
273 | error_free_dev: | ||
274 | iio_device_free(indio_dev); | ||
275 | error_ret: | ||
276 | return ret; | 271 | return ret; |
277 | } | 272 | } |
278 | 273 | ||
@@ -283,7 +278,6 @@ static int adis16240_remove(struct spi_device *spi) | |||
283 | 278 | ||
284 | iio_device_unregister(indio_dev); | 279 | iio_device_unregister(indio_dev); |
285 | adis_cleanup_buffer_and_trigger(st, indio_dev); | 280 | adis_cleanup_buffer_and_trigger(st, indio_dev); |
286 | iio_device_free(indio_dev); | ||
287 | 281 | ||
288 | return 0; | 282 | return 0; |
289 | } | 283 | } |