iio: imu: inv_mpu6050: return callee's error code rather than -EINVAL
authorSu Hui <suhui@nfschina.com>
Mon, 30 Oct 2023 02:07:53 +0000 (10:07 +0800)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 26 Nov 2023 17:06:33 +0000 (17:06 +0000)
regmap_bulk_write()/regmap_bulk_read() return zero or negative error
code, return the callee's error code is better than '-EINVAL'.

Signed-off-by: Su Hui <suhui@nfschina.com>
Link: https://lore.kernel.org/r/20231030020752.67630-1-suhui@nfschina.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c

index 3fbeef1a70186bf0c7b969f4c52219d7344bf112..4713e3bc59e0ccf96d8178fa4995c929bdcae159 100644 (file)
@@ -567,15 +567,12 @@ static int inv_mpu6050_init_config(struct iio_dev *indio_dev)
 static int inv_mpu6050_sensor_set(struct inv_mpu6050_state  *st, int reg,
                                int axis, int val)
 {
-       int ind, result;
+       int ind;
        __be16 d = cpu_to_be16(val);
 
        ind = (axis - IIO_MOD_X) * 2;
-       result = regmap_bulk_write(st->map, reg + ind, &d, sizeof(d));
-       if (result)
-               return -EINVAL;
 
-       return 0;
+       return regmap_bulk_write(st->map, reg + ind, &d, sizeof(d));
 }
 
 static int inv_mpu6050_sensor_show(struct inv_mpu6050_state  *st, int reg,
@@ -587,7 +584,7 @@ static int inv_mpu6050_sensor_show(struct inv_mpu6050_state  *st, int reg,
        ind = (axis - IIO_MOD_X) * 2;
        result = regmap_bulk_read(st->map, reg + ind, &d, sizeof(d));
        if (result)
-               return -EINVAL;
+               return result;
        *val = (short)be16_to_cpup(&d);
 
        return IIO_VAL_INT;