iio/imu: inv_icm42600: Use max() helper macros
Subsystems (2)
PATCH v2 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.
---
V1 -> V2: Adding similar changes to inv_icm42600_gyro & inv_icm42600_buffer
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 5 +---- drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 5 +---- drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +1 -4
@@ -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;
drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c +1 -4
@@ -424,10 +424,7 @@ static int inv_icm42600_buffer_postdisable(struct iio_dev *indio_dev)mutex_unlock (&st->lock);/* sleep maximum required time */ -if (sleep_sensor > sleep_temp) - sleep = sleep_sensor; -else - sleep = sleep_temp; + sleep =max (sleep_sensor, sleep_temp);if (sleep)msleep (sleep);
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +1 -4
@@ -137,10 +137,7 @@ static int inv_icm42600_gyro_update_scan_mode(struct iio_dev *indio_dev, out_unlock:mutex_unlock (&st->lock);/* sleep maximum required time */ -if (sleep_gyro > sleep_temp) - sleep = sleep_gyro; -else - sleep = sleep_temp; + sleep =max (sleep_gyro, sleep_temp);if (sleep)msleep (sleep);return ret;
Signature · 1 line
2.34.1
A message that is not in the archive (sent off-list or not yet received): FR3P281MB1757C4183E5B536D463BAEBBCEDCA@FR3P281MB1757.DEUP281.PROD.OUTLOOK.COM
Jonathan Cameron
maintainerQuoted 5 lines · On Fri, 27 Oct 2023 15:19:49 +0000 Jean-Baptiste Maneyrol…
Hello,
thanks for the patch, looks good.
Interestingly b4 isn't finding this tag. I'm too lazy to look into why but seems your email didn't reach patchwork either.
Applied it by hand whilst applying the patch to the togreg branch of iio.git which given timing will be rebase on rc1 once available. For now I'll just push it out as testing to give 0-day a head start.
Jonathan
Quoted 78 lines
Thanks,
JBFrom: Bragatheswaran Manickavel <[email protected]>
Sent: Friday, October 27, 2023 11:44
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 v2] iio/imu:inv_icm42600: Usemax()helper macros
Use the standardmax()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 standardmax()helper macros instead of direct
variable comparison using if/else blocks or ternary
operator. Change identified usingminmax.cocci
Coccinelle semantic patch.Signed-off-by Bragatheswaran Manickavel <[email protected]>---
V1 -> V2: Adding similar changes toinv_icm42600_gyro&inv_icm42600_bufferdrivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 5 +---- drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 5 +---- drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-)drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +1
-4@@ -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;drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c +1
-4@@ -424,10 +424,7 @@ static int inv_icm42600_buffer_postdisable(struct iio_dev *indio_dev)mutex_unlock (&st->lock);/* sleep maximum required time */ -if (sleep_sensor > sleep_temp) - sleep = sleep_sensor; -else - sleep = sleep_temp; + sleep =max (sleep_sensor, sleep_temp);if (sleep)msleep (sleep);drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +1
-4@@ -137,10 +137,7 @@ static int inv_icm42600_gyro_update_scan_mode(struct iio_dev *indio_dev, out_unlock:mutex_unlock (&st->lock);/* sleep maximum required time */ -if (sleep_gyro > sleep_temp) - sleep = sleep_gyro; -else - sleep = sleep_temp; + sleep =max (sleep_gyro, sleep_temp);if (sleep)msleep (sleep);return ret;