diff options
Diffstat (limited to 'drivers/iio/gyro/adis16080.c')
-rw-r--r-- | drivers/iio/gyro/adis16080.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/drivers/iio/gyro/adis16080.c b/drivers/iio/gyro/adis16080.c index e1bb5f994a54..e9ec022ae225 100644 --- a/drivers/iio/gyro/adis16080.c +++ b/drivers/iio/gyro/adis16080.c | |||
@@ -192,16 +192,13 @@ static const struct adis16080_chip_info adis16080_chip_info[] = { | |||
192 | static int adis16080_probe(struct spi_device *spi) | 192 | static int adis16080_probe(struct spi_device *spi) |
193 | { | 193 | { |
194 | const struct spi_device_id *id = spi_get_device_id(spi); | 194 | const struct spi_device_id *id = spi_get_device_id(spi); |
195 | int ret; | ||
196 | struct adis16080_state *st; | 195 | struct adis16080_state *st; |
197 | struct iio_dev *indio_dev; | 196 | struct iio_dev *indio_dev; |
198 | 197 | ||
199 | /* setup the industrialio driver allocated elements */ | 198 | /* setup the industrialio driver allocated elements */ |
200 | indio_dev = iio_device_alloc(sizeof(*st)); | 199 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
201 | if (indio_dev == NULL) { | 200 | if (!indio_dev) |
202 | ret = -ENOMEM; | 201 | return -ENOMEM; |
203 | goto error_ret; | ||
204 | } | ||
205 | st = iio_priv(indio_dev); | 202 | st = iio_priv(indio_dev); |
206 | /* this is only used for removal purposes */ | 203 | /* this is only used for removal purposes */ |
207 | spi_set_drvdata(spi, indio_dev); | 204 | spi_set_drvdata(spi, indio_dev); |
@@ -217,22 +214,12 @@ static int adis16080_probe(struct spi_device *spi) | |||
217 | indio_dev->info = &adis16080_info; | 214 | indio_dev->info = &adis16080_info; |
218 | indio_dev->modes = INDIO_DIRECT_MODE; | 215 | indio_dev->modes = INDIO_DIRECT_MODE; |
219 | 216 | ||
220 | ret = iio_device_register(indio_dev); | 217 | return iio_device_register(indio_dev); |
221 | if (ret) | ||
222 | goto error_free_dev; | ||
223 | return 0; | ||
224 | |||
225 | error_free_dev: | ||
226 | iio_device_free(indio_dev); | ||
227 | error_ret: | ||
228 | return ret; | ||
229 | } | 218 | } |
230 | 219 | ||
231 | static int adis16080_remove(struct spi_device *spi) | 220 | static int adis16080_remove(struct spi_device *spi) |
232 | { | 221 | { |
233 | iio_device_unregister(spi_get_drvdata(spi)); | 222 | iio_device_unregister(spi_get_drvdata(spi)); |
234 | iio_device_free(spi_get_drvdata(spi)); | ||
235 | |||
236 | return 0; | 223 | return 0; |
237 | } | 224 | } |
238 | 225 | ||