diff options
-rw-r--r-- | drivers/iio/gyro/hid-sensor-gyro-3d.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index 9cc8aa1102d7..d9d7befdd77b 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c | |||
@@ -282,11 +282,9 @@ static int hid_gyro_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 gyro_3d_state)); | 285 | indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*gyro_state)); |
286 | if (indio_dev == NULL) { | 286 | if (!indio_dev) |
287 | ret = -ENOMEM; | 287 | return -ENOMEM; |
288 | goto error_ret; | ||
289 | } | ||
290 | platform_set_drvdata(pdev, indio_dev); | 288 | platform_set_drvdata(pdev, indio_dev); |
291 | 289 | ||
292 | gyro_state = iio_priv(indio_dev); | 290 | gyro_state = iio_priv(indio_dev); |
@@ -298,15 +296,14 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) | |||
298 | &gyro_state->common_attributes); | 296 | &gyro_state->common_attributes); |
299 | if (ret) { | 297 | if (ret) { |
300 | dev_err(&pdev->dev, "failed to setup common attributes\n"); | 298 | dev_err(&pdev->dev, "failed to setup common attributes\n"); |
301 | goto error_free_dev; | 299 | return ret; |
302 | } | 300 | } |
303 | 301 | ||
304 | channels = kmemdup(gyro_3d_channels, sizeof(gyro_3d_channels), | 302 | channels = kmemdup(gyro_3d_channels, sizeof(gyro_3d_channels), |
305 | GFP_KERNEL); | 303 | GFP_KERNEL); |
306 | if (!channels) { | 304 | if (!channels) { |
307 | ret = -ENOMEM; | ||
308 | dev_err(&pdev->dev, "failed to duplicate channels\n"); | 305 | dev_err(&pdev->dev, "failed to duplicate channels\n"); |
309 | goto error_free_dev; | 306 | return -ENOMEM; |
310 | } | 307 | } |
311 | 308 | ||
312 | ret = gyro_3d_parse_report(pdev, hsdev, channels, | 309 | ret = gyro_3d_parse_report(pdev, hsdev, channels, |
@@ -363,9 +360,6 @@ error_unreg_buffer_funcs: | |||
363 | iio_triggered_buffer_cleanup(indio_dev); | 360 | iio_triggered_buffer_cleanup(indio_dev); |
364 | error_free_dev_mem: | 361 | error_free_dev_mem: |
365 | kfree(indio_dev->channels); | 362 | kfree(indio_dev->channels); |
366 | error_free_dev: | ||
367 | iio_device_free(indio_dev); | ||
368 | error_ret: | ||
369 | return ret; | 363 | return ret; |
370 | } | 364 | } |
371 | 365 | ||
@@ -380,7 +374,6 @@ static int hid_gyro_3d_remove(struct platform_device *pdev) | |||
380 | hid_sensor_remove_trigger(indio_dev); | 374 | hid_sensor_remove_trigger(indio_dev); |
381 | iio_triggered_buffer_cleanup(indio_dev); | 375 | iio_triggered_buffer_cleanup(indio_dev); |
382 | kfree(indio_dev->channels); | 376 | kfree(indio_dev->channels); |
383 | iio_device_free(indio_dev); | ||
384 | 377 | ||
385 | return 0; | 378 | return 0; |
386 | } | 379 | } |