Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 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>

authored by

Su Hui and committed by
Jonathan Cameron
39dac9d0 ed73c4f1

+3 -6
+3 -6
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
··· 567 567 static int inv_mpu6050_sensor_set(struct inv_mpu6050_state *st, int reg, 568 568 int axis, int val) 569 569 { 570 - int ind, result; 570 + int ind; 571 571 __be16 d = cpu_to_be16(val); 572 572 573 573 ind = (axis - IIO_MOD_X) * 2; 574 - result = regmap_bulk_write(st->map, reg + ind, &d, sizeof(d)); 575 - if (result) 576 - return -EINVAL; 577 574 578 - return 0; 575 + return regmap_bulk_write(st->map, reg + ind, &d, sizeof(d)); 579 576 } 580 577 581 578 static int inv_mpu6050_sensor_show(struct inv_mpu6050_state *st, int reg, ··· 584 587 ind = (axis - IIO_MOD_X) * 2; 585 588 result = regmap_bulk_read(st->map, reg + ind, &d, sizeof(d)); 586 589 if (result) 587 - return -EINVAL; 590 + return result; 588 591 *val = (short)be16_to_cpup(&d); 589 592 590 593 return IIO_VAL_INT;