* [PATCH] sr: dwc2/gadget: remove unneccessary if
@ 2020-06-06 15:37 Pavel Machek
2020-06-06 15:45 ` Minas Harutyunyan
0 siblings, 1 reply; 4+ messages in thread
From: Pavel Machek @ 2020-06-06 15:37 UTC (permalink / raw)
To: hminas, gregkh, linux-usb, kernel list, trivial
[-- Attachment #1: Type: text/plain, Size: 791 bytes --]
We don't really need if/else to set variable to 1/0.
Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 12b98b466287..f9f6fd470c81 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1761,10 +1761,7 @@ static int dwc2_hsotg_process_req_feature(struct dwc2_hsotg *hsotg,
case USB_RECIP_DEVICE:
switch (wValue) {
case USB_DEVICE_REMOTE_WAKEUP:
- if (set)
- hsotg->remote_wakeup_allowed = 1;
- else
- hsotg->remote_wakeup_allowed = 0;
+ hsotg->remote_wakeup_allowed = set;
break;
case USB_DEVICE_TEST_MODE:
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] sr: dwc2/gadget: remove unneccessary if
2020-06-06 15:37 [PATCH] sr: dwc2/gadget: remove unneccessary if Pavel Machek
@ 2020-06-06 15:45 ` Minas Harutyunyan
2020-06-06 19:05 ` Pavel Machek
0 siblings, 1 reply; 4+ messages in thread
From: Minas Harutyunyan @ 2020-06-06 15:45 UTC (permalink / raw)
To: Pavel Machek, gregkh@linuxfoundation.org,
linux-usb@vger.kernel.org, kernel list, trivial@kernel.org
Hi Pavel,
On 6/6/2020 7:37 PM, Pavel Machek wrote:
> We don't really need if/else to set variable to 1/0.
>
> Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
>
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 12b98b466287..f9f6fd470c81 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -1761,10 +1761,7 @@ static int dwc2_hsotg_process_req_feature(struct dwc2_hsotg *hsotg,
> case USB_RECIP_DEVICE:
> switch (wValue) {
> case USB_DEVICE_REMOTE_WAKEUP:
> - if (set)
> - hsotg->remote_wakeup_allowed = 1;
> - else
> - hsotg->remote_wakeup_allowed = 0;
> + hsotg->remote_wakeup_allowed = set;
> break;
>
> case USB_DEVICE_TEST_MODE:
>
It's good catch, but 'set' declared as 'bool' while
'remote_wakeup_allowed' is 'unsigned int'. Maybe update 'set' type to same.
Thanks,
Minas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sr: dwc2/gadget: remove unneccessary if
2020-06-06 15:45 ` Minas Harutyunyan
@ 2020-06-06 19:05 ` Pavel Machek
2020-06-09 8:35 ` Minas Harutyunyan
0 siblings, 1 reply; 4+ messages in thread
From: Pavel Machek @ 2020-06-06 19:05 UTC (permalink / raw)
To: Minas Harutyunyan
Cc: Pavel Machek, gregkh@linuxfoundation.org,
linux-usb@vger.kernel.org, kernel list, trivial@kernel.org
[-- Attachment #1: Type: text/plain, Size: 1588 bytes --]
Hi!
> > We don't really need if/else to set variable to 1/0.
> >
> > Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
> >
> > diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> > index 12b98b466287..f9f6fd470c81 100644
> > --- a/drivers/usb/dwc2/gadget.c
> > +++ b/drivers/usb/dwc2/gadget.c
> > @@ -1761,10 +1761,7 @@ static int dwc2_hsotg_process_req_feature(struct dwc2_hsotg *hsotg,
> > case USB_RECIP_DEVICE:
> > switch (wValue) {
> > case USB_DEVICE_REMOTE_WAKEUP:
> > - if (set)
> > - hsotg->remote_wakeup_allowed = 1;
> > - else
> > - hsotg->remote_wakeup_allowed = 0;
> > + hsotg->remote_wakeup_allowed = set;
> > break;
> >
> > case USB_DEVICE_TEST_MODE:
> >
>
> It's good catch, but 'set' declared as 'bool' while
> 'remote_wakeup_allowed' is 'unsigned int'. Maybe update 'set' type to same.
I know set is bool. But that should not matter, code is okay and
compiler will do the right thing:
pavel@amd:/tmp$ cat delme.c
#include <stdbool.h>
void main(void)
{
bool a = false;
int b = a;
}
pavel@amd:/tmp$ gcc -std=c99 -Wall delme.c
delme.c:3:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
void main(void)
^
delme.c: In function ‘main’:
delme.c:6:7: warning: unused variable ‘b’
[-Wunused-variable]
int b = a;
^
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sr: dwc2/gadget: remove unneccessary if
2020-06-06 19:05 ` Pavel Machek
@ 2020-06-09 8:35 ` Minas Harutyunyan
0 siblings, 0 replies; 4+ messages in thread
From: Minas Harutyunyan @ 2020-06-09 8:35 UTC (permalink / raw)
To: Pavel Machek, Minas Harutyunyan
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
kernel list, trivial@kernel.org
Hi,
On 6/6/2020 11:05 PM, Pavel Machek wrote:
> Hi!
>
>>> We don't really need if/else to set variable to 1/0.
>>>
>>> Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
>>>
>>> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
>>> index 12b98b466287..f9f6fd470c81 100644
>>> --- a/drivers/usb/dwc2/gadget.c
>>> +++ b/drivers/usb/dwc2/gadget.c
>>> @@ -1761,10 +1761,7 @@ static int dwc2_hsotg_process_req_feature(struct dwc2_hsotg *hsotg,
>>> case USB_RECIP_DEVICE:
>>> switch (wValue) {
>>> case USB_DEVICE_REMOTE_WAKEUP:
>>> - if (set)
>>> - hsotg->remote_wakeup_allowed = 1;
>>> - else
>>> - hsotg->remote_wakeup_allowed = 0;
>>> + hsotg->remote_wakeup_allowed = set;
>>> break;
>>>
>>> case USB_DEVICE_TEST_MODE:
>>>
>>
>> It's good catch, but 'set' declared as 'bool' while
>> 'remote_wakeup_allowed' is 'unsigned int'. Maybe update 'set' type to same.
>
> I know set is bool. But that should not matter, code is okay and
> compiler will do the right thing:
>
> pavel@amd:/tmp$ cat delme.c
> #include <stdbool.h>
>
> void main(void)
> {
> bool a = false;
> int b = a;
> }
> pavel@amd:/tmp$ gcc -std=c99 -Wall delme.c
> delme.c:3:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
> void main(void)
> ^
> delme.c: In function ‘main’:
> delme.c:6:7: warning: unused variable ‘b’
> [-Wunused-variable]
> int b = a;
> ^
>
> Best regards,
> Pavel
>
To avoid any possible check patch issues update type of "set" from bool
to same as "remote_wakeup_allowed".
Please update your patch topic to "usb: dwc2: gadget: remove unnecessary
if" and resubmit.
Thanks,
Minas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-09 8:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-06 15:37 [PATCH] sr: dwc2/gadget: remove unneccessary if Pavel Machek
2020-06-06 15:45 ` Minas Harutyunyan
2020-06-06 19:05 ` Pavel Machek
2020-06-09 8:35 ` Minas Harutyunyan
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).