aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/magnetometer/hid-sensor-magn-3d.c
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-08-02 06:08:00 -0400
committerJonathan Cameron <jic23@kernel.org>2013-08-03 13:43:14 -0400
commit907c0a0ae0e0f3b26d1d2bb6f05f116f0a9decc1 (patch)
tree1fb0968e2075632e1fc6dfa3203e4fc9ddafbf82 /drivers/iio/magnetometer/hid-sensor-magn-3d.c
parent555d5a9f17ef71849cae57fd2efda60b50d325ce (diff)
iio: magnetometer: hid-sensor-magn-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/magnetometer/hid-sensor-magn-3d.c')
-rw-r--r--drivers/iio/magnetometer/hid-sensor-magn-3d.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index e71127aeda09..5a6162d1a2c0 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -283,11 +283,11 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
283 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; 283 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
284 struct iio_chan_spec *channels; 284 struct iio_chan_spec *channels;
285 285
286 indio_dev = iio_device_alloc(sizeof(struct magn_3d_state)); 286 indio_dev = devm_iio_device_alloc(&pdev->dev,
287 if (indio_dev == NULL) { 287 sizeof(struct magn_3d_state));
288 ret = -ENOMEM; 288 if (indio_dev == NULL)
289 goto error_ret; 289 return -ENOMEM;
290 } 290
291 platform_set_drvdata(pdev, indio_dev); 291 platform_set_drvdata(pdev, indio_dev);
292 292
293 magn_state = iio_priv(indio_dev); 293 magn_state = iio_priv(indio_dev);
@@ -299,15 +299,14 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
299 &magn_state->common_attributes); 299 &magn_state->common_attributes);
300 if (ret) { 300 if (ret) {
301 dev_err(&pdev->dev, "failed to setup common attributes\n"); 301 dev_err(&pdev->dev, "failed to setup common attributes\n");
302 goto error_free_dev; 302 return ret;
303 } 303 }
304 304
305 channels = kmemdup(magn_3d_channels, sizeof(magn_3d_channels), 305 channels = kmemdup(magn_3d_channels, sizeof(magn_3d_channels),
306 GFP_KERNEL); 306 GFP_KERNEL);
307 if (!channels) { 307 if (!channels) {
308 ret = -ENOMEM;
309 dev_err(&pdev->dev, "failed to duplicate channels\n"); 308 dev_err(&pdev->dev, "failed to duplicate channels\n");
310 goto error_free_dev; 309 return -ENOMEM;
311 } 310 }
312 311
313 ret = magn_3d_parse_report(pdev, hsdev, channels, 312 ret = magn_3d_parse_report(pdev, hsdev, channels,
@@ -364,9 +363,6 @@ error_unreg_buffer_funcs:
364 iio_triggered_buffer_cleanup(indio_dev); 363 iio_triggered_buffer_cleanup(indio_dev);
365error_free_dev_mem: 364error_free_dev_mem:
366 kfree(indio_dev->channels); 365 kfree(indio_dev->channels);
367error_free_dev:
368 iio_device_free(indio_dev);
369error_ret:
370 return ret; 366 return ret;
371} 367}
372 368
@@ -381,7 +377,6 @@ static int hid_magn_3d_remove(struct platform_device *pdev)
381 hid_sensor_remove_trigger(indio_dev); 377 hid_sensor_remove_trigger(indio_dev);
382 iio_triggered_buffer_cleanup(indio_dev); 378 iio_triggered_buffer_cleanup(indio_dev);
383 kfree(indio_dev->channels); 379 kfree(indio_dev->channels);
384 iio_device_free(indio_dev);
385 380
386 return 0; 381 return 0;
387} 382}