Skip to contentSkip to conversation

iio/imu: inv_icm42600: Use max() helper macros

PATCH Superseded Bragatheswaran Manickavel 2 participants 3 messages Oct 25, 2023 – Oct 27, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio/imu: inv_icm42600: Use max() helper macros

Use the standard max() helper macros instead of direct variable comparison using if/else blocks or ternary operator. Change identified using minmax.cocci Coccinelle semantic patch.

---
 drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +1 -4
index b1e4fde27d25..f67bd5a39beb 100644
@@ -137,10 +137,7 @@ static int inv_icm42600_accel_update_scan_mode(struct iio_dev *indio_dev,
 out_unlock:
 	mutex_unlock(&st->lock);
 	/* sleep maximum required time */
-	if (sleep_accel > sleep_temp)
-		sleep = sleep_accel;
-	else
-		sleep = sleep_temp;
+	sleep = max(sleep_accel, sleep_temp);
 	if (sleep)
 		msleep(sleep);
 	return ret;
Signature · 1 line
2.34.1
#1 lore raw

Hello,

thanks for this patch.

The same computation is also done inside inv_icm42600_gyro. Can you do a patch that is updating both files to use max?

Thanks a lot,
JB

From: Bragatheswaran Manickavel <[email protected]>
Sent: Wednesday, October 25, 2023 13:35
To: Jean-Baptiste Maneyrol <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Cc: Bragatheswaran Manickavel <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Subject: [PATCH] iio/imu: inv_icm42600: Use max() helper macros

Use the standard max() helper macros instead of direct variable comparison using if/else blocks or ternary operator. Change identified using minmax. cocci Coccinelle semantic patch. Signed-off-by: Bragatheswaran Manickavel <bragathemanick0908@ gmail. com> ZjQcmQRYFpfptBannerStart
This Message Is From an Untrusted Sender
You have not previously corresponded with this sender.

ZjQcmQRYFpfptBannerEnd
Use the standard max() helper macros instead of direct
variable comparison using if/else blocks or ternary
operator. Change identified using minmax.cocci
Coccinelle semantic patch.

---
 drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +1 -4
index b1e4fde27d25..f67bd5a39beb 100644
@@ -137,10 +137,7 @@ static int inv_icm42600_accel_update_scan_mode(struct iio_dev *indio_dev,
 out_unlock:
 	mutex_unlock(&st->lock);
 	/* sleep maximum required time */
-	if (sleep_accel > sleep_temp)
-		sleep = sleep_accel;
-	else
-		sleep = sleep_temp;
+	sleep = max(sleep_accel, sleep_temp);
 	if (sleep)
 		msleep(sleep);
 	return ret;
Signature · 1 line
2.34.1
#2 lore raw
Quoted 8 lines · Jean-Baptiste Maneyrol

Hello,

thanks for this patch.

The same computation is also done inside inv_icm42600_gyro. Can you do a patch that is updating both files to use max?

Thanks a lot,
JB

Hi Jean,

Same computation can be included in both inv_icm42600_gyro and inv_icm42600_buffer. Will make those changes and send a new patch.

Thanks,
Bragathe

Quoted 39 lines

From: Bragatheswaran Manickavel <[email protected]>
Sent: Wednesday, October 25, 2023 13:35
To: Jean-Baptiste Maneyrol <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Cc: Bragatheswaran Manickavel <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Subject: [PATCH] iio/imu: inv_icm42600: Use max() helper macros

Use the standard max() helper macros instead of direct variable comparison using if/else blocks or ternary operator. Change identified using minmax. cocci Coccinelle semantic patch. Signed-off-by: Bragatheswaran Manickavel <bragathemanick0908@ gmail. com> ZjQcmQRYFpfptBannerStart
This Message Is From an Untrusted Sender
You have not previously corresponded with this sender.

ZjQcmQRYFpfptBannerEnd
Use the standard max() helper macros instead of direct variable comparison using if/else blocks or ternary operator. Change identified using minmax.cocci Coccinelle semantic patch.

---
  drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +1 -4
index b1e4fde27d25..f67bd5a39beb 100644
@@ -137,10 +137,7 @@ static int inv_icm42600_accel_update_scan_mode(struct iio_dev *indio_dev,
  out_unlock:
  	mutex_unlock(&st->lock);
  	/* sleep maximum required time */
-	if (sleep_accel > sleep_temp)
-		sleep = sleep_accel;
-	else
-		sleep = sleep_temp;
+	sleep = max(sleep_accel, sleep_temp);
  	if (sleep)
  		msleep(sleep);
  	return ret;