* [PATCH] usb: misc: ehset: fix wrong if condition
@ 2023-07-05 9:52 Xu Yang
2023-07-26 1:54 ` Xu Yang
0 siblings, 1 reply; 4+ messages in thread
From: Xu Yang @ 2023-07-05 9:52 UTC (permalink / raw)
To: gregkh; +Cc: heghedus.razvan, linux-usb, linux-imx, jun.li, xu.yang_2
A negative number from ret means the host controller had failed to send
usb message and 0 means succeed. Therefore, the if logic is wrong here
and this patch will fix it.
Fixes: f2b42379c576 ("usb: misc: ehset: Rework test mode entry")
cc: <stable@vger.kernel.org>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
drivers/usb/misc/ehset.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/misc/ehset.c b/drivers/usb/misc/ehset.c
index 986d6589f053..36b6e9fa7ffb 100644
--- a/drivers/usb/misc/ehset.c
+++ b/drivers/usb/misc/ehset.c
@@ -77,7 +77,7 @@ static int ehset_probe(struct usb_interface *intf,
switch (test_pid) {
case TEST_SE0_NAK_PID:
ret = ehset_prepare_port_for_testing(hub_udev, portnum);
- if (!ret)
+ if (ret < 0)
break;
ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
USB_RT_PORT, USB_PORT_FEAT_TEST,
@@ -86,7 +86,7 @@ static int ehset_probe(struct usb_interface *intf,
break;
case TEST_J_PID:
ret = ehset_prepare_port_for_testing(hub_udev, portnum);
- if (!ret)
+ if (ret < 0)
break;
ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
USB_RT_PORT, USB_PORT_FEAT_TEST,
@@ -95,7 +95,7 @@ static int ehset_probe(struct usb_interface *intf,
break;
case TEST_K_PID:
ret = ehset_prepare_port_for_testing(hub_udev, portnum);
- if (!ret)
+ if (ret < 0)
break;
ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
USB_RT_PORT, USB_PORT_FEAT_TEST,
@@ -104,7 +104,7 @@ static int ehset_probe(struct usb_interface *intf,
break;
case TEST_PACKET_PID:
ret = ehset_prepare_port_for_testing(hub_udev, portnum);
- if (!ret)
+ if (ret < 0)
break;
ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
USB_RT_PORT, USB_PORT_FEAT_TEST,
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] usb: misc: ehset: fix wrong if condition
2023-07-05 9:52 [PATCH] usb: misc: ehset: fix wrong if condition Xu Yang
@ 2023-07-26 1:54 ` Xu Yang
2023-07-26 3:57 ` gregkh
0 siblings, 1 reply; 4+ messages in thread
From: Xu Yang @ 2023-07-26 1:54 UTC (permalink / raw)
To: gregkh@linuxfoundation.org
Cc: heghedus.razvan@gmail.com, linux-usb@vger.kernel.org,
dl-linux-imx, Jun Li
> -----Original Message-----
>
> A negative number from ret means the host controller had failed to send
> usb message and 0 means succeed. Therefore, the if logic is wrong here
> and this patch will fix it.
>
> Fixes: f2b42379c576 ("usb: misc: ehset: Rework test mode entry")
> cc: <stable@vger.kernel.org>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
> drivers/usb/misc/ehset.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/misc/ehset.c b/drivers/usb/misc/ehset.c
> index 986d6589f053..36b6e9fa7ffb 100644
> --- a/drivers/usb/misc/ehset.c
> +++ b/drivers/usb/misc/ehset.c
> @@ -77,7 +77,7 @@ static int ehset_probe(struct usb_interface *intf,
> switch (test_pid) {
> case TEST_SE0_NAK_PID:
> ret = ehset_prepare_port_for_testing(hub_udev, portnum);
> - if (!ret)
> + if (ret < 0)
> break;
> ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
> USB_RT_PORT, USB_PORT_FEAT_TEST,
> @@ -86,7 +86,7 @@ static int ehset_probe(struct usb_interface *intf,
> break;
> case TEST_J_PID:
> ret = ehset_prepare_port_for_testing(hub_udev, portnum);
> - if (!ret)
> + if (ret < 0)
> break;
> ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
> USB_RT_PORT, USB_PORT_FEAT_TEST,
> @@ -95,7 +95,7 @@ static int ehset_probe(struct usb_interface *intf,
> break;
> case TEST_K_PID:
> ret = ehset_prepare_port_for_testing(hub_udev, portnum);
> - if (!ret)
> + if (ret < 0)
> break;
> ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
> USB_RT_PORT, USB_PORT_FEAT_TEST,
> @@ -104,7 +104,7 @@ static int ehset_probe(struct usb_interface *intf,
> break;
> case TEST_PACKET_PID:
> ret = ehset_prepare_port_for_testing(hub_udev, portnum);
> - if (!ret)
> + if (ret < 0)
> break;
> ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
> USB_RT_PORT, USB_PORT_FEAT_TEST,
> --
> 2.34.1
A gentle ping.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: misc: ehset: fix wrong if condition
2023-07-26 1:54 ` Xu Yang
@ 2023-07-26 3:57 ` gregkh
2023-07-26 5:10 ` [EXT] " Xu Yang
0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2023-07-26 3:57 UTC (permalink / raw)
To: Xu Yang
Cc: heghedus.razvan@gmail.com, linux-usb@vger.kernel.org,
dl-linux-imx, Jun Li
On Wed, Jul 26, 2023 at 01:54:15AM +0000, Xu Yang wrote:
> > -----Original Message-----
> >
> > A negative number from ret means the host controller had failed to send
> > usb message and 0 means succeed. Therefore, the if logic is wrong here
> > and this patch will fix it.
> >
> > Fixes: f2b42379c576 ("usb: misc: ehset: Rework test mode entry")
> > cc: <stable@vger.kernel.org>
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > ---
> > drivers/usb/misc/ehset.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/usb/misc/ehset.c b/drivers/usb/misc/ehset.c
> > index 986d6589f053..36b6e9fa7ffb 100644
> > --- a/drivers/usb/misc/ehset.c
> > +++ b/drivers/usb/misc/ehset.c
> > @@ -77,7 +77,7 @@ static int ehset_probe(struct usb_interface *intf,
> > switch (test_pid) {
> > case TEST_SE0_NAK_PID:
> > ret = ehset_prepare_port_for_testing(hub_udev, portnum);
> > - if (!ret)
> > + if (ret < 0)
> > break;
> > ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
> > USB_RT_PORT, USB_PORT_FEAT_TEST,
> > @@ -86,7 +86,7 @@ static int ehset_probe(struct usb_interface *intf,
> > break;
> > case TEST_J_PID:
> > ret = ehset_prepare_port_for_testing(hub_udev, portnum);
> > - if (!ret)
> > + if (ret < 0)
> > break;
> > ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
> > USB_RT_PORT, USB_PORT_FEAT_TEST,
> > @@ -95,7 +95,7 @@ static int ehset_probe(struct usb_interface *intf,
> > break;
> > case TEST_K_PID:
> > ret = ehset_prepare_port_for_testing(hub_udev, portnum);
> > - if (!ret)
> > + if (ret < 0)
> > break;
> > ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
> > USB_RT_PORT, USB_PORT_FEAT_TEST,
> > @@ -104,7 +104,7 @@ static int ehset_probe(struct usb_interface *intf,
> > break;
> > case TEST_PACKET_PID:
> > ret = ehset_prepare_port_for_testing(hub_udev, portnum);
> > - if (!ret)
> > + if (ret < 0)
> > break;
> > ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
> > USB_RT_PORT, USB_PORT_FEAT_TEST,
> > --
> > 2.34.1
>
> A gentle ping.
Have you teted this? It feels odd that the code could be that broken,
how did it ever work in the first place?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [EXT] Re: [PATCH] usb: misc: ehset: fix wrong if condition
2023-07-26 3:57 ` gregkh
@ 2023-07-26 5:10 ` Xu Yang
0 siblings, 0 replies; 4+ messages in thread
From: Xu Yang @ 2023-07-26 5:10 UTC (permalink / raw)
To: gregkh@linuxfoundation.org
Cc: heghedus.razvan@gmail.com, linux-usb@vger.kernel.org,
dl-linux-imx, Jun Li
Hi Greg,
> On Wed, Jul 26, 2023 at 01:54:15AM +0000, Xu Yang wrote:
> > > -----Original Message-----
> > >
> > > A negative number from ret means the host controller had failed to send
> > > usb message and 0 means succeed. Therefore, the if logic is wrong here
> > > and this patch will fix it.
> > >
> > > Fixes: f2b42379c576 ("usb: misc: ehset: Rework test mode entry")
> > > cc: <stable@vger.kernel.org>
> > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > > ---
> > > drivers/usb/misc/ehset.c | 8 ++++----
> > > 1 file changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/usb/misc/ehset.c b/drivers/usb/misc/ehset.c
> > > index 986d6589f053..36b6e9fa7ffb 100644
> > > --- a/drivers/usb/misc/ehset.c
> > > +++ b/drivers/usb/misc/ehset.c
> > > @@ -77,7 +77,7 @@ static int ehset_probe(struct usb_interface *intf,
> > > switch (test_pid) {
> > > case TEST_SE0_NAK_PID:
> > > ret = ehset_prepare_port_for_testing(hub_udev, portnum);
> > > - if (!ret)
> > > + if (ret < 0)
> > > break;
> > > ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
> > > USB_RT_PORT, USB_PORT_FEAT_TEST,
> > > @@ -86,7 +86,7 @@ static int ehset_probe(struct usb_interface *intf,
> > > break;
> > > case TEST_J_PID:
> > > ret = ehset_prepare_port_for_testing(hub_udev, portnum);
> > > - if (!ret)
> > > + if (ret < 0)
> > > break;
> > > ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
> > > USB_RT_PORT, USB_PORT_FEAT_TEST,
> > > @@ -95,7 +95,7 @@ static int ehset_probe(struct usb_interface *intf,
> > > break;
> > > case TEST_K_PID:
> > > ret = ehset_prepare_port_for_testing(hub_udev, portnum);
> > > - if (!ret)
> > > + if (ret < 0)
> > > break;
> > > ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
> > > USB_RT_PORT, USB_PORT_FEAT_TEST,
> > > @@ -104,7 +104,7 @@ static int ehset_probe(struct usb_interface *intf,
> > > break;
> > > case TEST_PACKET_PID:
> > > ret = ehset_prepare_port_for_testing(hub_udev, portnum);
> > > - if (!ret)
> > > + if (ret < 0)
> > > break;
> > > ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
> > > USB_RT_PORT, USB_PORT_FEAT_TEST,
> > > --
> > > 2.34.1
> >
> > A gentle ping.
>
> Have you teted this? It feels odd that the code could be that broken,
> how did it ever work in the first place?
Yes, I tested this patch and it works. If without this patch , the driver will skip
sending USB_PORT_FEAT_TEST packet even though USB_PORT_FEAT_SUSPEND
packet is successful.
You can also check the original handling of TEST_HS_HOST_PORT_SUSPEND_RESUME:
114 case TEST_HS_HOST_PORT_SUSPEND_RESUME:
115 /* Test: wait for 15secs -> suspend -> 15secs delay -> resume */
116 msleep(15 * 1000);
117 ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE,
118 USB_RT_PORT, USB_PORT_FEAT_SUSPEND,
119 portnum, NULL, 0, 1000, GFP_KERNEL);
120 if (ret < 0)
121 break;
This patch will align to this if condition. I also wonder why no one report this issue.
Thanks,
Xu Yang
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-26 5:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-05 9:52 [PATCH] usb: misc: ehset: fix wrong if condition Xu Yang
2023-07-26 1:54 ` Xu Yang
2023-07-26 3:57 ` gregkh
2023-07-26 5:10 ` [EXT] " Xu Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox