aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/accel
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-07-23 02:47:00 -0400
committerJonathan Cameron <jic23@kernel.org>2013-08-03 13:41:13 -0400
commit6b545eed655e846c16fdf611e686dca54db76766 (patch)
treedb7d45cd0c96e203c5c0fbea598707f647386d9a /drivers/iio/accel
parent80cab1da704e3f27fb4a631f95369fc31323e91c (diff)
iio: hid-sensor-accel-3d: 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/accel')
-rw-r--r--drivers/iio/accel/hid-sensor-accel-3d.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 275c5d7ea270..68df3416b612 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -282,11 +282,11 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
282 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; 282 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
283 struct iio_chan_spec *channels; 283 struct iio_chan_spec *channels;
284 284
285 indio_dev = iio_device_alloc(sizeof(struct accel_3d_state)); 285 indio_dev = devm_iio_device_alloc(&pdev->dev,
286 if (indio_dev == NULL) { 286 sizeof(struct accel_3d_state));
287 ret = -ENOMEM; 287 if (indio_dev == NULL)
288 goto error_ret; 288 return -ENOMEM;
289 } 289
290 platform_set_drvdata(pdev, indio_dev); 290 platform_set_drvdata(pdev, indio_dev);
291 291
292 accel_state = iio_priv(indio_dev); 292 accel_state = iio_priv(indio_dev);
@@ -298,15 +298,14 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
298 &accel_state->common_attributes); 298 &accel_state->common_attributes);
299 if (ret) { 299 if (ret) {
300 dev_err(&pdev->dev, "failed to setup common attributes\n"); 300 dev_err(&pdev->dev, "failed to setup common attributes\n");
301 goto error_free_dev; 301 return ret;
302 } 302 }
303 303
304 channels = kmemdup(accel_3d_channels, sizeof(accel_3d_channels), 304 channels = kmemdup(accel_3d_channels, sizeof(accel_3d_channels),
305 GFP_KERNEL); 305 GFP_KERNEL);
306 if (!channels) { 306 if (!channels) {
307 ret = -ENOMEM;
308 dev_err(&pdev->dev, "failed to duplicate channels\n"); 307 dev_err(&pdev->dev, "failed to duplicate channels\n");
309 goto error_free_dev; 308 return -ENOMEM;
310 } 309 }
311 310
312 ret = accel_3d_parse_report(pdev, hsdev, channels, 311 ret = accel_3d_parse_report(pdev, hsdev, channels,
@@ -363,9 +362,6 @@ error_unreg_buffer_funcs:
363 iio_triggered_buffer_cleanup(indio_dev); 362 iio_triggered_buffer_cleanup(indio_dev);
364error_free_dev_mem: 363error_free_dev_mem:
365 kfree(indio_dev->channels); 364 kfree(indio_dev->channels);
366error_free_dev:
367 iio_device_free(indio_dev);
368error_ret:
369 return ret; 365 return ret;
370} 366}
371 367
@@ -380,7 +376,6 @@ static int hid_accel_3d_remove(struct platform_device *pdev)
380 hid_sensor_remove_trigger(indio_dev); 376 hid_sensor_remove_trigger(indio_dev);
381 iio_triggered_buffer_cleanup(indio_dev); 377 iio_triggered_buffer_cleanup(indio_dev);
382 kfree(indio_dev->channels); 378 kfree(indio_dev->channels);
383 iio_device_free(indio_dev);
384 379
385 return 0; 380 return 0;
386} 381}