diff options
Diffstat (limited to 'drivers/iio/accel/st_accel_spi.c')
-rw-r--r-- | drivers/iio/accel/st_accel_spi.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c index 22b35bfea7d2..195639646e34 100644 --- a/drivers/iio/accel/st_accel_spi.c +++ b/drivers/iio/accel/st_accel_spi.c | |||
@@ -24,27 +24,20 @@ static int st_accel_spi_probe(struct spi_device *spi) | |||
24 | struct st_sensor_data *adata; | 24 | struct st_sensor_data *adata; |
25 | int err; | 25 | int err; |
26 | 26 | ||
27 | indio_dev = iio_device_alloc(sizeof(*adata)); | 27 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adata)); |
28 | if (indio_dev == NULL) { | 28 | if (!indio_dev) |
29 | err = -ENOMEM; | 29 | return -ENOMEM; |
30 | goto iio_device_alloc_error; | ||
31 | } | ||
32 | 30 | ||
33 | adata = iio_priv(indio_dev); | 31 | adata = iio_priv(indio_dev); |
34 | adata->dev = &spi->dev; | 32 | adata->dev = &spi->dev; |
35 | 33 | ||
36 | st_sensors_spi_configure(indio_dev, spi, adata); | 34 | st_sensors_spi_configure(indio_dev, spi, adata); |
37 | 35 | ||
38 | err = st_accel_common_probe(indio_dev); | 36 | err = st_accel_common_probe(indio_dev, spi->dev.platform_data); |
39 | if (err < 0) | 37 | if (err < 0) |
40 | goto st_accel_common_probe_error; | 38 | return err; |
41 | 39 | ||
42 | return 0; | 40 | return 0; |
43 | |||
44 | st_accel_common_probe_error: | ||
45 | iio_device_free(indio_dev); | ||
46 | iio_device_alloc_error: | ||
47 | return err; | ||
48 | } | 41 | } |
49 | 42 | ||
50 | static int st_accel_spi_remove(struct spi_device *spi) | 43 | static int st_accel_spi_remove(struct spi_device *spi) |