提交 6b7e0a9c 编写于 作者: S Sachin Kamat 提交者: Jonathan Cameron

iio: accel: st_accel: Use devm_iio_device_alloc

Using devm_iio_device_alloc makes code simpler.
Signed-off-by: NSachin Kamat <sachin.kamat@linaro.org>
Cc: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 4ee30933
...@@ -517,7 +517,6 @@ void st_accel_common_remove(struct iio_dev *indio_dev) ...@@ -517,7 +517,6 @@ void st_accel_common_remove(struct iio_dev *indio_dev)
st_sensors_deallocate_trigger(indio_dev); st_sensors_deallocate_trigger(indio_dev);
st_accel_deallocate_ring(indio_dev); st_accel_deallocate_ring(indio_dev);
} }
iio_device_free(indio_dev);
} }
EXPORT_SYMBOL(st_accel_common_remove); EXPORT_SYMBOL(st_accel_common_remove);
......
...@@ -25,11 +25,9 @@ static int st_accel_i2c_probe(struct i2c_client *client, ...@@ -25,11 +25,9 @@ static int st_accel_i2c_probe(struct i2c_client *client,
struct st_sensor_data *adata; struct st_sensor_data *adata;
int err; int err;
indio_dev = iio_device_alloc(sizeof(*adata)); indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*adata));
if (indio_dev == NULL) { if (!indio_dev)
err = -ENOMEM; return -ENOMEM;
goto iio_device_alloc_error;
}
adata = iio_priv(indio_dev); adata = iio_priv(indio_dev);
adata->dev = &client->dev; adata->dev = &client->dev;
...@@ -38,14 +36,9 @@ static int st_accel_i2c_probe(struct i2c_client *client, ...@@ -38,14 +36,9 @@ static int st_accel_i2c_probe(struct i2c_client *client,
err = st_accel_common_probe(indio_dev, client->dev.platform_data); err = st_accel_common_probe(indio_dev, client->dev.platform_data);
if (err < 0) if (err < 0)
goto st_accel_common_probe_error; return err;
return 0; return 0;
st_accel_common_probe_error:
iio_device_free(indio_dev);
iio_device_alloc_error:
return err;
} }
static int st_accel_i2c_remove(struct i2c_client *client) static int st_accel_i2c_remove(struct i2c_client *client)
......
...@@ -24,11 +24,9 @@ static int st_accel_spi_probe(struct spi_device *spi) ...@@ -24,11 +24,9 @@ static int st_accel_spi_probe(struct spi_device *spi)
struct st_sensor_data *adata; struct st_sensor_data *adata;
int err; int err;
indio_dev = iio_device_alloc(sizeof(*adata)); indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adata));
if (indio_dev == NULL) { if (!indio_dev)
err = -ENOMEM; return -ENOMEM;
goto iio_device_alloc_error;
}
adata = iio_priv(indio_dev); adata = iio_priv(indio_dev);
adata->dev = &spi->dev; adata->dev = &spi->dev;
...@@ -37,14 +35,9 @@ static int st_accel_spi_probe(struct spi_device *spi) ...@@ -37,14 +35,9 @@ static int st_accel_spi_probe(struct spi_device *spi)
err = st_accel_common_probe(indio_dev, spi->dev.platform_data); err = st_accel_common_probe(indio_dev, spi->dev.platform_data);
if (err < 0) if (err < 0)
goto st_accel_common_probe_error; return err;
return 0; return 0;
st_accel_common_probe_error:
iio_device_free(indio_dev);
iio_device_alloc_error:
return err;
} }
static int st_accel_spi_remove(struct spi_device *spi) static int st_accel_spi_remove(struct spi_device *spi)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册