iio: hid-sensors: bind IIO channels alloc to device object
Subsystems (2)
PATCH 1/1 iio: hid-sensors: bind IIO channels alloc to device object
Some HID drivers use devm_kmemdup() already to clone the template IIO channels information and update it.
However, there are still some drivers that kmemdup() and kfree() the channels.
This change converts them to use devm_kmemdup() and bind the life-time of this allocated object to the parent device object (in these drivers).
--- drivers/iio/accel/hid-sensor-accel-3d.c | 10 ++++------ drivers/iio/gyro/hid-sensor-gyro-3d.c | 11 ++++------- drivers/iio/light/hid-sensor-als.c | 11 ++++------- drivers/iio/light/hid-sensor-prox.c | 11 ++++------- drivers/iio/orientation/hid-sensor-incl-3d.c | 11 ++++------- drivers/iio/pressure/hid-sensor-press.c | 11 ++++------- 6 files changed, 24 insertions(+), 41 deletions(-)
drivers/iio/accel/hid-sensor-accel-3d.c +4 -6
@@ -367,7 +367,8 @@ static int hid_accel_3d_probe(struct platform_device *pdev)dev_err (&pdev->dev,"failed to setup common attributes\n" );return ret; } - indio_dev->channels =kmemdup (channel_spec, channel_size,GFP_KERNEL ); + indio_dev->channels =devm_kmemdup (&pdev->dev, channel_spec, + channel_size,GFP_KERNEL );if (!indio_dev->channels) {dev_err (&pdev->dev,"failed to duplicate channels\n" );
@@ -378,7 +379,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) hsdev->usage, accel_state);if (ret) {dev_err (&pdev->dev,"failed to setup attributes\n" ); - goto error_free_dev_mem; +return ret; } indio_dev->info = &accel_3d_info;
@@ -391,7 +392,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) &accel_state->common_attributes);if (ret <0 ) {dev_err (&pdev->dev,"trigger setup failed\n" ); - goto error_free_dev_mem; +return ret; } ret =iio_device_register (indio_dev);
@@ -416,8 +417,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev)iio_device_unregister (indio_dev); error_remove_trigger:hid_sensor_remove_trigger (indio_dev, &accel_state->common_attributes); -error_free_dev_mem: -kfree (indio_dev->channels);return ret; }
@@ -431,7 +430,6 @@ static int hid_accel_3d_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev, hsdev->usage);iio_device_unregister (indio_dev);hid_sensor_remove_trigger (indio_dev, &accel_state->common_attributes); -kfree (indio_dev->channels);return 0 ; }
drivers/iio/gyro/hid-sensor-gyro-3d.c +4 -7
@@ -303,8 +303,8 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)return ret; } - indio_dev->channels =kmemdup (gyro_3d_channels, -sizeof (gyro_3d_channels),GFP_KERNEL ); + indio_dev->channels =devm_kmemdup (&pdev->dev, gyro_3d_channels, +sizeof (gyro_3d_channels),GFP_KERNEL );if (!indio_dev->channels) {dev_err (&pdev->dev,"failed to duplicate channels\n" );return -ENOMEM ;
@@ -315,7 +315,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) HID_USAGE_SENSOR_GYRO_3D, gyro_state);if (ret) {dev_err (&pdev->dev,"failed to setup attributes\n" ); - goto error_free_dev_mem; +return ret; } indio_dev->num_channels =ARRAY_SIZE (gyro_3d_channels);
@@ -329,7 +329,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) &gyro_state->common_attributes);if (ret <0 ) {dev_err (&pdev->dev,"trigger setup failed\n" ); - goto error_free_dev_mem; +return ret; } ret =iio_device_register (indio_dev);
@@ -354,8 +354,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)iio_device_unregister (indio_dev); error_remove_trigger:hid_sensor_remove_trigger (indio_dev, &gyro_state->common_attributes); -error_free_dev_mem: -kfree (indio_dev->channels);return ret; }
@@ -369,7 +367,6 @@ static int hid_gyro_3d_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev,HID_USAGE_SENSOR_GYRO_3D );iio_device_unregister (indio_dev);hid_sensor_remove_trigger (indio_dev, &gyro_state->common_attributes); -kfree (indio_dev->channels);return 0 ; }
drivers/iio/light/hid-sensor-als.c +4 -7
@@ -294,8 +294,8 @@ static int hid_als_probe(struct platform_device *pdev)return ret; } - indio_dev->channels =kmemdup (als_channels, -sizeof (als_channels),GFP_KERNEL ); + indio_dev->channels =devm_kmemdup (&pdev->dev, als_channels, +sizeof (als_channels),GFP_KERNEL );if (!indio_dev->channels) {dev_err (&pdev->dev,"failed to duplicate channels\n" );return -ENOMEM ;
@@ -306,7 +306,7 @@ static int hid_als_probe(struct platform_device *pdev) HID_USAGE_SENSOR_ALS, als_state);if (ret) {dev_err (&pdev->dev,"failed to setup attributes\n" ); - goto error_free_dev_mem; +return ret; } indio_dev->num_channels =
@@ -321,7 +321,7 @@ static int hid_als_probe(struct platform_device *pdev) &als_state->common_attributes);if (ret <0 ) {dev_err (&pdev->dev,"trigger setup failed\n" ); - goto error_free_dev_mem; +return ret; } ret =iio_device_register (indio_dev);
@@ -346,8 +346,6 @@ static int hid_als_probe(struct platform_device *pdev)iio_device_unregister (indio_dev); error_remove_trigger:hid_sensor_remove_trigger (indio_dev, &als_state->common_attributes); -error_free_dev_mem: -kfree (indio_dev->channels);return ret; }
@@ -361,7 +359,6 @@ static int hid_als_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev,HID_USAGE_SENSOR_ALS );iio_device_unregister (indio_dev);hid_sensor_remove_trigger (indio_dev, &als_state->common_attributes); -kfree (indio_dev->channels);return 0 ; }
drivers/iio/light/hid-sensor-prox.c +4 -7
@@ -253,8 +253,8 @@ static int hid_prox_probe(struct platform_device *pdev)return ret; } - indio_dev->channels =kmemdup (prox_channels,sizeof (prox_channels), -GFP_KERNEL ); + indio_dev->channels =devm_kmemdup (&pdev->dev, prox_channels, +sizeof (prox_channels),GFP_KERNEL );if (!indio_dev->channels) {dev_err (&pdev->dev,"failed to duplicate channels\n" );return -ENOMEM ;
@@ -265,7 +265,7 @@ static int hid_prox_probe(struct platform_device *pdev) HID_USAGE_SENSOR_PROX, prox_state);if (ret) {dev_err (&pdev->dev,"failed to setup attributes\n" ); - goto error_free_dev_mem; +return ret; } indio_dev->num_channels =ARRAY_SIZE (prox_channels);
@@ -279,7 +279,7 @@ static int hid_prox_probe(struct platform_device *pdev) &prox_state->common_attributes);if (ret) {dev_err (&pdev->dev,"trigger setup failed\n" ); - goto error_free_dev_mem; +return ret; } ret =iio_device_register (indio_dev);
@@ -304,8 +304,6 @@ static int hid_prox_probe(struct platform_device *pdev)iio_device_unregister (indio_dev); error_remove_trigger:hid_sensor_remove_trigger (indio_dev, &prox_state->common_attributes); -error_free_dev_mem: -kfree (indio_dev->channels);return ret; }
@@ -319,7 +317,6 @@ static int hid_prox_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev,HID_USAGE_SENSOR_PROX );iio_device_unregister (indio_dev);hid_sensor_remove_trigger (indio_dev, &prox_state->common_attributes); -kfree (indio_dev->channels);return 0 ; }
drivers/iio/orientation/hid-sensor-incl-3d.c +4 -7
@@ -326,8 +326,8 @@ static int hid_incl_3d_probe(struct platform_device *pdev)return ret; } - indio_dev->channels =kmemdup (incl_3d_channels, -sizeof (incl_3d_channels),GFP_KERNEL ); + indio_dev->channels =devm_kmemdup (&pdev->dev, incl_3d_channels, +sizeof (incl_3d_channels),GFP_KERNEL );if (!indio_dev->channels) {dev_err (&pdev->dev,"failed to duplicate channels\n" );return -ENOMEM ;
@@ -339,7 +339,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev) incl_state);if (ret) {dev_err (&pdev->dev,"failed to setup attributes\n" ); - goto error_free_dev_mem; +return ret; } indio_dev->num_channels =ARRAY_SIZE (incl_3d_channels);
@@ -353,7 +353,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev) &incl_state->common_attributes);if (ret) {dev_err (&pdev->dev,"trigger setup failed\n" ); - goto error_free_dev_mem; +return ret; } ret =iio_device_register (indio_dev);
@@ -379,8 +379,6 @@ static int hid_incl_3d_probe(struct platform_device *pdev)iio_device_unregister (indio_dev); error_remove_trigger:hid_sensor_remove_trigger (indio_dev, &incl_state->common_attributes); -error_free_dev_mem: -kfree (indio_dev->channels);return ret; }
@@ -394,7 +392,6 @@ static int hid_incl_3d_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev,HID_USAGE_SENSOR_INCLINOMETER_3D );iio_device_unregister (indio_dev);hid_sensor_remove_trigger (indio_dev, &incl_state->common_attributes); -kfree (indio_dev->channels);return 0 ; }
drivers/iio/pressure/hid-sensor-press.c +4 -7
@@ -259,8 +259,8 @@ static int hid_press_probe(struct platform_device *pdev)return ret; } - indio_dev->channels =kmemdup (press_channels,sizeof (press_channels), -GFP_KERNEL ); + indio_dev->channels =devm_kmemdup (&pdev->dev, press_channels, +sizeof (press_channels),GFP_KERNEL );if (!indio_dev->channels) {dev_err (&pdev->dev,"failed to duplicate channels\n" );return -ENOMEM ;
@@ -271,7 +271,7 @@ static int hid_press_probe(struct platform_device *pdev) HID_USAGE_SENSOR_PRESSURE, press_state);if (ret) {dev_err (&pdev->dev,"failed to setup attributes\n" ); - goto error_free_dev_mem; +return ret; } indio_dev->num_channels =
@@ -286,7 +286,7 @@ static int hid_press_probe(struct platform_device *pdev) &press_state->common_attributes);if (ret) {dev_err (&pdev->dev,"trigger setup failed\n" ); - goto error_free_dev_mem; +return ret; } ret =iio_device_register (indio_dev);
@@ -311,8 +311,6 @@ static int hid_press_probe(struct platform_device *pdev)iio_device_unregister (indio_dev); error_remove_trigger:hid_sensor_remove_trigger (indio_dev, &press_state->common_attributes); -error_free_dev_mem: -kfree (indio_dev->channels);return ret; }
@@ -326,7 +324,6 @@ static int hid_press_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev,HID_USAGE_SENSOR_PRESSURE );iio_device_unregister (indio_dev);hid_sensor_remove_trigger (indio_dev, &press_state->common_attributes); -kfree (indio_dev->channels);return 0 ; }
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerQuoted 9 lines · On Wed, 30 Jun 2021 15:30:29 +0300 Alexandru Ardelean <[email protected]>…
Some HID drivers use
devm_kmemdup()already to clone the template IIO channels information and update it.
However, there are still some drivers thatkmemdup()andkfree()the channels.This change converts them to use
devm_kmemdup()and bind the life-time of this allocated object to the parent device object (in these drivers).Signed-off-by Alexandru Ardelean <[email protected]>
All look good to me, plus it's the same thing already done in hid-sensors-magn-3d so should be fine :)
Srinivas, if you have time to sanity check that would be great. No huge rush given we are in the merge window.
Thanks,
Jonathan
Quoted 308 lines
--- drivers/iio/accel/hid-sensor-accel-3d.c | 10 ++++------ drivers/iio/gyro/hid-sensor-gyro-3d.c | 11 ++++------- drivers/iio/light/hid-sensor-als.c | 11 ++++------- drivers/iio/light/hid-sensor-prox.c | 11 ++++------- drivers/iio/orientation/hid-sensor-incl-3d.c | 11 ++++------- drivers/iio/pressure/hid-sensor-press.c | 11 ++++------- 6 files changed, 24 insertions(+), 41 deletions(-)drivers/iio/accel/hid-sensor-accel-3d.c +4
-6@@ -367,7 +367,8 @@ static int hid_accel_3d_probe(struct platform_device *pdev)dev_err (&pdev->dev,"failed to setup common attributes\n" );return ret; } - indio_dev->channels =kmemdup (channel_spec, channel_size,GFP_KERNEL ); + indio_dev->channels =devm_kmemdup (&pdev->dev, channel_spec, + channel_size,GFP_KERNEL );if (!indio_dev->channels) {dev_err (&pdev->dev,"failed to duplicate channels\n" );@@ -378,7 +379,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) hsdev->usage, accel_state);if (ret) {dev_err (&pdev->dev,"failed to setup attributes\n" ); - goto error_free_dev_mem; +return ret; } indio_dev->info = &accel_3d_info;@@ -391,7 +392,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) &accel_state->common_attributes);if (ret <0 ) {dev_err (&pdev->dev,"trigger setup failed\n" ); - goto error_free_dev_mem; +return ret; } ret =iio_device_register (indio_dev);@@ -416,8 +417,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev)iio_device_unregister (indio_dev); error_remove_trigger:hid_sensor_remove_trigger (indio_dev, &accel_state->common_attributes); -error_free_dev_mem: -kfree (indio_dev->channels);return ret; }@@ -431,7 +430,6 @@ static int hid_accel_3d_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev, hsdev->usage);iio_device_unregister (indio_dev);hid_sensor_remove_trigger (indio_dev, &accel_state->common_attributes); -kfree (indio_dev->channels);return 0 ; }drivers/iio/gyro/hid-sensor-gyro-3d.c +4
-7@@ -303,8 +303,8 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)return ret; } - indio_dev->channels =kmemdup (gyro_3d_channels, -sizeof (gyro_3d_channels),GFP_KERNEL ); + indio_dev->channels =devm_kmemdup (&pdev->dev, gyro_3d_channels, +sizeof (gyro_3d_channels),GFP_KERNEL );if (!indio_dev->channels) {dev_err (&pdev->dev,"failed to duplicate channels\n" );return -ENOMEM ;@@ -315,7 +315,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) HID_USAGE_SENSOR_GYRO_3D, gyro_state);if (ret) {dev_err (&pdev->dev,"failed to setup attributes\n" ); - goto error_free_dev_mem; +return ret; } indio_dev->num_channels =ARRAY_SIZE (gyro_3d_channels);@@ -329,7 +329,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) &gyro_state->common_attributes);if (ret <0 ) {dev_err (&pdev->dev,"trigger setup failed\n" ); - goto error_free_dev_mem; +return ret; } ret =iio_device_register (indio_dev);@@ -354,8 +354,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)iio_device_unregister (indio_dev); error_remove_trigger:hid_sensor_remove_trigger (indio_dev, &gyro_state->common_attributes); -error_free_dev_mem: -kfree (indio_dev->channels);return ret; }@@ -369,7 +367,6 @@ static int hid_gyro_3d_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev,HID_USAGE_SENSOR_GYRO_3D );iio_device_unregister (indio_dev);hid_sensor_remove_trigger (indio_dev, &gyro_state->common_attributes); -kfree (indio_dev->channels);return 0 ; }drivers/iio/light/hid-sensor-als.c +4
-7@@ -294,8 +294,8 @@ static int hid_als_probe(struct platform_device *pdev)return ret; } - indio_dev->channels =kmemdup (als_channels, -sizeof (als_channels),GFP_KERNEL ); + indio_dev->channels =devm_kmemdup (&pdev->dev, als_channels, +sizeof (als_channels),GFP_KERNEL );if (!indio_dev->channels) {dev_err (&pdev->dev,"failed to duplicate channels\n" );return -ENOMEM ;@@ -306,7 +306,7 @@ static int hid_als_probe(struct platform_device *pdev) HID_USAGE_SENSOR_ALS, als_state);if (ret) {dev_err (&pdev->dev,"failed to setup attributes\n" ); - goto error_free_dev_mem; +return ret; } indio_dev->num_channels =@@ -321,7 +321,7 @@ static int hid_als_probe(struct platform_device *pdev) &als_state->common_attributes);if (ret <0 ) {dev_err (&pdev->dev,"trigger setup failed\n" ); - goto error_free_dev_mem; +return ret; } ret =iio_device_register (indio_dev);@@ -346,8 +346,6 @@ static int hid_als_probe(struct platform_device *pdev)iio_device_unregister (indio_dev); error_remove_trigger:hid_sensor_remove_trigger (indio_dev, &als_state->common_attributes); -error_free_dev_mem: -kfree (indio_dev->channels);return ret; }@@ -361,7 +359,6 @@ static int hid_als_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev,HID_USAGE_SENSOR_ALS );iio_device_unregister (indio_dev);hid_sensor_remove_trigger (indio_dev, &als_state->common_attributes); -kfree (indio_dev->channels);return 0 ; }drivers/iio/light/hid-sensor-prox.c +4
-7@@ -253,8 +253,8 @@ static int hid_prox_probe(struct platform_device *pdev)return ret; } - indio_dev->channels =kmemdup (prox_channels,sizeof (prox_channels), -GFP_KERNEL ); + indio_dev->channels =devm_kmemdup (&pdev->dev, prox_channels, +sizeof (prox_channels),GFP_KERNEL );if (!indio_dev->channels) {dev_err (&pdev->dev,"failed to duplicate channels\n" );return -ENOMEM ;@@ -265,7 +265,7 @@ static int hid_prox_probe(struct platform_device *pdev) HID_USAGE_SENSOR_PROX, prox_state);if (ret) {dev_err (&pdev->dev,"failed to setup attributes\n" ); - goto error_free_dev_mem; +return ret; } indio_dev->num_channels =ARRAY_SIZE (prox_channels);@@ -279,7 +279,7 @@ static int hid_prox_probe(struct platform_device *pdev) &prox_state->common_attributes);if (ret) {dev_err (&pdev->dev,"trigger setup failed\n" ); - goto error_free_dev_mem; +return ret; } ret =iio_device_register (indio_dev);@@ -304,8 +304,6 @@ static int hid_prox_probe(struct platform_device *pdev)iio_device_unregister (indio_dev); error_remove_trigger:hid_sensor_remove_trigger (indio_dev, &prox_state->common_attributes); -error_free_dev_mem: -kfree (indio_dev->channels);return ret; }@@ -319,7 +317,6 @@ static int hid_prox_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev,HID_USAGE_SENSOR_PROX );iio_device_unregister (indio_dev);hid_sensor_remove_trigger (indio_dev, &prox_state->common_attributes); -kfree (indio_dev->channels);return 0 ; }drivers/iio/orientation/hid-sensor-incl-3d.c +4
-7@@ -326,8 +326,8 @@ static int hid_incl_3d_probe(struct platform_device *pdev)return ret; } - indio_dev->channels =kmemdup (incl_3d_channels, -sizeof (incl_3d_channels),GFP_KERNEL ); + indio_dev->channels =devm_kmemdup (&pdev->dev, incl_3d_channels, +sizeof (incl_3d_channels),GFP_KERNEL );if (!indio_dev->channels) {dev_err (&pdev->dev,"failed to duplicate channels\n" );return -ENOMEM ;@@ -339,7 +339,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev) incl_state);if (ret) {dev_err (&pdev->dev,"failed to setup attributes\n" ); - goto error_free_dev_mem; +return ret; } indio_dev->num_channels =ARRAY_SIZE (incl_3d_channels);@@ -353,7 +353,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev) &incl_state->common_attributes);if (ret) {dev_err (&pdev->dev,"trigger setup failed\n" ); - goto error_free_dev_mem; +return ret; } ret =iio_device_register (indio_dev);@@ -379,8 +379,6 @@ static int hid_incl_3d_probe(struct platform_device *pdev)iio_device_unregister (indio_dev); error_remove_trigger:hid_sensor_remove_trigger (indio_dev, &incl_state->common_attributes); -error_free_dev_mem: -kfree (indio_dev->channels);return ret; }@@ -394,7 +392,6 @@ static int hid_incl_3d_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev,HID_USAGE_SENSOR_INCLINOMETER_3D );iio_device_unregister (indio_dev);hid_sensor_remove_trigger (indio_dev, &incl_state->common_attributes); -kfree (indio_dev->channels);return 0 ; }drivers/iio/pressure/hid-sensor-press.c +4
-7@@ -259,8 +259,8 @@ static int hid_press_probe(struct platform_device *pdev)return ret; } - indio_dev->channels =kmemdup (press_channels,sizeof (press_channels), -GFP_KERNEL ); + indio_dev->channels =devm_kmemdup (&pdev->dev, press_channels, +sizeof (press_channels),GFP_KERNEL );if (!indio_dev->channels) {dev_err (&pdev->dev,"failed to duplicate channels\n" );return -ENOMEM ;@@ -271,7 +271,7 @@ static int hid_press_probe(struct platform_device *pdev) HID_USAGE_SENSOR_PRESSURE, press_state);if (ret) {dev_err (&pdev->dev,"failed to setup attributes\n" ); - goto error_free_dev_mem; +return ret; } indio_dev->num_channels =@@ -286,7 +286,7 @@ static int hid_press_probe(struct platform_device *pdev) &press_state->common_attributes);if (ret) {dev_err (&pdev->dev,"trigger setup failed\n" ); - goto error_free_dev_mem; +return ret; } ret =iio_device_register (indio_dev);@@ -311,8 +311,6 @@ static int hid_press_probe(struct platform_device *pdev)iio_device_unregister (indio_dev); error_remove_trigger:hid_sensor_remove_trigger (indio_dev, &press_state->common_attributes); -error_free_dev_mem: -kfree (indio_dev->channels);return ret; }@@ -326,7 +324,6 @@ static int hid_press_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev,HID_USAGE_SENSOR_PRESSURE );iio_device_unregister (indio_dev);hid_sensor_remove_trigger (indio_dev, &press_state->common_attributes); -kfree (indio_dev->channels);return 0 ; }
Quoted 10 lines · Alexandru Ardelean
Some HID drivers use
devm_kmemdup()already to clone the template IIO channels information and update it.
However, there are still some drivers thatkmemdup()andkfree()the channels.This change converts them to use
devm_kmemdup()and bind the life- time of
this allocated object to the parent device object (in these drivers).Signed-off-by Alexandru Ardelean <[email protected]>
Quoted 383 lines
---
drivers/iio/accel/hid-sensor-accel-3d.c | 10 ++++------ drivers/iio/gyro/hid-sensor-gyro-3d.c | 11 ++++------- drivers/iio/light/hid-sensor-als.c | 11 ++++------- drivers/iio/light/hid-sensor-prox.c | 11 ++++-------drivers/iio/orientation/hid-sensor-incl-3d.c| 11 ++++------- drivers/iio/pressure/hid-sensor-press.c | 11 ++++-------6 files changed, 24 insertions(+), 41 deletions(-)drivers/iio/accel/hid-sensor-accel-3d.c +0
-0@@ -367,7 +367,8 @@ static int hid_accel_3d_probe(struct platform_device *pdev)dev_err(&pdev->dev, "failed to setup common attributes\n");
return ret;
}
- indio_dev->channels =kmemdup(channel_spec, channel_size, GFP_KERNEL);
+ indio_dev->channels = devm_kmemdup(&pdev->dev,channel_spec, +channel_size,GFP_KERNEL);
if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");drivers/iio/accel/hid-sensor-accel-3d.c +1
-1@@ -378,7 +379,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) hsdev->usage, accel_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; }
indio_dev->info =&accel_3d_info;drivers/iio/accel/hid-sensor-accel-3d.c +0
-0@@ -391,7 +392,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev)&accel_state-
Quoted 1 line
common_attributes);if (ret < 0) {
dev_err(&pdev->dev, "trigger setup failed\n"); - gotoerror_free_dev_mem;
+ return ret;
}
ret =iio_device_register(indio_dev);drivers/iio/accel/hid-sensor-accel-3d.c +0
-0@@ -416,8 +417,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev) iio_device_unregister(indio_dev);error_remove_trigger:
hid_sensor_remove_trigger(indio_dev, &accel_state-Quoted 1 line
common_attributes);-error_free_dev_mem:
- kfree(indio_dev->channels);
return ret;
}drivers/iio/accel/hid-sensor-accel-3d.c +0
-0@@ -431,7 +430,6 @@ static int hid_accel_3d_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev, hsdev->usage); iio_device_unregister(indio_dev);hid_sensor_remove_trigger(indio_dev, &accel_state-
Quoted 1 line
common_attributes);- kfree(indio_dev->channels);
return 0;
}drivers/iio/gyro/hid-sensor-gyro-3d.c +0
-0@@ -303,8 +303,8 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) return ret; }
- indio_dev->channels = kmemdup(gyro_3d_channels,
-sizeof(gyro_3d_channels),GFP_KERNEL);
+ indio_dev->channels = devm_kmemdup(&pdev->dev,gyro_3d_channels,
+sizeof(gyro_3d_channels),GFP_KERNEL);
if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return-ENOMEM;drivers/iio/gyro/hid-sensor-gyro-3d.c +1
-1@@ -315,7 +315,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) HID_USAGE_SENSOR_GYRO_3D, gyro_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; }
indio_dev->num_channels =ARRAY_SIZE(gyro_3d_channels);drivers/iio/gyro/hid-sensor-gyro-3d.c +0
-0@@ -329,7 +329,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)&gyro_state-
Quoted 1 line
common_attributes);if (ret < 0) {
dev_err(&pdev->dev, "trigger setup failed\n"); - gotoerror_free_dev_mem;
+ return ret;
}
ret =iio_device_register(indio_dev);drivers/iio/gyro/hid-sensor-gyro-3d.c +0
-0@@ -354,8 +354,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) iio_device_unregister(indio_dev);error_remove_trigger:
hid_sensor_remove_trigger(indio_dev, &gyro_state-Quoted 1 line
common_attributes);-error_free_dev_mem:
- kfree(indio_dev->channels);
return ret;
}drivers/iio/gyro/hid-sensor-gyro-3d.c +0
-0@@ -369,7 +367,6 @@ static int hid_gyro_3d_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D); iio_device_unregister(indio_dev);hid_sensor_remove_trigger(indio_dev, &gyro_state-
Quoted 1 line
common_attributes);- kfree(indio_dev->channels);
return 0;
}drivers/iio/light/hid-sensor-als.c +0
-0@@ -294,8 +294,8 @@ static int hid_als_probe(struct platform_device *pdev) return ret; }
- indio_dev->channels = kmemdup(als_channels,
-sizeof(als_channels),GFP_KERNEL);
+ indio_dev->channels = devm_kmemdup(&pdev->dev,als_channels, +sizeof(als_channels),GFP_KERNEL);
if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return-ENOMEM;drivers/iio/light/hid-sensor-als.c +1
-1@@ -306,7 +306,7 @@ static int hid_als_probe(struct platform_device *pdev) HID_USAGE_SENSOR_ALS, als_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; }
indio_dev->num_channels =drivers/iio/light/hid-sensor-als.c +1
-1@@ -321,7 +321,7 @@ static int hid_als_probe(struct platform_device *pdev) &als_state->common_attributes); if (ret < 0) { dev_err(&pdev->dev, "trigger setup failed\n"); - goto error_free_dev_mem; + return ret; }
ret =iio_device_register(indio_dev);drivers/iio/light/hid-sensor-als.c +0
-0@@ -346,8 +346,6 @@ static int hid_als_probe(struct platform_device *pdev) iio_device_unregister(indio_dev);error_remove_trigger:
hid_sensor_remove_trigger(indio_dev, &als_state-Quoted 1 line
common_attributes);-error_free_dev_mem:
- kfree(indio_dev->channels);
return ret;
}drivers/iio/light/hid-sensor-als.c +0
-0@@ -361,7 +359,6 @@ static int hid_als_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS); iio_device_unregister(indio_dev);hid_sensor_remove_trigger(indio_dev, &als_state-
Quoted 1 line
common_attributes);- kfree(indio_dev->channels);
return 0;
}drivers/iio/light/hid-sensor-prox.c +0
-0@@ -253,8 +253,8 @@ static int hid_prox_probe(struct platform_device *pdev) return ret; }
- indio_dev->channels = kmemdup(prox_channels,sizeof(prox_channels),
-GFP_KERNEL);
+ indio_dev->channels = devm_kmemdup(&pdev->dev,prox_channels, +sizeof(prox_channels),GFP_KERNEL);
if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return-ENOMEM;drivers/iio/light/hid-sensor-prox.c +1
-1@@ -265,7 +265,7 @@ static int hid_prox_probe(struct platform_device *pdev) HID_USAGE_SENSOR_PROX, prox_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; }
indio_dev->num_channels =ARRAY_SIZE(prox_channels);drivers/iio/light/hid-sensor-prox.c +1
-1@@ -279,7 +279,7 @@ static int hid_prox_probe(struct platform_device *pdev) &prox_state->common_attributes); if (ret) { dev_err(&pdev->dev, "trigger setup failed\n"); - goto error_free_dev_mem; + return ret; }
ret =iio_device_register(indio_dev);drivers/iio/light/hid-sensor-prox.c +0
-0@@ -304,8 +304,6 @@ static int hid_prox_probe(struct platform_device *pdev) iio_device_unregister(indio_dev);error_remove_trigger:
hid_sensor_remove_trigger(indio_dev, &prox_state-Quoted 1 line
common_attributes);-error_free_dev_mem:
- kfree(indio_dev->channels);
return ret;
}drivers/iio/light/hid-sensor-prox.c +0
-0@@ -319,7 +317,6 @@ static int hid_prox_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_PROX); iio_device_unregister(indio_dev);hid_sensor_remove_trigger(indio_dev, &prox_state-
Quoted 1 line
common_attributes);- kfree(indio_dev->channels);
return 0;
}drivers/iio/orientation/hid-sensor-incl-3d.c +0
-0@@ -326,8 +326,8 @@ static int hid_incl_3d_probe(struct platform_device *pdev) return ret; }
- indio_dev->channels = kmemdup(incl_3d_channels,
-sizeof(incl_3d_channels),GFP_KERNEL);
+ indio_dev->channels = devm_kmemdup(&pdev->dev,incl_3d_channels,
+sizeof(incl_3d_channels),GFP_KERNEL);
if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return-ENOMEM;drivers/iio/orientation/hid-sensor-incl-3d.c +1
-1@@ -339,7 +339,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev) incl_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; }
indio_dev->num_channels =ARRAY_SIZE(incl_3d_channels);drivers/iio/orientation/hid-sensor-incl-3d.c +0
-0@@ -353,7 +353,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev)&incl_state-
Quoted 1 line
common_attributes);if (ret) {
dev_err(&pdev->dev, "trigger setup failed\n"); - gotoerror_free_dev_mem;
+ return ret;
}
ret =iio_device_register(indio_dev);drivers/iio/orientation/hid-sensor-incl-3d.c +0
-0@@ -379,8 +379,6 @@ static int hid_incl_3d_probe(struct platform_device *pdev) iio_device_unregister(indio_dev);error_remove_trigger:
hid_sensor_remove_trigger(indio_dev, &incl_state-Quoted 1 line
common_attributes);-error_free_dev_mem:
- kfree(indio_dev->channels);
return ret;
}drivers/iio/orientation/hid-sensor-incl-3d.c +0
-0@@ -394,7 +392,6 @@ static int hid_incl_3d_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev,HID_USAGE_SENSOR_INCLINOMETER_3D ); iio_device_unregister(indio_dev);hid_sensor_remove_trigger(indio_dev, &incl_state-
Quoted 1 line
common_attributes);- kfree(indio_dev->channels);
return 0;
}drivers/iio/pressure/hid-sensor-press.c +0
-0@@ -259,8 +259,8 @@ static int hid_press_probe(struct platform_device *pdev) return ret; }
- indio_dev->channels = kmemdup(press_channels,sizeof(press_channels),
-GFP_KERNEL);
+ indio_dev->channels = devm_kmemdup(&pdev->dev,press_channels,
+sizeof(press_channels),GFP_KERNEL);
if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return-ENOMEM;drivers/iio/pressure/hid-sensor-press.c +1
-1@@ -271,7 +271,7 @@ static int hid_press_probe(struct platform_device *pdev) HID_USAGE_SENSOR_PRESSURE, press_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; }
indio_dev->num_channels =drivers/iio/pressure/hid-sensor-press.c +1
-1@@ -286,7 +286,7 @@ static int hid_press_probe(struct platform_device *pdev) &press_state->common_attributes); if (ret) { dev_err(&pdev->dev, "trigger setup failed\n"); - goto error_free_dev_mem; + return ret; }
ret =iio_device_register(indio_dev);drivers/iio/pressure/hid-sensor-press.c +0
-0@@ -311,8 +311,6 @@ static int hid_press_probe(struct platform_device *pdev) iio_device_unregister(indio_dev);error_remove_trigger:
hid_sensor_remove_trigger(indio_dev, &press_state-Quoted 1 line
common_attributes);-error_free_dev_mem:
- kfree(indio_dev->channels);
return ret;
}drivers/iio/pressure/hid-sensor-press.c +0
-0@@ -326,7 +324,6 @@ static int hid_press_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_PRESSURE); iio_device_unregister(indio_dev);hid_sensor_remove_trigger(indio_dev, &press_state-
Quoted 1 line
common_attributes);- kfree(indio_dev->channels);
return 0;
}
Quoted 6 lines · On Tue, 13 Jul 2021 09:29:55 -0700 Srinivas Pandruvada…
Quoted 5 lines · Alexandru Ardelean
Some HID drivers use
devm_kmemdup()already to clone the template IIO channels information and update it.
However, there are still some drivers thatkmemdup()andkfree()the channels.
Quoted 6 lines
Quoted 5 lines
This change converts them to use
devm_kmemdup()and bind the life- time of
this allocated object to the parent device object (in these drivers).Signed-off-by Alexandru Ardelean <[email protected]>
Applied to the togreg branch of iio.git which will go through the usual initial exposure as testing before I push it out for linux-next to pick up.
Thanks,
Jonathan
Quoted 386 lines
Quoted 384 lines
---
drivers/iio/accel/hid-sensor-accel-3d.c | 10 ++++------ drivers/iio/gyro/hid-sensor-gyro-3d.c | 11 ++++------- drivers/iio/light/hid-sensor-als.c | 11 ++++------- drivers/iio/light/hid-sensor-prox.c | 11 ++++-------drivers/iio/orientation/hid-sensor-incl-3d.c| 11 ++++------- drivers/iio/pressure/hid-sensor-press.c | 11 ++++-------6 files changed, 24 insertions(+), 41 deletions(-)drivers/iio/accel/hid-sensor-accel-3d.c +0
-0@@ -367,7 +367,8 @@ static int hid_accel_3d_probe(struct platform_device *pdev)dev_err(&pdev->dev, "failed to setup common attributes\n");
return ret;
}
- indio_dev->channels =kmemdup(channel_spec, channel_size, GFP_KERNEL);
+ indio_dev->channels = devm_kmemdup(&pdev->dev,channel_spec, +channel_size,GFP_KERNEL);
if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");drivers/iio/accel/hid-sensor-accel-3d.c +1
-1@@ -378,7 +379,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) hsdev->usage, accel_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; }
indio_dev->info =&accel_3d_info;drivers/iio/accel/hid-sensor-accel-3d.c +0
-0@@ -391,7 +392,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev)&accel_state-
Quoted 1 line
common_attributes);if (ret < 0) {
dev_err(&pdev->dev, "trigger setup failed\n"); - gotoerror_free_dev_mem;
+ return ret;
}
ret =iio_device_register(indio_dev);drivers/iio/accel/hid-sensor-accel-3d.c +0
-0@@ -416,8 +417,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev) iio_device_unregister(indio_dev);error_remove_trigger:
hid_sensor_remove_trigger(indio_dev, &accel_state-Quoted 1 line
common_attributes);-error_free_dev_mem:
- kfree(indio_dev->channels);
return ret;
}drivers/iio/accel/hid-sensor-accel-3d.c +0
-0@@ -431,7 +430,6 @@ static int hid_accel_3d_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev, hsdev->usage); iio_device_unregister(indio_dev);hid_sensor_remove_trigger(indio_dev, &accel_state-
Quoted 1 line
common_attributes);- kfree(indio_dev->channels);
return 0;
}drivers/iio/gyro/hid-sensor-gyro-3d.c +0
-0@@ -303,8 +303,8 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) return ret; }
- indio_dev->channels = kmemdup(gyro_3d_channels,
-sizeof(gyro_3d_channels),GFP_KERNEL);
+ indio_dev->channels = devm_kmemdup(&pdev->dev,gyro_3d_channels,
+sizeof(gyro_3d_channels),GFP_KERNEL);
if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return-ENOMEM;drivers/iio/gyro/hid-sensor-gyro-3d.c +1
-1@@ -315,7 +315,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) HID_USAGE_SENSOR_GYRO_3D, gyro_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; }
indio_dev->num_channels =ARRAY_SIZE(gyro_3d_channels);drivers/iio/gyro/hid-sensor-gyro-3d.c +0
-0@@ -329,7 +329,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)&gyro_state-
Quoted 1 line
common_attributes);if (ret < 0) {
dev_err(&pdev->dev, "trigger setup failed\n"); - gotoerror_free_dev_mem;
+ return ret;
}
ret =iio_device_register(indio_dev);drivers/iio/gyro/hid-sensor-gyro-3d.c +0
-0@@ -354,8 +354,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) iio_device_unregister(indio_dev);error_remove_trigger:
hid_sensor_remove_trigger(indio_dev, &gyro_state-Quoted 1 line
common_attributes);-error_free_dev_mem:
- kfree(indio_dev->channels);
return ret;
}drivers/iio/gyro/hid-sensor-gyro-3d.c +0
-0@@ -369,7 +367,6 @@ static int hid_gyro_3d_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D); iio_device_unregister(indio_dev);hid_sensor_remove_trigger(indio_dev, &gyro_state-
Quoted 1 line
common_attributes);- kfree(indio_dev->channels);
return 0;
}drivers/iio/light/hid-sensor-als.c +0
-0@@ -294,8 +294,8 @@ static int hid_als_probe(struct platform_device *pdev) return ret; }
- indio_dev->channels = kmemdup(als_channels,
-sizeof(als_channels),GFP_KERNEL);
+ indio_dev->channels = devm_kmemdup(&pdev->dev,als_channels, +sizeof(als_channels),GFP_KERNEL);
if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return-ENOMEM;drivers/iio/light/hid-sensor-als.c +1
-1@@ -306,7 +306,7 @@ static int hid_als_probe(struct platform_device *pdev) HID_USAGE_SENSOR_ALS, als_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; }
indio_dev->num_channels =drivers/iio/light/hid-sensor-als.c +1
-1@@ -321,7 +321,7 @@ static int hid_als_probe(struct platform_device *pdev) &als_state->common_attributes); if (ret < 0) { dev_err(&pdev->dev, "trigger setup failed\n"); - goto error_free_dev_mem; + return ret; }
ret =iio_device_register(indio_dev);drivers/iio/light/hid-sensor-als.c +0
-0@@ -346,8 +346,6 @@ static int hid_als_probe(struct platform_device *pdev) iio_device_unregister(indio_dev);error_remove_trigger:
hid_sensor_remove_trigger(indio_dev, &als_state-Quoted 1 line
common_attributes);-error_free_dev_mem:
- kfree(indio_dev->channels);
return ret;
}drivers/iio/light/hid-sensor-als.c +0
-0@@ -361,7 +359,6 @@ static int hid_als_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS); iio_device_unregister(indio_dev);hid_sensor_remove_trigger(indio_dev, &als_state-
Quoted 1 line
common_attributes);- kfree(indio_dev->channels);
return 0;
}drivers/iio/light/hid-sensor-prox.c +0
-0@@ -253,8 +253,8 @@ static int hid_prox_probe(struct platform_device *pdev) return ret; }
- indio_dev->channels = kmemdup(prox_channels,sizeof(prox_channels),
-GFP_KERNEL);
+ indio_dev->channels = devm_kmemdup(&pdev->dev,prox_channels, +sizeof(prox_channels),GFP_KERNEL);
if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return-ENOMEM;drivers/iio/light/hid-sensor-prox.c +1
-1@@ -265,7 +265,7 @@ static int hid_prox_probe(struct platform_device *pdev) HID_USAGE_SENSOR_PROX, prox_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; }
indio_dev->num_channels =ARRAY_SIZE(prox_channels);drivers/iio/light/hid-sensor-prox.c +1
-1@@ -279,7 +279,7 @@ static int hid_prox_probe(struct platform_device *pdev) &prox_state->common_attributes); if (ret) { dev_err(&pdev->dev, "trigger setup failed\n"); - goto error_free_dev_mem; + return ret; }
ret =iio_device_register(indio_dev);drivers/iio/light/hid-sensor-prox.c +0
-0@@ -304,8 +304,6 @@ static int hid_prox_probe(struct platform_device *pdev) iio_device_unregister(indio_dev);error_remove_trigger:
hid_sensor_remove_trigger(indio_dev, &prox_state-Quoted 1 line
common_attributes);-error_free_dev_mem:
- kfree(indio_dev->channels);
return ret;
}drivers/iio/light/hid-sensor-prox.c +0
-0@@ -319,7 +317,6 @@ static int hid_prox_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_PROX); iio_device_unregister(indio_dev);hid_sensor_remove_trigger(indio_dev, &prox_state-
Quoted 1 line
common_attributes);- kfree(indio_dev->channels);
return 0;
}drivers/iio/orientation/hid-sensor-incl-3d.c +0
-0@@ -326,8 +326,8 @@ static int hid_incl_3d_probe(struct platform_device *pdev) return ret; }
- indio_dev->channels = kmemdup(incl_3d_channels,
-sizeof(incl_3d_channels),GFP_KERNEL);
+ indio_dev->channels = devm_kmemdup(&pdev->dev,incl_3d_channels,
+sizeof(incl_3d_channels),GFP_KERNEL);
if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return-ENOMEM;drivers/iio/orientation/hid-sensor-incl-3d.c +1
-1@@ -339,7 +339,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev) incl_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; }
indio_dev->num_channels =ARRAY_SIZE(incl_3d_channels);drivers/iio/orientation/hid-sensor-incl-3d.c +0
-0@@ -353,7 +353,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev)&incl_state-
Quoted 1 line
common_attributes);if (ret) {
dev_err(&pdev->dev, "trigger setup failed\n"); - gotoerror_free_dev_mem;
+ return ret;
}
ret =iio_device_register(indio_dev);drivers/iio/orientation/hid-sensor-incl-3d.c +0
-0@@ -379,8 +379,6 @@ static int hid_incl_3d_probe(struct platform_device *pdev) iio_device_unregister(indio_dev);error_remove_trigger:
hid_sensor_remove_trigger(indio_dev, &incl_state-Quoted 1 line
common_attributes);-error_free_dev_mem:
- kfree(indio_dev->channels);
return ret;
}drivers/iio/orientation/hid-sensor-incl-3d.c +0
-0@@ -394,7 +392,6 @@ static int hid_incl_3d_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev,HID_USAGE_SENSOR_INCLINOMETER_3D ); iio_device_unregister(indio_dev);hid_sensor_remove_trigger(indio_dev, &incl_state-
Quoted 1 line
common_attributes);- kfree(indio_dev->channels);
return 0;
}drivers/iio/pressure/hid-sensor-press.c +0
-0@@ -259,8 +259,8 @@ static int hid_press_probe(struct platform_device *pdev) return ret; }
- indio_dev->channels = kmemdup(press_channels,sizeof(press_channels),
-GFP_KERNEL);
+ indio_dev->channels = devm_kmemdup(&pdev->dev,press_channels,
+sizeof(press_channels),GFP_KERNEL);
if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return-ENOMEM;drivers/iio/pressure/hid-sensor-press.c +1
-1@@ -271,7 +271,7 @@ static int hid_press_probe(struct platform_device *pdev) HID_USAGE_SENSOR_PRESSURE, press_state); if (ret) { dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; }
indio_dev->num_channels =drivers/iio/pressure/hid-sensor-press.c +1
-1@@ -286,7 +286,7 @@ static int hid_press_probe(struct platform_device *pdev) &press_state->common_attributes); if (ret) { dev_err(&pdev->dev, "trigger setup failed\n"); - goto error_free_dev_mem; + return ret; }
ret =iio_device_register(indio_dev);drivers/iio/pressure/hid-sensor-press.c +0
-0@@ -311,8 +311,6 @@ static int hid_press_probe(struct platform_device *pdev) iio_device_unregister(indio_dev);error_remove_trigger:
hid_sensor_remove_trigger(indio_dev, &press_state-Quoted 1 line
common_attributes);-error_free_dev_mem:
- kfree(indio_dev->channels);
return ret;
}drivers/iio/pressure/hid-sensor-press.c +0
-0@@ -326,7 +324,6 @@ static int hid_press_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_PRESSURE); iio_device_unregister(indio_dev);hid_sensor_remove_trigger(indio_dev, &press_state-
Quoted 1 line
common_attributes);- kfree(indio_dev->channels);
return 0;
}