Message ID | 0402e613-446a-40d1-b676-0422f6223aa8@moroto.mountain (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | platform/x86: silicom-platform: clean up a check | expand |
On Wed, 10 Jan 2024, Dan Carpenter wrote: > "value" is either non-zero, or zero. There isn't a third option. > Delete the unnecessary code. > > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> > --- > drivers/platform/x86/silicom-platform.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/platform/x86/silicom-platform.c b/drivers/platform/x86/silicom-platform.c > index 6ce43ccb3112..5cac698bf98d 100644 > --- a/drivers/platform/x86/silicom-platform.c > +++ b/drivers/platform/x86/silicom-platform.c > @@ -258,10 +258,8 @@ static void silicom_gpio_set(struct gpio_chip *gc, > > 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, 1); This covers both cases without if: silicom_mec_port_set(channel, !value);
On Thu, Jan 11, 2024 at 01:56:28PM +0200, Ilpo Järvinen wrote: > On Wed, 10 Jan 2024, Dan Carpenter wrote: > > > "value" is either non-zero, or zero. There isn't a third option. > > Delete the unnecessary code. > > > > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> > > --- > > drivers/platform/x86/silicom-platform.c | 4 +--- > > 1 file changed, 1 insertion(+), 3 deletions(-) > > > > diff --git a/drivers/platform/x86/silicom-platform.c b/drivers/platform/x86/silicom-platform.c > > index 6ce43ccb3112..5cac698bf98d 100644 > > --- a/drivers/platform/x86/silicom-platform.c > > +++ b/drivers/platform/x86/silicom-platform.c > > @@ -258,10 +258,8 @@ static void silicom_gpio_set(struct gpio_chip *gc, > > > > 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, 1); > > This covers both cases without if: > > silicom_mec_port_set(channel, !value); > True. Let me resend it that way. regards, dan carpenter
diff --git a/drivers/platform/x86/silicom-platform.c b/drivers/platform/x86/silicom-platform.c index 6ce43ccb3112..5cac698bf98d 100644 --- a/drivers/platform/x86/silicom-platform.c +++ b/drivers/platform/x86/silicom-platform.c @@ -258,10 +258,8 @@ static void silicom_gpio_set(struct gpio_chip *gc, 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, 1); } static int silicom_gpio_direction_output(struct gpio_chip *gc,
"value" is either non-zero, or zero. There isn't a third option. Delete the unnecessary code. Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> --- drivers/platform/x86/silicom-platform.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)