Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: iio: ad5930: Use devm_iio_device_alloc

devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Sachin Kamat and committed by
Jonathan Cameron
85bf6ee3 664716ae

+4 -12
+4 -12
drivers/staging/iio/frequency/ad5930.c
··· 94 94 struct iio_dev *idev; 95 95 int ret = 0; 96 96 97 - idev = iio_device_alloc(sizeof(*st)); 98 - if (idev == NULL) { 99 - ret = -ENOMEM; 100 - goto error_ret; 101 - } 97 + idev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); 98 + if (!idev) 99 + return -ENOMEM; 102 100 spi_set_drvdata(spi, idev); 103 101 st = iio_priv(idev); 104 102 ··· 108 110 109 111 ret = iio_device_register(idev); 110 112 if (ret) 111 - goto error_free_dev; 113 + return ret; 112 114 spi->max_speed_hz = 2000000; 113 115 spi->mode = SPI_MODE_3; 114 116 spi->bits_per_word = 16; 115 117 spi_setup(spi); 116 118 117 119 return 0; 118 - 119 - error_free_dev: 120 - iio_device_free(idev); 121 - error_ret: 122 - return ret; 123 120 } 124 121 125 122 static int ad5930_remove(struct spi_device *spi) 126 123 { 127 124 iio_device_unregister(spi_get_drvdata(spi)); 128 - iio_device_free(spi_get_drvdata(spi)); 129 125 130 126 return 0; 131 127 }