linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] USB: serial: pl2303: fix HX type detection
       [not found] <YQPsgPey1V+7ccGq@hovoldconsulting.com>
@ 2021-07-30 12:21 ` Johan Hovold
  2021-07-30 12:29   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Hovold @ 2021-07-30 12:21 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Charles Yeh, Yeh.Charles [葉榮鑫],
	linux-usb, linux-kernel, Chris, stable

The device release number for HX-type devices is configurable in
EEPROM/OTPROM and cannot be used reliably for type detection.

Assume all (non-H) devices with bcdUSB 1.1 and unknown bcdDevice to be
of HX type while adding a bcdDevice check for HXD and TB (1.1 and 2.0,
respectively).

Reported-by: Chris <chris@cyber-anlage.de>
Fixes: 8a7bf7510d1f ("USB: serial: pl2303: amend and tighten type detection")
Cc: stable@vger.kernel.org	# 5.13
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/serial/pl2303.c | 41 ++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 2f2f5047452b..17601e32083e 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -418,24 +418,33 @@ static int pl2303_detect_type(struct usb_serial *serial)
 	bcdDevice = le16_to_cpu(desc->bcdDevice);
 	bcdUSB = le16_to_cpu(desc->bcdUSB);
 
-	switch (bcdDevice) {
-	case 0x100:
-		/*
-		 * Assume it's an HXN-type if the device doesn't support the old read
-		 * request value.
-		 */
-		if (bcdUSB == 0x200 && !pl2303_supports_hx_status(serial))
-			return TYPE_HXN;
+	switch (bcdUSB) {
+	case 0x110:
+		switch (bcdDevice) {
+		case 0x300:
+			return TYPE_HX;
+		case 0x400:
+			return TYPE_HXD;
+		default:
+			return TYPE_HX;
+		}
 		break;
-	case 0x300:
-		if (bcdUSB == 0x200)
+	case 0x200:
+		switch (bcdDevice) {
+		case 0x100:
+			/*
+			 * Assume it's an HXN-type if the device doesn't
+			 * support the old read request value.
+			 */
+			if (!pl2303_supports_hx_status(serial))
+				return TYPE_HXN;
+			break;
+		case 0x300:
 			return TYPE_TA;
-
-		return TYPE_HX;
-	case 0x400:
-		return TYPE_HXD;
-	case 0x500:
-		return TYPE_TB;
+		case 0x500:
+			return TYPE_TB;
+		}
+		break;
 	}
 
 	dev_err(&serial->interface->dev,
-- 
2.31.1


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

* Re: [PATCH] USB: serial: pl2303: fix HX type detection
  2021-07-30 12:21 ` [PATCH] USB: serial: pl2303: fix HX type detection Johan Hovold
@ 2021-07-30 12:29   ` Greg KH
  2021-07-30 15:11     ` Johan Hovold
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2021-07-30 12:29 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Charles Yeh, Yeh.Charles [葉榮鑫],
	linux-usb, linux-kernel, Chris, stable

On Fri, Jul 30, 2021 at 02:21:56PM +0200, Johan Hovold wrote:
> The device release number for HX-type devices is configurable in
> EEPROM/OTPROM and cannot be used reliably for type detection.
> 
> Assume all (non-H) devices with bcdUSB 1.1 and unknown bcdDevice to be
> of HX type while adding a bcdDevice check for HXD and TB (1.1 and 2.0,
> respectively).
> 
> Reported-by: Chris <chris@cyber-anlage.de>
> Fixes: 8a7bf7510d1f ("USB: serial: pl2303: amend and tighten type detection")
> Cc: stable@vger.kernel.org	# 5.13
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/usb/serial/pl2303.c | 41 ++++++++++++++++++++++---------------
>  1 file changed, 25 insertions(+), 16 deletions(-)
> 

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH] USB: serial: pl2303: fix HX type detection
  2021-07-30 12:29   ` Greg KH
@ 2021-07-30 15:11     ` Johan Hovold
  0 siblings, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2021-07-30 15:11 UTC (permalink / raw)
  To: Greg KH
  Cc: Charles Yeh, Yeh.Charles [葉榮鑫],
	linux-usb, linux-kernel, Chris, stable

On Fri, Jul 30, 2021 at 02:29:55PM +0200, Greg Kroah-Hartman wrote:
> On Fri, Jul 30, 2021 at 02:21:56PM +0200, Johan Hovold wrote:
> > The device release number for HX-type devices is configurable in
> > EEPROM/OTPROM and cannot be used reliably for type detection.
> > 
> > Assume all (non-H) devices with bcdUSB 1.1 and unknown bcdDevice to be
> > of HX type while adding a bcdDevice check for HXD and TB (1.1 and 2.0,
> > respectively).
> > 
> > Reported-by: Chris <chris@cyber-anlage.de>
> > Fixes: 8a7bf7510d1f ("USB: serial: pl2303: amend and tighten type detection")
> > Cc: stable@vger.kernel.org	# 5.13
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> > ---
> >  drivers/usb/serial/pl2303.c | 41 ++++++++++++++++++++++---------------
> >  1 file changed, 25 insertions(+), 16 deletions(-)
> > 
> 
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Thanks for reviewing. Now applied.

Johan

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

end of thread, other threads:[~2021-07-30 15:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <YQPsgPey1V+7ccGq@hovoldconsulting.com>
2021-07-30 12:21 ` [PATCH] USB: serial: pl2303: fix HX type detection Johan Hovold
2021-07-30 12:29   ` Greg KH
2021-07-30 15:11     ` Johan Hovold

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).