Commit 8483aa5e0f0a4bdf8bdc54d83397715c7adb762d

Authored by Sachin Kamat
Committed by Jonathan Cameron
1 parent e59576d4be

iio: adc: lp8788_adc: Use devm_* APIs

devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Milo Kim <milo.kim@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

Showing 1 changed file with 2 additions and 5 deletions Side-by-side Diff

drivers/iio/adc/lp8788_adc.c
... ... @@ -194,7 +194,7 @@
194 194 struct lp8788_adc *adc;
195 195 int ret;
196 196  
197   - indio_dev = iio_device_alloc(sizeof(*adc));
  197 + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc));
198 198 if (!indio_dev)
199 199 return -ENOMEM;
200 200  
... ... @@ -205,7 +205,7 @@
205 205 indio_dev->dev.of_node = pdev->dev.of_node;
206 206 ret = lp8788_iio_map_register(indio_dev, lp->pdata, adc);
207 207 if (ret)
208   - goto err_iio_map;
  208 + return ret;
209 209  
210 210 mutex_init(&adc->lock);
211 211  
... ... @@ -226,8 +226,6 @@
226 226  
227 227 err_iio_device:
228 228 iio_map_array_unregister(indio_dev);
229   -err_iio_map:
230   - iio_device_free(indio_dev);
231 229 return ret;
232 230 }
233 231  
... ... @@ -237,7 +235,6 @@
237 235  
238 236 iio_device_unregister(indio_dev);
239 237 iio_map_array_unregister(indio_dev);
240   - iio_device_free(indio_dev);
241 238  
242 239 return 0;
243 240 }