diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-08-13 02:34:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-08-17 10:50:55 -0400 |
commit | 6694cf9652c718b624c459867e7833c759665225 (patch) | |
tree | 03260b1d0210483ca3efb0e882cbe633ace2e282 /drivers/iio | |
parent | 1ba15cf249061c2f55f4a883ee142002261003a8 (diff) |
iio: gyro: adxrs450: 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>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/gyro/adxrs450.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/iio/gyro/adxrs450.c b/drivers/iio/gyro/adxrs450.c index 8bd72b490b7f..6dab2995f0f2 100644 --- a/drivers/iio/gyro/adxrs450.c +++ b/drivers/iio/gyro/adxrs450.c | |||
@@ -426,11 +426,9 @@ static int adxrs450_probe(struct spi_device *spi) | |||
426 | struct iio_dev *indio_dev; | 426 | struct iio_dev *indio_dev; |
427 | 427 | ||
428 | /* setup the industrialio driver allocated elements */ | 428 | /* setup the industrialio driver allocated elements */ |
429 | indio_dev = iio_device_alloc(sizeof(*st)); | 429 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
430 | if (indio_dev == NULL) { | 430 | if (!indio_dev) |
431 | ret = -ENOMEM; | 431 | return -ENOMEM; |
432 | goto error_ret; | ||
433 | } | ||
434 | st = iio_priv(indio_dev); | 432 | st = iio_priv(indio_dev); |
435 | st->us = spi; | 433 | st->us = spi; |
436 | mutex_init(&st->buf_lock); | 434 | mutex_init(&st->buf_lock); |
@@ -447,7 +445,7 @@ static int adxrs450_probe(struct spi_device *spi) | |||
447 | 445 | ||
448 | ret = iio_device_register(indio_dev); | 446 | ret = iio_device_register(indio_dev); |
449 | if (ret) | 447 | if (ret) |
450 | goto error_free_dev; | 448 | return ret; |
451 | 449 | ||
452 | /* Get the device into a sane initial state */ | 450 | /* Get the device into a sane initial state */ |
453 | ret = adxrs450_initial_setup(indio_dev); | 451 | ret = adxrs450_initial_setup(indio_dev); |
@@ -456,17 +454,12 @@ static int adxrs450_probe(struct spi_device *spi) | |||
456 | return 0; | 454 | return 0; |
457 | error_initial: | 455 | error_initial: |
458 | iio_device_unregister(indio_dev); | 456 | iio_device_unregister(indio_dev); |
459 | error_free_dev: | ||
460 | iio_device_free(indio_dev); | ||
461 | |||
462 | error_ret: | ||
463 | return ret; | 457 | return ret; |
464 | } | 458 | } |
465 | 459 | ||
466 | static int adxrs450_remove(struct spi_device *spi) | 460 | static int adxrs450_remove(struct spi_device *spi) |
467 | { | 461 | { |
468 | iio_device_unregister(spi_get_drvdata(spi)); | 462 | iio_device_unregister(spi_get_drvdata(spi)); |
469 | iio_device_free(spi_get_drvdata(spi)); | ||
470 | 463 | ||
471 | return 0; | 464 | return 0; |
472 | } | 465 | } |