diff options
Diffstat (limited to 'drivers/iio/gyro/st_gyro_i2c.c')
-rw-r--r-- | drivers/iio/gyro/st_gyro_i2c.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c index 8a310500573d..16b8b8d70bf1 100644 --- a/drivers/iio/gyro/st_gyro_i2c.c +++ b/drivers/iio/gyro/st_gyro_i2c.c | |||
@@ -25,27 +25,21 @@ static int st_gyro_i2c_probe(struct i2c_client *client, | |||
25 | struct st_sensor_data *gdata; | 25 | struct st_sensor_data *gdata; |
26 | int err; | 26 | int err; |
27 | 27 | ||
28 | indio_dev = iio_device_alloc(sizeof(*gdata)); | 28 | indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*gdata)); |
29 | if (indio_dev == NULL) { | 29 | if (!indio_dev) |
30 | err = -ENOMEM; | 30 | return -ENOMEM; |
31 | goto iio_device_alloc_error; | ||
32 | } | ||
33 | 31 | ||
34 | gdata = iio_priv(indio_dev); | 32 | gdata = iio_priv(indio_dev); |
35 | gdata->dev = &client->dev; | 33 | gdata->dev = &client->dev; |
36 | 34 | ||
37 | st_sensors_i2c_configure(indio_dev, client, gdata); | 35 | st_sensors_i2c_configure(indio_dev, client, gdata); |
38 | 36 | ||
39 | err = st_gyro_common_probe(indio_dev); | 37 | err = st_gyro_common_probe(indio_dev, |
38 | (struct st_sensors_platform_data *)&gyro_pdata); | ||
40 | if (err < 0) | 39 | if (err < 0) |
41 | goto st_gyro_common_probe_error; | 40 | return err; |
42 | 41 | ||
43 | return 0; | 42 | return 0; |
44 | |||
45 | st_gyro_common_probe_error: | ||
46 | iio_device_free(indio_dev); | ||
47 | iio_device_alloc_error: | ||
48 | return err; | ||
49 | } | 43 | } |
50 | 44 | ||
51 | static int st_gyro_i2c_remove(struct i2c_client *client) | 45 | static int st_gyro_i2c_remove(struct i2c_client *client) |