diff mbox series

[v2] platform/x86: silicom-platform: clean up a check

Message ID a58bffb7-0a8b-4195-b273-f65a188ace7b@moroto.mountain (mailing list archive)
State Accepted, archived
Headers show
Series [v2] platform/x86: silicom-platform: clean up a check | expand

Commit Message

Dan Carpenter Jan. 12, 2024, 6:56 a.m. UTC
The error message in this code can't be reached because value is either
zero or non-zero.  There isn't a third option.  Really, it's nicer to
write this as a one liner.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/platform/x86/silicom-platform.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Ilpo Järvinen Jan. 12, 2024, 8:29 a.m. UTC | #1
On Fri, 12 Jan 2024, Dan Carpenter wrote:

> The error message in this code can't be reached because value is either
> zero or non-zero.  There isn't a third option.  Really, it's nicer to
> write this as a one liner.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/platform/x86/silicom-platform.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/platform/x86/silicom-platform.c b/drivers/platform/x86/silicom-platform.c
> index 6ce43ccb3112..c0910af16a3a 100644
> --- a/drivers/platform/x86/silicom-platform.c
> +++ b/drivers/platform/x86/silicom-platform.c
> @@ -256,12 +256,7 @@ static void silicom_gpio_set(struct gpio_chip *gc,
>  	if (direction == GPIO_LINE_DIRECTION_IN)
>  		return;
>  
> -	if (value)
> -		silicom_mec_port_set(channel, 0);
> -	else if (value == 0)
> -		silicom_mec_port_set(channel, 1);
> -	else
> -		pr_err("Wrong argument value: %d\n", value);
> +	silicom_mec_port_set(channel, !value);
>  }
>  
>  static int silicom_gpio_direction_output(struct gpio_chip *gc,
> 

Thanks for the update,

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Ilpo Järvinen Jan. 24, 2024, 11:02 a.m. UTC | #2
On Fri, 12 Jan 2024 09:56:25 +0300, Dan Carpenter wrote:

> The error message in this code can't be reached because value is either
> zero or non-zero.  There isn't a third option.  Really, it's nicer to
> write this as a one liner.
> 
> 


Thank you for your contribution, it has been applied to my local
review-ilpo branch. Note it will show up in the public
platform-drivers-x86/review-ilpo branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86: silicom-platform: clean up a check
      commit: 890a48ca7b05406c538505a92148de7ab0d50591

--
 i.
diff mbox series

Patch

diff --git a/drivers/platform/x86/silicom-platform.c b/drivers/platform/x86/silicom-platform.c
index 6ce43ccb3112..c0910af16a3a 100644
--- a/drivers/platform/x86/silicom-platform.c
+++ b/drivers/platform/x86/silicom-platform.c
@@ -256,12 +256,7 @@  static void silicom_gpio_set(struct gpio_chip *gc,
 	if (direction == GPIO_LINE_DIRECTION_IN)
 		return;
 
-	if (value)
-		silicom_mec_port_set(channel, 0);
-	else if (value == 0)
-		silicom_mec_port_set(channel, 1);
-	else
-		pr_err("Wrong argument value: %d\n", value);
+	silicom_mec_port_set(channel, !value);
 }
 
 static int silicom_gpio_direction_output(struct gpio_chip *gc,