Commit b909459f authored by Sachin Kamat's avatar Sachin Kamat Committed by Jonathan Cameron

staging: iio: ade7854: Use devm_iio_device_alloc

devm_iio_device_alloc makes code simpler.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Cc: Barry Song <21cnbao@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent b67637a3
...@@ -208,7 +208,7 @@ static int ade7854_i2c_probe(struct i2c_client *client, ...@@ -208,7 +208,7 @@ static int ade7854_i2c_probe(struct i2c_client *client,
struct ade7854_state *st; struct ade7854_state *st;
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
indio_dev = iio_device_alloc(sizeof(*st)); indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
if (indio_dev == NULL) if (indio_dev == NULL)
return -ENOMEM; return -ENOMEM;
st = iio_priv(indio_dev); st = iio_priv(indio_dev);
...@@ -225,8 +225,6 @@ static int ade7854_i2c_probe(struct i2c_client *client, ...@@ -225,8 +225,6 @@ static int ade7854_i2c_probe(struct i2c_client *client,
st->irq = client->irq; st->irq = client->irq;
ret = ade7854_probe(indio_dev, &client->dev); ret = ade7854_probe(indio_dev, &client->dev);
if (ret)
iio_device_free(indio_dev);
return ret; return ret;
} }
......
...@@ -278,7 +278,7 @@ static int ade7854_spi_probe(struct spi_device *spi) ...@@ -278,7 +278,7 @@ static int ade7854_spi_probe(struct spi_device *spi)
struct ade7854_state *st; struct ade7854_state *st;
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
indio_dev = iio_device_alloc(sizeof(*st)); indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (indio_dev == NULL) if (indio_dev == NULL)
return -ENOMEM; return -ENOMEM;
st = iio_priv(indio_dev); st = iio_priv(indio_dev);
...@@ -296,8 +296,6 @@ static int ade7854_spi_probe(struct spi_device *spi) ...@@ -296,8 +296,6 @@ static int ade7854_spi_probe(struct spi_device *spi)
ret = ade7854_probe(indio_dev, &spi->dev); ret = ade7854_probe(indio_dev, &spi->dev);
if (ret)
iio_device_free(indio_dev);
return 0; return 0;
} }
......
...@@ -550,7 +550,7 @@ int ade7854_probe(struct iio_dev *indio_dev, struct device *dev) ...@@ -550,7 +550,7 @@ int ade7854_probe(struct iio_dev *indio_dev, struct device *dev)
ret = iio_device_register(indio_dev); ret = iio_device_register(indio_dev);
if (ret) if (ret)
goto error_free_dev; return ret;
/* Get the device into a sane initial state */ /* Get the device into a sane initial state */
ret = ade7854_initial_setup(indio_dev); ret = ade7854_initial_setup(indio_dev);
...@@ -561,9 +561,6 @@ int ade7854_probe(struct iio_dev *indio_dev, struct device *dev) ...@@ -561,9 +561,6 @@ int ade7854_probe(struct iio_dev *indio_dev, struct device *dev)
error_unreg_dev: error_unreg_dev:
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
error_free_dev:
iio_device_free(indio_dev);
return ret; return ret;
} }
EXPORT_SYMBOL(ade7854_probe); EXPORT_SYMBOL(ade7854_probe);
...@@ -571,7 +568,6 @@ EXPORT_SYMBOL(ade7854_probe); ...@@ -571,7 +568,6 @@ EXPORT_SYMBOL(ade7854_probe);
int ade7854_remove(struct iio_dev *indio_dev) int ade7854_remove(struct iio_dev *indio_dev)
{ {
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
iio_device_free(indio_dev);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment