aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/pressure/st_pressure_spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iio/pressure/st_pressure_spi.c')
-rw-r--r--drivers/iio/pressure/st_pressure_spi.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c
index 17a14907940a..399a29b6017b 100644
--- a/drivers/iio/pressure/st_pressure_spi.c
+++ b/drivers/iio/pressure/st_pressure_spi.c
@@ -24,27 +24,20 @@ static int st_press_spi_probe(struct spi_device *spi)
24 struct st_sensor_data *pdata; 24 struct st_sensor_data *pdata;
25 int err; 25 int err;
26 26
27 indio_dev = iio_device_alloc(sizeof(*pdata)); 27 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*pdata));
28 if (indio_dev == NULL) { 28 if (indio_dev == NULL)
29 err = -ENOMEM; 29 return -ENOMEM;
30 goto iio_device_alloc_error;
31 }
32 30
33 pdata = iio_priv(indio_dev); 31 pdata = iio_priv(indio_dev);
34 pdata->dev = &spi->dev; 32 pdata->dev = &spi->dev;
35 33
36 st_sensors_spi_configure(indio_dev, spi, pdata); 34 st_sensors_spi_configure(indio_dev, spi, pdata);
37 35
38 err = st_press_common_probe(indio_dev); 36 err = st_press_common_probe(indio_dev, spi->dev.platform_data);
39 if (err < 0) 37 if (err < 0)
40 goto st_press_common_probe_error; 38 return err;
41 39
42 return 0; 40 return 0;
43
44st_press_common_probe_error:
45 iio_device_free(indio_dev);
46iio_device_alloc_error:
47 return err;
48} 41}
49 42
50static int st_press_spi_remove(struct spi_device *spi) 43static int st_press_spi_remove(struct spi_device *spi)