From: Sachin Kamat Date: Sat, 24 Aug 2013 18:48:00 +0000 (+0100) Subject: staging: iio: sca3000: Use devm_iio_device_alloc X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=0189d93fdf82cd546d5e54c6f4f7c4622c90aa3c;p=linux-beck.git staging: iio: sca3000: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 32950ad94857..48a25ba290f5 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -1135,11 +1135,9 @@ static int sca3000_probe(struct spi_device *spi) struct sca3000_state *st; struct iio_dev *indio_dev; - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); spi_set_drvdata(spi, indio_dev); @@ -1162,7 +1160,7 @@ static int sca3000_probe(struct spi_device *spi) sca3000_configure_ring(indio_dev); ret = iio_device_register(indio_dev); if (ret < 0) - goto error_free_dev; + return ret; ret = iio_buffer_register(indio_dev, sca3000_channels, @@ -1198,10 +1196,6 @@ error_unregister_ring: iio_buffer_unregister(indio_dev); error_unregister_dev: iio_device_unregister(indio_dev); -error_free_dev: - iio_device_free(indio_dev); - -error_ret: return ret; } @@ -1235,7 +1229,6 @@ static int sca3000_remove(struct spi_device *spi) iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); sca3000_unconfigure_ring(indio_dev); - iio_device_free(indio_dev); return 0; }