Commit 39dac9d0 authored by Su Hui's avatar Su Hui Committed by Jonathan Cameron
Browse files

iio: imu: inv_mpu6050: return callee's error code rather than -EINVAL



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: default avatarSu Hui <suhui@nfschina.com>
Link: https://lore.kernel.org/r/20231030020752.67630-1-suhui@nfschina.com


Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent ed73c4f1
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -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;