mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: imu: inv_mpu6050: return callee's error code rather than -EINVAL
@ 2023-10-30  2:07 Su Hui
  2023-11-26 17:07 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Su Hui @ 2023-10-30  2:07 UTC (permalink / raw)
  To: jic23, lars
  Cc: Su Hui, jean-baptiste.maneyrol, chenhuiz, andy.shevchenko,
	linux-iio, linux-kernel, kernel-janitors

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>
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index a9a5fb266ef1..5ded0781797c 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -572,7 +572,7 @@ static int inv_mpu6050_sensor_set(struct inv_mpu6050_state  *st, int reg,
 	ind = (axis - IIO_MOD_X) * 2;
 	result = regmap_bulk_write(st->map, reg + ind, &d, sizeof(d));
 	if (result)
-		return -EINVAL;
+		return result;
 
 	return 0;
 }
@@ -586,7 +586,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;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: imu: inv_mpu6050: return callee's error code rather than -EINVAL
  2023-10-30  2:07 [PATCH] iio: imu: inv_mpu6050: return callee's error code rather than -EINVAL Su Hui
@ 2023-11-26 17:07 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2023-11-26 17:07 UTC (permalink / raw)
  To: Su Hui
  Cc: lars, jean-baptiste.maneyrol, chenhuiz, andy.shevchenko,
	linux-iio, linux-kernel, kernel-janitors

On Mon, 30 Oct 2023 10:07:53 +0800
Su Hui <suhui@nfschina.com> wrote:

> regmap_bulk_write()/regmap_bulk_read() return zero or negative error
> code, return the callee's error code is better than '-EINVAL'.
Thanks and fully agree - though one small tweak I made whilst applying is mentioned
below.

Applied to the togreg branch of iio.git and pushed out as testing for 0-day
to see if we missed anything.

> 
> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---
>  drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index a9a5fb266ef1..5ded0781797c 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -572,7 +572,7 @@ static int inv_mpu6050_sensor_set(struct inv_mpu6050_state  *st, int reg,
>  	ind = (axis - IIO_MOD_X) * 2;
>  	result = regmap_bulk_write(st->map, reg + ind, &d, sizeof(d));
>  	if (result)
> -		return -EINVAL;
> +		return result;
>  
>  	return 0;
I tweaked this to go further

	return regmap_bulk_write();

>  }
> @@ -586,7 +586,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;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-26 17:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-30  2:07 [PATCH] iio: imu: inv_mpu6050: return callee's error code rather than -EINVAL Su Hui
2023-11-26 17:07 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®