All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: qcom: spmi-gpio: Assign boolean values to a bool variable
@ 2021-01-20  7:29 Jiapeng Zhong
  2021-01-21  3:19 ` Bjorn Andersson
  0 siblings, 1 reply; 3+ messages in thread
From: Jiapeng Zhong @ 2021-01-20  7:29 UTC (permalink / raw)
  To: agross
  Cc: bjorn.andersson, linus.walleij, linux-arm-msm, linux-gpio,
	linux-kernel, Jiapeng Zhong

Fix the following coccicheck warnings:

./drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c:340:3-15: WARNING:
Assignment of 0/1 to bool variable.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Zhong <abaci-bugfix@linux.alibaba.com>
---
 drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
index b5949f7..eb0b60c 100644
--- a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
+++ b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
@@ -331,13 +331,13 @@ static int pm8xxx_pin_config_set(struct pinctrl_dev *pctldev,
 		case PIN_CONFIG_BIAS_DISABLE:
 			pin->bias = PM8XXX_GPIO_BIAS_NP;
 			banks |= BIT(2);
-			pin->disable = 0;
+			pin->disable = false;
 			banks |= BIT(3);
 			break;
 		case PIN_CONFIG_BIAS_PULL_DOWN:
 			pin->bias = PM8XXX_GPIO_BIAS_PD;
 			banks |= BIT(2);
-			pin->disable = 0;
+			pin->disable = false;
 			banks |= BIT(3);
 			break;
 		case PM8XXX_QCOM_PULL_UP_STRENGTH:
@@ -350,11 +350,11 @@ static int pm8xxx_pin_config_set(struct pinctrl_dev *pctldev,
 		case PIN_CONFIG_BIAS_PULL_UP:
 			pin->bias = pin->pull_up_strength;
 			banks |= BIT(2);
-			pin->disable = 0;
+			pin->disable = false;
 			banks |= BIT(3);
 			break;
 		case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
-			pin->disable = 1;
+			pin->disable = true;
 			banks |= BIT(3);
 			break;
 		case PIN_CONFIG_INPUT_ENABLE:
-- 
1.8.3.1


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

* Re: [PATCH] pinctrl: qcom: spmi-gpio: Assign boolean values to a bool variable
  2021-01-20  7:29 [PATCH] pinctrl: qcom: spmi-gpio: Assign boolean values to a bool variable Jiapeng Zhong
@ 2021-01-21  3:19 ` Bjorn Andersson
  2021-01-22 13:16   ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Andersson @ 2021-01-21  3:19 UTC (permalink / raw)
  To: Jiapeng Zhong
  Cc: agross, linus.walleij, linux-arm-msm, linux-gpio, linux-kernel

On Wed 20 Jan 01:29 CST 2021, Jiapeng Zhong wrote:

> Fix the following coccicheck warnings:
> 
> ./drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c:340:3-15: WARNING:
> Assignment of 0/1 to bool variable.
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Zhong <abaci-bugfix@linux.alibaba.com>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Although we're mixing bool/int on line 417 and 637 as well, with:

	val |= pin->disable;

and

	pin->disable = val & BIT(0);

respectively. The latter could be dealt with using !!(val & BIT(0)); I
guess the appropriate for for the prior is:

	if (pin->disable)
		val |= BIT(0);

If you would like to update your patch with these as well I'd be happy
to review this.

Thanks,
Bjorn

> ---
>  drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
> index b5949f7..eb0b60c 100644
> --- a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
> +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
> @@ -331,13 +331,13 @@ static int pm8xxx_pin_config_set(struct pinctrl_dev *pctldev,
>  		case PIN_CONFIG_BIAS_DISABLE:
>  			pin->bias = PM8XXX_GPIO_BIAS_NP;
>  			banks |= BIT(2);
> -			pin->disable = 0;
> +			pin->disable = false;
>  			banks |= BIT(3);
>  			break;
>  		case PIN_CONFIG_BIAS_PULL_DOWN:
>  			pin->bias = PM8XXX_GPIO_BIAS_PD;
>  			banks |= BIT(2);
> -			pin->disable = 0;
> +			pin->disable = false;
>  			banks |= BIT(3);
>  			break;
>  		case PM8XXX_QCOM_PULL_UP_STRENGTH:
> @@ -350,11 +350,11 @@ static int pm8xxx_pin_config_set(struct pinctrl_dev *pctldev,
>  		case PIN_CONFIG_BIAS_PULL_UP:
>  			pin->bias = pin->pull_up_strength;
>  			banks |= BIT(2);
> -			pin->disable = 0;
> +			pin->disable = false;
>  			banks |= BIT(3);
>  			break;
>  		case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
> -			pin->disable = 1;
> +			pin->disable = true;
>  			banks |= BIT(3);
>  			break;
>  		case PIN_CONFIG_INPUT_ENABLE:
> -- 
> 1.8.3.1
> 

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

* Re: [PATCH] pinctrl: qcom: spmi-gpio: Assign boolean values to a bool variable
  2021-01-21  3:19 ` Bjorn Andersson
@ 2021-01-22 13:16   ` Linus Walleij
  0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2021-01-22 13:16 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Jiapeng Zhong, Andy Gross, MSM, open list:GPIO SUBSYSTEM, linux-kernel

On Thu, Jan 21, 2021 at 4:19 AM Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> On Wed 20 Jan 01:29 CST 2021, Jiapeng Zhong wrote:
>
> > Fix the following coccicheck warnings:
> >
> > ./drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c:340:3-15: WARNING:
> > Assignment of 0/1 to bool variable.
> >
> > Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> > Signed-off-by: Jiapeng Zhong <abaci-bugfix@linux.alibaba.com>
>
> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
>
> Although we're mixing bool/int on line 417 and 637 as well, with:
>
>         val |= pin->disable;
>
> and
>
>         pin->disable = val & BIT(0);
>
> respectively. The latter could be dealt with using !!(val & BIT(0)); I
> guess the appropriate for for the prior is:
>
>         if (pin->disable)
>                 val |= BIT(0);
>
> If you would like to update your patch with these as well I'd be happy
> to review this.

I would opt for a respin with the above when we are anyways at it,
no hurry as it is no regression anyway.

Yours,
Linus Walleij

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

end of thread, other threads:[~2021-01-22 13:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20  7:29 [PATCH] pinctrl: qcom: spmi-gpio: Assign boolean values to a bool variable Jiapeng Zhong
2021-01-21  3:19 ` Bjorn Andersson
2021-01-22 13:16   ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.