Re: [PATCH 6/6] staging: sm750fb: sm750_sw_i2c_init: return -EINVAL for invalid GPIO
From: Dan Carpenter
Date: Thu Mar 05 2026 - 00:48:58 EST
On Wed, Mar 04, 2026 at 11:05:29PM +0530, Soham Kute wrote:
> Return -EINVAL instead of -1 when the GPIO pin number is out of
> range. The caller ignores the return value.
>
> Signed-off-by: Soham Kute <officialsohamkute@xxxxxxxxx>
> ---
> drivers/staging/sm750fb/ddk750_swi2c.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c
> index c73943341f66..46599be8d6b9 100644
> --- a/drivers/staging/sm750fb/ddk750_swi2c.c
> +++ b/drivers/staging/sm750fb/ddk750_swi2c.c
> @@ -344,7 +344,7 @@ static unsigned char sw_i2c_read_byte(unsigned char ack)
> * data_gpio - The GPIO pin to be used as i2c SDA
> *
> * Return Value:
> - * -1 - Fail to initialize the i2c
> + * -EINVAL - Fail to initialize the i2c
> * 0 - Success
> */
> static long sm750le_i2c_init(unsigned char clk_gpio, unsigned char data_gpio)
This part needs to be done in the patch that changes
sw_i2c_read_byte().
regards,
dan carpenter
> @@ -382,7 +382,7 @@ static long sm750le_i2c_init(unsigned char clk_gpio, unsigned char data_gpio)
> * data_gpio - The GPIO pin to be used as i2c SDA
> *
> * Return Value:
> - * -1 - Fail to initialize the i2c
> + * -EINVAL - Fail to initialize the i2c
> * 0 - Success
> */
> long sm750_sw_i2c_init(unsigned char clk_gpio, unsigned char data_gpio)
> @@ -394,7 +394,7 @@ long sm750_sw_i2c_init(unsigned char clk_gpio, unsigned char data_gpio)
> * range is only from [0..63]
> */
> if ((clk_gpio > 31) || (data_gpio > 31))
> - return -1;
> + return -EINVAL;
>
> if (sm750_get_chip_type() == SM750LE)
> return sm750le_i2c_init(clk_gpio, data_gpio);
> --
> 2.34.1
>