* [PATCH] usb: musb: davinci: change the variable type
@ 2021-04-18 18:36 Saurav Girepunje
2021-04-22 8:49 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Saurav Girepunje @ 2021-04-18 18:36 UTC (permalink / raw)
To: b-liu, gregkh, linux-usb, linux-kernel; +Cc: saurav.girepunje
vbus_state is define as bool but on davinci.c assigning a value
'-1' to the bool variable.
Fix the following coccicheck error:
drivers/usb/musb//davinci.c:532:2-18:
ERROR: Assignment of non-0/1 constant to bool variable
By changing the variable type to int.
As vbus_state need more three values/states more required by
vbus_state variable.
/* 0/1 vs "-1 == unknown/init" */
Signed-off-by: Saurav Girepunje <saurav.girepunje@google.com>
---
drivers/usb/musb/davinci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 704435526394..e3435621a9d9 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -36,7 +36,7 @@ struct davinci_glue {
struct device *dev;
struct platform_device *musb;
struct clk *clk;
- bool vbus_state;
+ int vbus_state;
struct gpio_desc *vbus;
struct work_struct vbus_work;
};
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: musb: davinci: change the variable type
2021-04-18 18:36 [PATCH] usb: musb: davinci: change the variable type Saurav Girepunje
@ 2021-04-22 8:49 ` Greg KH
2021-04-27 19:37 ` SAURAV GIREPUNJE
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2021-04-22 8:49 UTC (permalink / raw)
To: Saurav Girepunje; +Cc: b-liu, linux-usb, linux-kernel, saurav.girepunje
On Mon, Apr 19, 2021 at 12:06:18AM +0530, Saurav Girepunje wrote:
> vbus_state is define as bool but on davinci.c assigning a value
> '-1' to the bool variable.
Does it also test that value?
If so, shouldn't that logic error be fixed instead of working around it
by changing the variable type?
This feels wrong...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: musb: davinci: change the variable type
2021-04-22 8:49 ` Greg KH
@ 2021-04-27 19:37 ` SAURAV GIREPUNJE
0 siblings, 0 replies; 3+ messages in thread
From: SAURAV GIREPUNJE @ 2021-04-27 19:37 UTC (permalink / raw)
To: Greg KH; +Cc: b-liu, linux-usb, linux-kernel, saurav.girepunje
On Thu, Apr 22, 2021 at 10:49:10AM +0200, Greg KH wrote:
> On Mon, Apr 19, 2021 at 12:06:18AM +0530, Saurav Girepunje wrote:
> > vbus_state is define as bool but on davinci.c assigning a value
> > '-1' to the bool variable.
>
> Does it also test that value?
>
> If so, shouldn't that logic error be fixed instead of working around it
> by changing the variable type?
>
> This feels wrong...
>
> thanks,
>
> greg k-h
vbus_state is assign with the value of "-1" in davinci.c file.
However it check value whether it is zero or a non-zero.
This value pass On gpio lib function.Which need this value to bool only.
On below "glue->vbus_state" should be 1.
glue->vbus = devm_gpiod_get_optional(&pdev->dev, NULL, GPIOD_OUT_LOW);
if (IS_ERR(glue->vbus)) {
ret = PTR_ERR(glue->vbus);
goto err0;
} else {
glue->vbus_state = -1;
INIT_WORK(&glue->vbus_work, evm_deferred_drvvbus);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-27 19:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-18 18:36 [PATCH] usb: musb: davinci: change the variable type Saurav Girepunje
2021-04-22 8:49 ` Greg KH
2021-04-27 19:37 ` SAURAV GIREPUNJE
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).