iio/imu: inv_icm42600: Use max() helper macros
authorBragatheswaran Manickavel <bragathemanick0908@gmail.com>
Fri, 27 Oct 2023 09:44:10 +0000 (15:14 +0530)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 16 Nov 2023 19:10:28 +0000 (19:10 +0000)
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>
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20231027094410.3706-1-bragathemanick0908@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c

index b1e4fde27d25609d27a359a228c84e7f31b2881f..f67bd5a39beb3441114ec5f500bf0bd086917872 100644 (file)
@@ -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;
index 6ef1df9d60b77de585b8cc30307a0d32576e2cb4..b52f328fd26ce7ab130b40a21c5ba8c317920fbb 100644 (file)
@@ -424,10 +424,7 @@ out_unlock:
        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);
 
index 3bf946e56e1dfd4f4b766d2b289caee4cd468072..3df0a715e8856039fc185f69ed193ae9dcbabb0a 100644 (file)
@@ -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;