diff mbox series

[1/3] usb: cdns3: ep0: fix the test mode set incorrectly

Message ID 20200623030918.8409-2-peter.chen@nxp.com (mailing list archive)
State Mainlined
Commit c0e2a0341cd8ccd213ffc6c7f9cd52a31466cba9
Headers show
Series usb: cdns3: bug-fixes for usb-linus | expand

Commit Message

Peter Chen June 23, 2020, 3:09 a.m. UTC
The 'tmode' is ctrl->wIndex, changing it as the real test
mode value for register assignment.

Cc: <stable@vger.kernel.org>
Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
 drivers/usb/cdns3/ep0.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Pawel Laszczak June 23, 2020, 6:45 a.m. UTC | #1
Hi,

Reviewed-by: Pawel Laszczak <pawell@cadence.com>
>
>
>The 'tmode' is ctrl->wIndex, changing it as the real test
>mode value for register assignment.
>
>Cc: <stable@vger.kernel.org>
>Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
>Reviewed-by: Jun Li <jun.li@nxp.com>
>Signed-off-by: Peter Chen <peter.chen@nxp.com>
>---
> drivers/usb/cdns3/ep0.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c
>index 2465a84e8fee..74a1ff5000ba 100644
>--- a/drivers/usb/cdns3/ep0.c
>+++ b/drivers/usb/cdns3/ep0.c
>@@ -327,7 +327,8 @@ static int cdns3_ep0_feature_handle_device(struct cdns3_device *priv_dev,
> 		if (!set || (tmode & 0xff) != 0)
> 			return -EINVAL;
>
>-		switch (tmode >> 8) {
>+		tmode >>= 8;
>+		switch (tmode) {

For me it's looks the same, but it's ok. 

> 		case TEST_J:
> 		case TEST_K:
> 		case TEST_SE0_NAK:
>--
>2.17.1
Peter Chen June 23, 2020, 7:01 a.m. UTC | #2
> >diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c index
> >2465a84e8fee..74a1ff5000ba 100644
> >--- a/drivers/usb/cdns3/ep0.c
> >+++ b/drivers/usb/cdns3/ep0.c
> >@@ -327,7 +327,8 @@ static int cdns3_ep0_feature_handle_device(struct
> cdns3_device *priv_dev,
> > 		if (!set || (tmode & 0xff) != 0)
> > 			return -EINVAL;
> >
> >-		switch (tmode >> 8) {
> >+		tmode >>= 8;
> >+		switch (tmode) {
> 
> For me it's looks the same, but it's ok.
> 

Pawel, please check the coming code, it uses tmode to set the register which
is incorrect before shift. (line 336)

328                 tmode >>= 8;
329                 switch (tmode) {
330                 case TEST_J:
331                 case TEST_K:
332                 case TEST_SE0_NAK:
333                 case TEST_PACKET:
334                         cdns3_set_register_bit(&priv_dev->regs->usb_cmd,
335                                                USB_CMD_STMODE |
336                                                USB_STS_TMODE_SEL(tmode - 1));
337                         break;

Peter
Pawel Laszczak June 23, 2020, 7:22 a.m. UTC | #3
>
>> >diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c index
>> >2465a84e8fee..74a1ff5000ba 100644
>> >--- a/drivers/usb/cdns3/ep0.c
>> >+++ b/drivers/usb/cdns3/ep0.c
>> >@@ -327,7 +327,8 @@ static int cdns3_ep0_feature_handle_device(struct
>> cdns3_device *priv_dev,
>> > 		if (!set || (tmode & 0xff) != 0)
>> > 			return -EINVAL;
>> >
>> >-		switch (tmode >> 8) {
>> >+		tmode >>= 8;
>> >+		switch (tmode) {
>>
>> For me it's looks the same, but it's ok.
>>
>
>Pawel, please check the coming code, it uses tmode to set the register which
>is incorrect before shift. (line 336)

Rigth, thanks for clarification.

>
>328                 tmode >>= 8;
>329                 switch (tmode) {
>330                 case TEST_J:
>331                 case TEST_K:
>332                 case TEST_SE0_NAK:
>333                 case TEST_PACKET:
>334                         cdns3_set_register_bit(&priv_dev->regs->usb_cmd,
>335                                                USB_CMD_STMODE |
>336                                                USB_STS_TMODE_SEL(tmode - 1));
>337                         break;
>
>Peter
diff mbox series

Patch

diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c
index 2465a84e8fee..74a1ff5000ba 100644
--- a/drivers/usb/cdns3/ep0.c
+++ b/drivers/usb/cdns3/ep0.c
@@ -327,7 +327,8 @@  static int cdns3_ep0_feature_handle_device(struct cdns3_device *priv_dev,
 		if (!set || (tmode & 0xff) != 0)
 			return -EINVAL;
 
-		switch (tmode >> 8) {
+		tmode >>= 8;
+		switch (tmode) {
 		case TEST_J:
 		case TEST_K:
 		case TEST_SE0_NAK: