diff options
Diffstat (limited to 'drivers/iio/gyro')
-rw-r--r-- | drivers/iio/gyro/adis16260.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c index b4cf800717ad..06541162fc02 100644 --- a/drivers/iio/gyro/adis16260.c +++ b/drivers/iio/gyro/adis16260.c | |||
@@ -343,11 +343,9 @@ static int adis16260_probe(struct spi_device *spi) | |||
343 | int ret; | 343 | int ret; |
344 | 344 | ||
345 | /* setup the industrialio driver allocated elements */ | 345 | /* setup the industrialio driver allocated elements */ |
346 | indio_dev = iio_device_alloc(sizeof(*adis)); | 346 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis)); |
347 | if (indio_dev == NULL) { | 347 | if (!indio_dev) |
348 | ret = -ENOMEM; | 348 | return -ENOMEM; |
349 | goto error_ret; | ||
350 | } | ||
351 | adis = iio_priv(indio_dev); | 349 | adis = iio_priv(indio_dev); |
352 | /* this is only used for removal purposes */ | 350 | /* this is only used for removal purposes */ |
353 | spi_set_drvdata(spi, indio_dev); | 351 | spi_set_drvdata(spi, indio_dev); |
@@ -361,11 +359,11 @@ static int adis16260_probe(struct spi_device *spi) | |||
361 | 359 | ||
362 | ret = adis_init(adis, indio_dev, spi, &adis16260_data); | 360 | ret = adis_init(adis, indio_dev, spi, &adis16260_data); |
363 | if (ret) | 361 | if (ret) |
364 | goto error_free_dev; | 362 | return ret; |
365 | 363 | ||
366 | ret = adis_setup_buffer_and_trigger(adis, indio_dev, NULL); | 364 | ret = adis_setup_buffer_and_trigger(adis, indio_dev, NULL); |
367 | if (ret) | 365 | if (ret) |
368 | goto error_free_dev; | 366 | return ret; |
369 | 367 | ||
370 | /* Get the device into a sane initial state */ | 368 | /* Get the device into a sane initial state */ |
371 | ret = adis_initial_startup(adis); | 369 | ret = adis_initial_startup(adis); |
@@ -379,9 +377,6 @@ static int adis16260_probe(struct spi_device *spi) | |||
379 | 377 | ||
380 | error_cleanup_buffer_trigger: | 378 | error_cleanup_buffer_trigger: |
381 | adis_cleanup_buffer_and_trigger(adis, indio_dev); | 379 | adis_cleanup_buffer_and_trigger(adis, indio_dev); |
382 | error_free_dev: | ||
383 | iio_device_free(indio_dev); | ||
384 | error_ret: | ||
385 | return ret; | 380 | return ret; |
386 | } | 381 | } |
387 | 382 | ||
@@ -393,7 +388,6 @@ static int adis16260_remove(struct spi_device *spi) | |||
393 | iio_device_unregister(indio_dev); | 388 | iio_device_unregister(indio_dev); |
394 | adis16260_stop_device(indio_dev); | 389 | adis16260_stop_device(indio_dev); |
395 | adis_cleanup_buffer_and_trigger(adis, indio_dev); | 390 | adis_cleanup_buffer_and_trigger(adis, indio_dev); |
396 | iio_device_free(indio_dev); | ||
397 | 391 | ||
398 | return 0; | 392 | return 0; |
399 | } | 393 | } |