From 50711572c6949f3e5f53f47f7adf2d7c1d5011d9 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 11 Sep 2013 10:55:00 +0100 Subject: [PATCH] staging: iio: ad2s1210: Use devm_iio_device_alloc devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Graff Yang Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s1210.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 2b0c8e50654d..6966d5f76648 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -669,16 +669,14 @@ static int ad2s1210_probe(struct spi_device *spi) if (spi->dev.platform_data == NULL) return -EINVAL; - 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); st->pdata = spi->dev.platform_data; ret = ad2s1210_setup_gpios(st); if (ret < 0) - goto error_free_dev; + return ret; spi_set_drvdata(spi, indio_dev); @@ -709,9 +707,6 @@ static int ad2s1210_probe(struct spi_device *spi) error_free_gpios: ad2s1210_free_gpios(st); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -721,7 +716,6 @@ static int ad2s1210_remove(struct spi_device *spi) iio_device_unregister(indio_dev); ad2s1210_free_gpios(iio_priv(indio_dev)); - iio_device_free(indio_dev); return 0; } -- 2.30.2