diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-08-13 02:34:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-08-17 10:50:54 -0400 |
commit | 42aceff5a26713a50239504ff30ce78beac66b6a (patch) | |
tree | dc087584718189ec5c909a0f6f931fdba3fd1471 /drivers/iio | |
parent | da419463d8819b66c2795b0fdbf462a1766d9ace (diff) |
iio: gyro: adis16130: Use devm_iio_device_alloc
Using devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/gyro/adis16130.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/drivers/iio/gyro/adis16130.c b/drivers/iio/gyro/adis16130.c index 129acdf801a4..ac66fc184042 100644 --- a/drivers/iio/gyro/adis16130.c +++ b/drivers/iio/gyro/adis16130.c | |||
@@ -148,16 +148,13 @@ static const struct iio_info adis16130_info = { | |||
148 | 148 | ||
149 | static int adis16130_probe(struct spi_device *spi) | 149 | static int adis16130_probe(struct spi_device *spi) |
150 | { | 150 | { |
151 | int ret; | ||
152 | struct adis16130_state *st; | 151 | struct adis16130_state *st; |
153 | struct iio_dev *indio_dev; | 152 | struct iio_dev *indio_dev; |
154 | 153 | ||
155 | /* setup the industrialio driver allocated elements */ | 154 | /* setup the industrialio driver allocated elements */ |
156 | indio_dev = iio_device_alloc(sizeof(*st)); | 155 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
157 | if (indio_dev == NULL) { | 156 | if (!indio_dev) |
158 | ret = -ENOMEM; | 157 | return -ENOMEM; |
159 | goto error_ret; | ||
160 | } | ||
161 | st = iio_priv(indio_dev); | 158 | st = iio_priv(indio_dev); |
162 | /* this is only used for removal purposes */ | 159 | /* this is only used for removal purposes */ |
163 | spi_set_drvdata(spi, indio_dev); | 160 | spi_set_drvdata(spi, indio_dev); |
@@ -170,24 +167,12 @@ static int adis16130_probe(struct spi_device *spi) | |||
170 | indio_dev->info = &adis16130_info; | 167 | indio_dev->info = &adis16130_info; |
171 | indio_dev->modes = INDIO_DIRECT_MODE; | 168 | indio_dev->modes = INDIO_DIRECT_MODE; |
172 | 169 | ||
173 | ret = iio_device_register(indio_dev); | 170 | return iio_device_register(indio_dev); |
174 | if (ret) | ||
175 | goto error_free_dev; | ||
176 | |||
177 | return 0; | ||
178 | |||
179 | error_free_dev: | ||
180 | iio_device_free(indio_dev); | ||
181 | |||
182 | error_ret: | ||
183 | return ret; | ||
184 | } | 171 | } |
185 | 172 | ||
186 | static int adis16130_remove(struct spi_device *spi) | 173 | static int adis16130_remove(struct spi_device *spi) |
187 | { | 174 | { |
188 | iio_device_unregister(spi_get_drvdata(spi)); | 175 | iio_device_unregister(spi_get_drvdata(spi)); |
189 | iio_device_free(spi_get_drvdata(spi)); | ||
190 | |||
191 | return 0; | 176 | return 0; |
192 | } | 177 | } |
193 | 178 | ||