diff mbox series

iio: ssp_sensors: fix error code in ssp_print_mcu_debug()

Message ID 20210914105333.GA11657@kili (mailing list archive)
State Accepted
Headers show
Series iio: ssp_sensors: fix error code in ssp_print_mcu_debug() | expand

Commit Message

Dan Carpenter Sept. 14, 2021, 10:53 a.m. UTC
The ssp_print_mcu_debug() function should return negative error codes on
error.  Returning "length" is meaningless.  This change does not affect
runtime because the callers only care about zero/non-zero.

Reported-by: Jonathan Cameron <jic23@kernel.org>
Fixes: 50dd64d57eee ("iio: common: ssp_sensors: Add sensorhub driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/iio/common/ssp_sensors/ssp_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jonathan Cameron Sept. 18, 2021, 6:13 p.m. UTC | #1
On Tue, 14 Sep 2021 13:53:33 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> The ssp_print_mcu_debug() function should return negative error codes on
> error.  Returning "length" is meaningless.  This change does not affect
> runtime because the callers only care about zero/non-zero.
> 
> Reported-by: Jonathan Cameron <jic23@kernel.org>
> Fixes: 50dd64d57eee ("iio: common: ssp_sensors: Add sensorhub driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

> ---
>  drivers/iio/common/ssp_sensors/ssp_spi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/common/ssp_sensors/ssp_spi.c b/drivers/iio/common/ssp_sensors/ssp_spi.c
> index 4864c38b8d1c..77449b4f3df5 100644
> --- a/drivers/iio/common/ssp_sensors/ssp_spi.c
> +++ b/drivers/iio/common/ssp_sensors/ssp_spi.c
> @@ -137,7 +137,7 @@ static int ssp_print_mcu_debug(char *data_frame, int *data_index,
>  	if (length > received_len - *data_index || length <= 0) {
>  		ssp_dbg("[SSP]: MSG From MCU-invalid debug length(%d/%d)\n",
>  			length, received_len);
> -		return length ? length : -EPROTO;
> +		return -EPROTO;
>  	}
>  
>  	ssp_dbg("[SSP]: MSG From MCU - %s\n", &data_frame[*data_index]);
diff mbox series

Patch

diff --git a/drivers/iio/common/ssp_sensors/ssp_spi.c b/drivers/iio/common/ssp_sensors/ssp_spi.c
index 4864c38b8d1c..77449b4f3df5 100644
--- a/drivers/iio/common/ssp_sensors/ssp_spi.c
+++ b/drivers/iio/common/ssp_sensors/ssp_spi.c
@@ -137,7 +137,7 @@  static int ssp_print_mcu_debug(char *data_frame, int *data_index,
 	if (length > received_len - *data_index || length <= 0) {
 		ssp_dbg("[SSP]: MSG From MCU-invalid debug length(%d/%d)\n",
 			length, received_len);
-		return length ? length : -EPROTO;
+		return -EPROTO;
 	}
 
 	ssp_dbg("[SSP]: MSG From MCU - %s\n", &data_frame[*data_index]);