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 b1e4fde..f67bd5a 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 6ef1df9..b52f328 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 3bf946e..3df0a71 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;