|
@@ -25,11 +25,9 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
|
|
|
struct st_sensor_data *gdata;
|
|
|
int err;
|
|
|
|
|
|
- indio_dev = iio_device_alloc(sizeof(*gdata));
|
|
|
- if (indio_dev == NULL) {
|
|
|
- err = -ENOMEM;
|
|
|
- goto iio_device_alloc_error;
|
|
|
- }
|
|
|
+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*gdata));
|
|
|
+ if (!indio_dev)
|
|
|
+ return -ENOMEM;
|
|
|
|
|
|
gdata = iio_priv(indio_dev);
|
|
|
gdata->dev = &client->dev;
|
|
@@ -39,14 +37,9 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
|
|
|
err = st_gyro_common_probe(indio_dev,
|
|
|
(struct st_sensors_platform_data *)&gyro_pdata);
|
|
|
if (err < 0)
|
|
|
- goto st_gyro_common_probe_error;
|
|
|
+ return err;
|
|
|
|
|
|
return 0;
|
|
|
-
|
|
|
-st_gyro_common_probe_error:
|
|
|
- iio_device_free(indio_dev);
|
|
|
-iio_device_alloc_error:
|
|
|
- return err;
|
|
|
}
|
|
|
|
|
|
static int st_gyro_i2c_remove(struct i2c_client *client)
|