aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-07-30 04:44:00 -0400
committerJonathan Cameron <jic23@kernel.org>2013-08-03 13:55:24 -0400
commit47aff92ce081d8c9013f52e021cdfee5eebdbd2b (patch)
tree8a96997a7f79f06f01874a749568031cd6d6624c /drivers/iio
parent452204ae531f236696d69966d0ff2f5ca0ef02f7 (diff)
iio: light: hid-sensor-als: Use devm_iio_device_alloc
Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Cc: Srinivas Pandruvada <srinivas.pandruvada@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/light/hid-sensor-als.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 9adfef07d8c2..84cf0043c99d 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -249,11 +249,9 @@ static int hid_als_probe(struct platform_device *pdev)
249 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; 249 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
250 struct iio_chan_spec *channels; 250 struct iio_chan_spec *channels;
251 251
252 indio_dev = iio_device_alloc(sizeof(struct als_state)); 252 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct als_state));
253 if (indio_dev == NULL) { 253 if (!indio_dev)
254 ret = -ENOMEM; 254 return -ENOMEM;
255 goto error_ret;
256 }
257 platform_set_drvdata(pdev, indio_dev); 255 platform_set_drvdata(pdev, indio_dev);
258 256
259 als_state = iio_priv(indio_dev); 257 als_state = iio_priv(indio_dev);
@@ -264,14 +262,13 @@ static int hid_als_probe(struct platform_device *pdev)
264 &als_state->common_attributes); 262 &als_state->common_attributes);
265 if (ret) { 263 if (ret) {
266 dev_err(&pdev->dev, "failed to setup common attributes\n"); 264 dev_err(&pdev->dev, "failed to setup common attributes\n");
267 goto error_free_dev; 265 return ret;
268 } 266 }
269 267
270 channels = kmemdup(als_channels, sizeof(als_channels), GFP_KERNEL); 268 channels = kmemdup(als_channels, sizeof(als_channels), GFP_KERNEL);
271 if (!channels) { 269 if (!channels) {
272 ret = -ENOMEM;
273 dev_err(&pdev->dev, "failed to duplicate channels\n"); 270 dev_err(&pdev->dev, "failed to duplicate channels\n");
274 goto error_free_dev; 271 return -ENOMEM;
275 } 272 }
276 273
277 ret = als_parse_report(pdev, hsdev, channels, 274 ret = als_parse_report(pdev, hsdev, channels,
@@ -329,9 +326,6 @@ error_unreg_buffer_funcs:
329 iio_triggered_buffer_cleanup(indio_dev); 326 iio_triggered_buffer_cleanup(indio_dev);
330error_free_dev_mem: 327error_free_dev_mem:
331 kfree(indio_dev->channels); 328 kfree(indio_dev->channels);
332error_free_dev:
333 iio_device_free(indio_dev);
334error_ret:
335 return ret; 329 return ret;
336} 330}
337 331
@@ -346,7 +340,6 @@ static int hid_als_remove(struct platform_device *pdev)
346 hid_sensor_remove_trigger(indio_dev); 340 hid_sensor_remove_trigger(indio_dev);
347 iio_triggered_buffer_cleanup(indio_dev); 341 iio_triggered_buffer_cleanup(indio_dev);
348 kfree(indio_dev->channels); 342 kfree(indio_dev->channels);
349 iio_device_free(indio_dev);
350 343
351 return 0; 344 return 0;
352} 345}