diff options
Diffstat (limited to 'drivers/iio/gyro/adxrs450.c')
-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 | } |