diff options
-rw-r--r-- | drivers/iio/magnetometer/hid-sensor-magn-3d.c | 19 |
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); |
365 | error_free_dev_mem: | 364 | error_free_dev_mem: |
366 | kfree(indio_dev->channels); | 365 | kfree(indio_dev->channels); |
367 | error_free_dev: | ||
368 | iio_device_free(indio_dev); | ||
369 | error_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 | } |