iio: gyro: hid-sensor-gyro-3d: align parenthesis for readability
Subsystems (3)
PATCH v4 10/36 iio: gyro: hid-sensor-gyro-3d: align parenthesis for readability
From: Sanjay Chitroda <[email protected]>
Adjust alignment of parentheses to improve readability and maintain consistency with kernel coding style
--- drivers/iio/gyro/hid-sensor-gyro-3d.c | 67 ++++++++++++++------------- 1 file changed, 34 insertions(+), 33 deletions(-)
drivers/iio/gyro/hid-sensor-gyro-3d.c +34 -33
@@ -84,7 +84,7 @@ static const struct iio_chan_spec gyro_3d_channels[] = {/* Adjust channel real bits based on report descriptor */ static void gyro_3d_adjust_channel_bit_mask (struct iio_chan_spec *channels, -int channel,int size) +int channel,int size) { channels[channel].scan_type.sign ='s' ;/* Real storage bits will change based on the report desc. */
@@ -95,9 +95,9 @@ static void gyro_3d_adjust_channel_bit_mask(struct iio_chan_spec *channels,/* Channel read_raw handler */ static int gyro_3d_read_raw (struct iio_dev *indio_dev, -struct iio_chan_spec const *chan, -int *val,int *val2, -long mask) +struct iio_chan_spec const *chan, +int *val,int *val2, +long mask) {struct gyro_3d_state *gyro_state =iio_priv (indio_dev);int report_id =-1 ;
@@ -122,8 +122,7 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev, min < 0); else { *val =0 ; -hid_sensor_power_state (&gyro_state->common_attributes, - false); +hid_sensor_power_state (&gyro_state->common_attributes, false);return -EINVAL ; }hid_sensor_power_state (&gyro_state->common_attributes, false);
@@ -156,10 +155,10 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev,/* Channel write_raw handler */ static int gyro_3d_write_raw (struct iio_dev *indio_dev, -struct iio_chan_spec const *chan, -int val, -int val2, -long mask) +struct iio_chan_spec const *chan, +int val, +int val2, +long mask) {struct gyro_3d_state *gyro_state =iio_priv (indio_dev);int ret =0 ;
@@ -187,8 +186,8 @@ static const struct iio_info gyro_3d_info = {/* Callback handler to send event after all samples are received and captured */ static int gyro_3d_proc_event (struct hid_sensor_hub_device *hsdev, -u32 usage_id, -void *priv) +u32 usage_id, +void *priv) {struct iio_dev *indio_dev =platform_get_drvdata (priv);struct gyro_3d_state *gyro_state =iio_priv (indio_dev);
@@ -209,9 +208,9 @@ static int gyro_3d_proc_event(struct hid_sensor_hub_device *hsdev,/* Capture samples in local storage */ static int gyro_3d_capture_sample (struct hid_sensor_hub_device *hsdev, -u32 usage_id, -size_t raw_len,char *raw_data, -void *priv) +u32 usage_id, +size_t raw_len,char *raw_data, +void *priv) {struct iio_dev *indio_dev =platform_get_drvdata (priv);struct gyro_3d_state *gyro_state =iio_priv (indio_dev);
@@ -251,22 +250,24 @@ static int gyro_3d_parse_report(struct platform_device *pdev,int i;for (i =0 ; i <=CHANNEL_SCAN_INDEX_Z ; ++i) { - ret =sensor_hub_input_get_attribute_info (hsdev, -HID_INPUT_REPORT , - usage_id, -HID_USAGE_SENSOR_ANGL_VELOCITY_X_AXIS + i, - &st->gyro[CHANNEL_SCAN_INDEX_X + i]); + ret =sensor_hub_input_get_attribute_info ( + hsdev, +HID_INPUT_REPORT , + usage_id, +HID_USAGE_SENSOR_ANGL_VELOCITY_X_AXIS + i, + &st->gyro[CHANNEL_SCAN_INDEX_X + i]);if (ret <0 )break ; -gyro_3d_adjust_channel_bit_mask (channels, -CHANNEL_SCAN_INDEX_X + i, - st->gyro[CHANNEL_SCAN_INDEX_X + i].size); +gyro_3d_adjust_channel_bit_mask ( + channels, +CHANNEL_SCAN_INDEX_X + i, + st->gyro[CHANNEL_SCAN_INDEX_X + i].size); }dev_dbg (&pdev->dev,"gyro_3d %x:%x, %x:%x, %x:%x\n" , - st->gyro[0 ].index, - st->gyro[0 ].report_id, - st->gyro[1 ].index, st->gyro[1 ].report_id, - st->gyro[2 ].index, st->gyro[2 ].report_id); + st->gyro[0 ].index, + st->gyro[0 ].report_id, + st->gyro[1 ].index, st->gyro[1 ].report_id, + st->gyro[2 ].index, st->gyro[2 ].report_id); st->scale_precision = hid_sensor_format_scale( HID_USAGE_SENSOR_GYRO_3D,
@@ -295,10 +296,10 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) gyro_state->common_attributes.pdev = pdev; ret =hid_sensor_parse_common_attributes (hsdev, -HID_USAGE_SENSOR_GYRO_3D , - &gyro_state->common_attributes, - gyro_3d_sensitivity_addresses, -ARRAY_SIZE (gyro_3d_sensitivity_addresses)); +HID_USAGE_SENSOR_GYRO_3D , + &gyro_state->common_attributes, + gyro_3d_sensitivity_addresses, +ARRAY_SIZE (gyro_3d_sensitivity_addresses));if (ret) {dev_err (&pdev->dev,"failed to setup common attributes\n" );return ret;
@@ -327,7 +328,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)atomic_set (&gyro_state->common_attributes.data_ready,0 ); ret =hid_sensor_setup_trigger (indio_dev, name, - &gyro_state->common_attributes); + &gyro_state->common_attributes);if (ret <0 ) {dev_err (&pdev->dev,"trigger setup failed\n" );return ret;
@@ -343,7 +344,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) gyro_state->callbacks.capture_sample = gyro_3d_capture_sample; gyro_state->callbacks.pdev = pdev; ret =sensor_hub_register_callback (hsdev,HID_USAGE_SENSOR_GYRO_3D , - &gyro_state->callbacks); + &gyro_state->callbacks);if (ret <0 ) {dev_err (&pdev->dev,"callback reg failed\n" ); goto error_iio_unreg;
Signature · 1 line
2.34.1
PATCH v4 11/36 iio: magnetometer: hid-sensor-magn-3d: align parenthesis for readability
From: Sanjay Chitroda <[email protected]>
Adjust alignment of parentheses to improve readability and maintain consistency with kernel coding style
--- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-)
drivers/iio/magnetometer/hid-sensor-magn-3d.c +36 -36
@@ -134,7 +134,7 @@ static const struct iio_chan_spec magn_3d_channels[] = {/* Adjust channel real bits based on report descriptor */ static void magn_3d_adjust_channel_bit_mask (struct iio_chan_spec *channels, -int channel,int size) +int channel,int size) { channels[channel].scan_type.sign ='s' ;/* Real storage bits will change based on the report desc. */
@@ -145,9 +145,9 @@ static void magn_3d_adjust_channel_bit_mask(struct iio_chan_spec *channels,/* Channel read_raw handler */ static int magn_3d_read_raw (struct iio_dev *indio_dev, -struct iio_chan_spec const *chan, -int *val,int *val2, -long mask) +struct iio_chan_spec const *chan, +int *val,int *val2, +long mask) {struct magn_3d_state *magn_state =iio_priv (indio_dev);int report_id =-1 ;
@@ -177,8 +177,7 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev, false);return -EINVAL ; } -hid_sensor_power_state (&magn_state->magn_flux_attributes, - false); +hid_sensor_power_state (&magn_state->magn_flux_attributes, false); ret_type =IIO_VAL_INT ;break ;case IIO_CHAN_INFO_SCALE :
@@ -239,10 +238,10 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev,/* Channel write_raw handler */ static int magn_3d_write_raw (struct iio_dev *indio_dev, -struct iio_chan_spec const *chan, -int val, -int val2, -long mask) +struct iio_chan_spec const *chan, +int val, +int val2, +long mask) {struct magn_3d_state *magn_state =iio_priv (indio_dev);int ret =0 ;
@@ -280,8 +279,8 @@ static const struct iio_info magn_3d_info = {/* Callback handler to send event after all samples are received and captured */ static int magn_3d_proc_event (struct hid_sensor_hub_device *hsdev, -u32 usage_id, -void *priv) +u32 usage_id, +void *priv) {struct iio_dev *indio_dev =platform_get_drvdata (priv);struct magn_3d_state *magn_state =iio_priv (indio_dev);
@@ -302,9 +301,9 @@ static int magn_3d_proc_event(struct hid_sensor_hub_device *hsdev,/* Capture samples in local storage */ static int magn_3d_capture_sample (struct hid_sensor_hub_device *hsdev, -u32 usage_id, -size_t raw_len,char *raw_data, -void *priv) +u32 usage_id, +size_t raw_len,char *raw_data, +void *priv) {struct iio_dev *indio_dev =platform_get_drvdata (priv);struct magn_3d_state *magn_state =iio_priv (indio_dev);
@@ -363,7 +362,8 @@ static int magn_3d_parse_report(struct platform_device *pdev,u32 address = magn_3d_addresses[i];/* Check if usage attribute exists in the sensor hub device */ - status = sensor_hub_input_get_attribute_info(hsdev, + status = sensor_hub_input_get_attribute_info( + hsdev, HID_INPUT_REPORT, usage_id, address,
@@ -378,18 +378,17 @@ static int magn_3d_parse_report(struct platform_device *pdev,return -EINVAL ; } -dev_dbg (&pdev->dev,"magn_3d Found %d usage attributes\n" , - attr_count); +dev_dbg (&pdev->dev,"magn_3d Found %d usage attributes\n" , attr_count);dev_dbg (&pdev->dev,"magn_3d X: %x:%x Y: %x:%x Z: %x:%x\n" , - st->magn[0 ].index, - st->magn[0 ].report_id, - st->magn[1 ].index, st->magn[1 ].report_id, - st->magn[2 ].index, st->magn[2 ].report_id); + st->magn[0 ].index, + st->magn[0 ].report_id, + st->magn[1 ].index, st->magn[1 ].report_id, + st->magn[2 ].index, st->magn[2 ].report_id);/* Setup IIO channel array */ _channels =devm_kcalloc (&pdev->dev, attr_count, -sizeof (struct iio_chan_spec ), -GFP_KERNEL ); +sizeof (struct iio_chan_spec ), +GFP_KERNEL );if (!_channels) {dev_err (&pdev->dev,"failed to allocate space for iio channels\n" );
@@ -434,8 +433,7 @@ static int magn_3d_parse_report(struct platform_device *pdev, *channels = _channels; -dev_dbg (&pdev->dev,"magn_3d Setup %d IIO channels\n" , - *chan_count); +dev_dbg (&pdev->dev,"magn_3d Setup %d IIO channels\n" , *chan_count); st->magn_flux_attr.scale_precision = hid_sensor_format_scale( HID_USAGE_SENSOR_COMPASS_3D,
@@ -450,7 +448,8 @@ static int magn_3d_parse_report(struct platform_device *pdev, &st->rot_attr.scale_post_decml);if (st->rot_attributes.sensitivity.index <0 ) { - sensor_hub_input_get_attribute_info(hsdev, + sensor_hub_input_get_attribute_info( + hsdev, HID_FEATURE_REPORT, usage_id, HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | HID_USAGE_SENSOR_ORIENT_COMP_MAGN_NORTH,
@@ -485,11 +484,12 @@ static int hid_magn_3d_probe(struct platform_device *pdev) magn_state->magn_flux_attributes.hsdev = hsdev; magn_state->magn_flux_attributes.pdev = pdev; - ret =hid_sensor_parse_common_attributes (hsdev, -HID_USAGE_SENSOR_COMPASS_3D , - &magn_state->magn_flux_attributes, - magn_3d_sensitivity_addresses, -ARRAY_SIZE (magn_3d_sensitivity_addresses)); + ret =hid_sensor_parse_common_attributes ( + hsdev, +HID_USAGE_SENSOR_COMPASS_3D , + &magn_state->magn_flux_attributes, + magn_3d_sensitivity_addresses, +ARRAY_SIZE (magn_3d_sensitivity_addresses));if (ret) {dev_err (&pdev->dev,"failed to setup common attributes\n" );return ret;
@@ -499,8 +499,8 @@ static int hid_magn_3d_probe(struct platform_device *pdev) magn_state->rot_attributes.sensitivity.index =-1 ; ret =magn_3d_parse_report (pdev, hsdev, - &channels, &chan_count, -HID_USAGE_SENSOR_COMPASS_3D , magn_state); + &channels, &chan_count, +HID_USAGE_SENSOR_COMPASS_3D , magn_state);if (ret) {dev_err (&pdev->dev,"failed to parse report\n" );return ret;
@@ -515,7 +515,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev)atomic_set (&magn_state->magn_flux_attributes.data_ready,0 ); ret =hid_sensor_setup_trigger (indio_dev, name, - &magn_state->magn_flux_attributes); + &magn_state->magn_flux_attributes);if (ret <0 ) {dev_err (&pdev->dev,"trigger setup failed\n" );return ret;
@@ -531,7 +531,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev) magn_state->callbacks.capture_sample = magn_3d_capture_sample; magn_state->callbacks.pdev = pdev; ret =sensor_hub_register_callback (hsdev,HID_USAGE_SENSOR_COMPASS_3D , - &magn_state->callbacks); + &magn_state->callbacks);if (ret <0 ) {dev_err (&pdev->dev,"callback reg failed\n" ); goto error_iio_unreg;
Signature · 1 line
2.34.1
PATCH v4 12/36 iio: humidity: hid-sensor-humidity: use common device for devres
In reply to Sanjay ChitrodaFrom: Sanjay Chitroda <[email protected]>
kmemdup() is used for memory that is logically tied to the HID platform device, even though the driver binds into the IIO framework.
Using &indio_dev->dev for devres allocations works functionally, but it results in two separate devres ownership trees—one for the HID platform device (pdev) and another for the IIO device (indio_dev).
The devres framework is intended to have a single, well-defined parent device. Since the memory originates from HID sensor probing and is not IIO-specific, &pdev->dev is the correct and logical owner.
Switch to using the platform device for devm_kmemdup() so that all resources are released deterministically and consistently.
--- drivers/iio/humidity/hid-sensor-humidity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/humidity/hid-sensor-humidity.c +1 -1
@@ -215,7 +215,7 @@ static int hid_humidity_probe(struct platform_device *pdev)if (ret)return ret; - humid_chans =devm_kmemdup (&indio_dev->dev, humidity_channels, + humid_chans =devm_kmemdup (&pdev->dev, humidity_channels,sizeof (humidity_channels),GFP_KERNEL );if (!humid_chans)return -ENOMEM ;
Signature · 1 line
2.34.1
PATCH v4 13/36 iio: position: hid-sensor-custom-intel-hinge: use common device for devres
In reply to Sanjay ChitrodaFrom: Sanjay Chitroda <[email protected]>
kmemdup() is used for memory that is logically tied to the HID platform device, even though the driver binds into the IIO framework.
Using &indio_dev->dev for devres allocations works functionally, but it results in two separate devres ownership trees—one for the HID platform device (pdev) and another for the IIO device (indio_dev).
The devres framework is intended to have a single, well-defined parent device. Since the memory originates from HID sensor probing and is not IIO-specific, &pdev->dev is the correct and logical owner.
Switch to using the platform device for devm_kmemdup() so that all resources are released deterministically and consistently.
--- drivers/iio/position/hid-sensor-custom-intel-hinge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/position/hid-sensor-custom-intel-hinge.c +1 -1
@@ -292,7 +292,7 @@ static int hid_hinge_probe(struct platform_device *pdev) } indio_dev->num_channels =ARRAY_SIZE (hinge_channels); - indio_dev->channels =devm_kmemdup (&indio_dev->dev, hinge_channels, + indio_dev->channels =devm_kmemdup (&pdev->dev, hinge_channels,sizeof (hinge_channels),GFP_KERNEL );if (!indio_dev->channels)return -ENOMEM ;
Signature · 1 line
2.34.1
PATCH v4 14/36 iio: temperature: hid-sensor-temperature: use common device for devres
In reply to Sanjay ChitrodaFrom: Sanjay Chitroda <[email protected]>
kmemdup() is used for memory that is logically tied to the HID platform device, even though the driver binds into the IIO framework.
Using &indio_dev->dev for devres allocations works functionally, but it results in two separate devres ownership trees—one for the HID platform device (pdev) and another for the IIO device (indio_dev).
The devres framework is intended to have a single, well-defined parent device. Since the memory originates from HID sensor probing and is not IIO-specific, &pdev->dev is the correct and logical owner.
Switch to using the platform device for devm_kmemdup() so that all resources are released deterministically and consistently.
--- drivers/iio/temperature/hid-sensor-temperature.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/temperature/hid-sensor-temperature.c +2 -2
@@ -213,8 +213,8 @@ static int hid_temperature_probe(struct platform_device *pdev)if (ret)return ret; - temp_chans =devm_kmemdup (&indio_dev->dev, temperature_channels, -sizeof (temperature_channels),GFP_KERNEL ); + temp_chans =devm_kmemdup (&pdev->dev, temperature_channels, +sizeof (temperature_channels),GFP_KERNEL );if (!temp_chans)return -ENOMEM ;
Signature · 1 line
2.34.1
PATCH v4 15/36 iio: humidity: hid-sensor-humidity: use local struct device
In reply to Sanjay ChitrodaFrom: Sanjay Chitroda <[email protected]>
Introduce a local struct device pointer derived from &pdev->dev. This avoids repeated &pdev->dev usage and improves readability.
--- drivers/iio/humidity/hid-sensor-humidity.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/iio/humidity/hid-sensor-humidity.c +4 -3
@@ -196,10 +196,11 @@ static int hid_humidity_probe(struct platform_device *pdev)struct iio_dev *indio_dev;struct hid_humidity_state *humid_st;struct iio_chan_spec *humid_chans; -struct hid_sensor_hub_device *hsdev =dev_get_platdata (&pdev->dev); +struct device *dev = &pdev->dev; +struct hid_sensor_hub_device *hsdev =dev_get_platdata (dev);int ret; - indio_dev =devm_iio_device_alloc (&pdev->dev,sizeof (*humid_st)); + indio_dev =devm_iio_device_alloc (dev,sizeof (*humid_st));if (!indio_dev)return -ENOMEM ;
@@ -215,7 +216,7 @@ static int hid_humidity_probe(struct platform_device *pdev)if (ret)return ret; - humid_chans =devm_kmemdup (&pdev->dev, humidity_channels, + humid_chans =devm_kmemdup (dev, humidity_channels,sizeof (humidity_channels),GFP_KERNEL );if (!humid_chans)return -ENOMEM ;
Signature · 1 line
2.34.1
PATCH v4 16/36 iio: gyro: hid-sensor-gyro-3d: use local struct device
In reply to Sanjay ChitrodaFrom: Sanjay Chitroda <[email protected]>
Introduce a local struct device pointer derived from &pdev->dev. This avoids repeated &pdev->dev usage and improves readability.
--- drivers/iio/gyro/hid-sensor-gyro-3d.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/iio/gyro/hid-sensor-gyro-3d.c +10 -9
@@ -280,13 +280,14 @@ static int gyro_3d_parse_report(struct platform_device *pdev,/* Function to initialize the processing for usage id */ static int hid_gyro_3d_probe (struct platform_device *pdev) { -struct hid_sensor_hub_device *hsdev =dev_get_platdata (&pdev->dev); +struct device *dev = &pdev->dev; +struct hid_sensor_hub_device *hsdev =dev_get_platdata (dev);int ret =0 ;static const char *name ="gyro_3d" ;struct iio_dev *indio_dev;struct gyro_3d_state *gyro_state; - indio_dev =devm_iio_device_alloc (&pdev->dev,sizeof (*gyro_state)); + indio_dev =devm_iio_device_alloc (dev,sizeof (*gyro_state));if (!indio_dev)return -ENOMEM ;platform_set_drvdata (pdev, indio_dev);
@@ -301,14 +302,14 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) gyro_3d_sensitivity_addresses, ARRAY_SIZE(gyro_3d_sensitivity_addresses));if (ret) { -dev_err (&pdev->dev,"failed to setup common attributes\n" ); +dev_err (dev,"failed to setup common attributes\n" );return ret; } - indio_dev->channels =devm_kmemdup (&pdev->dev, gyro_3d_channels, + indio_dev->channels =devm_kmemdup (dev, gyro_3d_channels,sizeof (gyro_3d_channels),GFP_KERNEL );if (!indio_dev->channels) { -dev_err (&pdev->dev,"failed to duplicate channels\n" ); +dev_err (dev,"failed to duplicate channels\n" );return -ENOMEM ; }
@@ -316,7 +317,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) (struct iio_chan_spec *)indio_dev->channels, HID_USAGE_SENSOR_GYRO_3D, gyro_state);if (ret) { -dev_err (&pdev->dev,"failed to setup attributes\n" ); +dev_err (dev,"failed to setup attributes\n" );return ret; }
@@ -330,13 +331,13 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) ret =hid_sensor_setup_trigger (indio_dev, name, &gyro_state->common_attributes);if (ret <0 ) { -dev_err (&pdev->dev,"trigger setup failed\n" ); +dev_err (dev,"trigger setup failed\n" );return ret; } ret =iio_device_register (indio_dev);if (ret) { -dev_err (&pdev->dev,"device register failed\n" ); +dev_err (dev,"device register failed\n" ); goto error_remove_trigger; }
@@ -346,7 +347,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) ret =sensor_hub_register_callback (hsdev,HID_USAGE_SENSOR_GYRO_3D , &gyro_state->callbacks);if (ret <0 ) { -dev_err (&pdev->dev,"callback reg failed\n" ); +dev_err (dev,"callback reg failed\n" ); goto error_iio_unreg; }
Signature · 1 line
2.34.1
PATCH v4 17/36 iio: accel: hid-sensor-accel-3d: use local struct device
In reply to Sanjay ChitrodaFrom: Sanjay Chitroda <[email protected]>
Introduce a local struct device pointer derived from &pdev->dev. This avoids repeated &pdev->dev usage and improves readability.
--- drivers/iio/accel/hid-sensor-accel-3d.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/iio/accel/hid-sensor-accel-3d.c +10 -10
@@ -328,7 +328,8 @@ static int accel_3d_parse_report(struct platform_device *pdev,/* Function to initialize the processing for usage id */ static int hid_accel_3d_probe (struct platform_device *pdev) { -struct hid_sensor_hub_device *hsdev =dev_get_platdata (&pdev->dev); +struct device *dev = &pdev->dev; +struct hid_sensor_hub_device *hsdev =dev_get_platdata (dev);int ret =0 ;const char *name;struct iio_dev *indio_dev;
@@ -336,8 +337,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev)const struct iio_chan_spec *channel_spec;int channel_size; - indio_dev =devm_iio_device_alloc (&pdev->dev, -sizeof (struct accel_3d_state )); + indio_dev =devm_iio_device_alloc (dev,sizeof (struct accel_3d_state ));if (indio_dev ==NULL )return -ENOMEM ;
@@ -364,21 +364,21 @@ static int hid_accel_3d_probe(struct platform_device *pdev) accel_3d_sensitivity_addresses, ARRAY_SIZE(accel_3d_sensitivity_addresses));if (ret) { -dev_err (&pdev->dev,"failed to setup common attributes\n" ); +dev_err (dev,"failed to setup common attributes\n" );return ret; } - indio_dev->channels =devm_kmemdup (&pdev->dev, channel_spec, + indio_dev->channels =devm_kmemdup (dev, channel_spec, channel_size,GFP_KERNEL );if (!indio_dev->channels) { -dev_err (&pdev->dev,"failed to duplicate channels\n" ); +dev_err (dev,"failed to duplicate channels\n" );return -ENOMEM ; } ret =accel_3d_parse_report (pdev, hsdev, (struct iio_chan_spec *)indio_dev->channels, hsdev->usage, accel_state);if (ret) { -dev_err (&pdev->dev,"failed to setup attributes\n" ); +dev_err (dev,"failed to setup attributes\n" );return ret; }
@@ -391,13 +391,13 @@ static int hid_accel_3d_probe(struct platform_device *pdev) ret =hid_sensor_setup_trigger (indio_dev, name, &accel_state->common_attributes);if (ret <0 ) { -dev_err (&pdev->dev,"trigger setup failed\n" ); +dev_err (dev,"trigger setup failed\n" );return ret; } ret =iio_device_register (indio_dev);if (ret) { -dev_err (&pdev->dev,"device register failed\n" ); +dev_err (dev,"device register failed\n" ); goto error_remove_trigger; }
@@ -407,7 +407,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) ret =sensor_hub_register_callback (hsdev, hsdev->usage, &accel_state->callbacks);if (ret <0 ) { -dev_err (&pdev->dev,"callback reg failed\n" ); +dev_err (dev,"callback reg failed\n" ); goto error_iio_unreg; }
Signature · 1 line
2.34.1
PATCH v4 18/36 iio: light: hid-sensor-als: use local struct device
In reply to Sanjay ChitrodaFrom: Sanjay Chitroda <[email protected]>
Introduce a local struct device pointer derived from &pdev->dev. This avoids repeated &pdev->dev usage and improves readability.
--- drivers/iio/light/hid-sensor-als.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/iio/light/hid-sensor-als.c +8 -7
@@ -357,13 +357,14 @@ static int als_parse_report(struct platform_device *pdev,/* Function to initialize the processing for usage id */ static int hid_als_probe (struct platform_device *pdev) { -struct hid_sensor_hub_device *hsdev =dev_get_platdata (&pdev->dev); +struct device *dev = &pdev->dev; +struct hid_sensor_hub_device *hsdev =dev_get_platdata (dev);int ret =0 ;static const char *name ="als" ;struct iio_dev *indio_dev;struct als_state *als_state; - indio_dev =devm_iio_device_alloc (&pdev->dev,sizeof (struct als_state )); + indio_dev =devm_iio_device_alloc (dev,sizeof (struct als_state ));if (!indio_dev)return -ENOMEM ;platform_set_drvdata (pdev, indio_dev);
@@ -378,7 +379,7 @@ static int hid_als_probe(struct platform_device *pdev) als_sensitivity_addresses, ARRAY_SIZE(als_sensitivity_addresses));if (ret) { -dev_err (&pdev->dev,"failed to setup common attributes\n" ); +dev_err (dev,"failed to setup common attributes\n" );return ret; }
@@ -386,7 +387,7 @@ static int hid_als_probe(struct platform_device *pdev) hsdev->usage, als_state);if (ret) { -dev_err (&pdev->dev,"failed to setup attributes\n" ); +dev_err (dev,"failed to setup attributes\n" );return ret; }
@@ -408,13 +409,13 @@ static int hid_als_probe(struct platform_device *pdev) ret =hid_sensor_setup_trigger (indio_dev, name, &als_state->common_attributes);if (ret <0 ) { -dev_err (&pdev->dev,"trigger setup failed\n" ); +dev_err (dev,"trigger setup failed\n" );return ret; } ret =iio_device_register (indio_dev);if (ret) { -dev_err (&pdev->dev,"device register failed\n" ); +dev_err (dev,"device register failed\n" ); goto error_remove_trigger; }
@@ -423,7 +424,7 @@ static int hid_als_probe(struct platform_device *pdev) als_state->callbacks.pdev = pdev; ret =sensor_hub_register_callback (hsdev, hsdev->usage, &als_state->callbacks);if (ret <0 ) { -dev_err (&pdev->dev,"callback reg failed\n" ); +dev_err (dev,"callback reg failed\n" ); goto error_iio_unreg; }
Signature · 1 line
2.34.1
PATCH v4 19/36 iio: light: hid-sensor-prox: use local struct device
In reply to Sanjay ChitrodaFrom: Sanjay Chitroda <[email protected]>
Introduce a local struct device pointer derived from &pdev->dev. This avoids repeated &pdev->dev usage and improves readability.
--- drivers/iio/light/hid-sensor-prox.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/iio/light/hid-sensor-prox.c +8 -8
@@ -272,14 +272,14 @@ static int prox_parse_report(struct platform_device *pdev,/* Function to initialize the processing for usage id */ static int hid_prox_probe (struct platform_device *pdev) { -struct hid_sensor_hub_device *hsdev =dev_get_platdata (&pdev->dev); +struct device *dev = &pdev->dev; +struct hid_sensor_hub_device *hsdev =dev_get_platdata (dev);int ret =0 ;static const char *name ="prox" ;struct iio_dev *indio_dev;struct prox_state *prox_state; - indio_dev =devm_iio_device_alloc (&pdev->dev, -sizeof (struct prox_state )); + indio_dev =devm_iio_device_alloc (dev,sizeof (struct prox_state ));if (!indio_dev)return -ENOMEM ;platform_set_drvdata (pdev, indio_dev);
@@ -293,13 +293,13 @@ static int hid_prox_probe(struct platform_device *pdev) prox_sensitivity_addresses, ARRAY_SIZE(prox_sensitivity_addresses));if (ret) { -dev_err (&pdev->dev,"failed to setup common attributes\n" ); +dev_err (dev,"failed to setup common attributes\n" );return ret; } ret =prox_parse_report (pdev, hsdev, prox_state);if (ret) { -dev_err (&pdev->dev,"failed to setup attributes\n" ); +dev_err (dev,"failed to setup attributes\n" );return ret; }
@@ -315,13 +315,13 @@ static int hid_prox_probe(struct platform_device *pdev) ret =hid_sensor_setup_trigger (indio_dev, name, &prox_state->common_attributes);if (ret) { -dev_err (&pdev->dev,"trigger setup failed\n" ); +dev_err (dev,"trigger setup failed\n" );return ret; } ret =iio_device_register (indio_dev);if (ret) { -dev_err (&pdev->dev,"device register failed\n" ); +dev_err (dev,"device register failed\n" ); goto error_remove_trigger; }
@@ -331,7 +331,7 @@ static int hid_prox_probe(struct platform_device *pdev) ret =sensor_hub_register_callback (hsdev, hsdev->usage, &prox_state->callbacks);if (ret <0 ) { -dev_err (&pdev->dev,"callback reg failed\n" ); +dev_err (dev,"callback reg failed\n" ); goto error_iio_unreg; }
Signature · 1 line
2.34.1