From: Johan Hovold <johan@kernel.org>
To: linux-usb@vger.kernel.org
Cc: "Michael G. Katzmann" <michaelk@IEEE.org>,
"Charles Yeh" <charlesyeh522@gmail.com>,
"Yeh.Charles [葉榮鑫]" <charles-yeh@prolific.com.tw>,
"Johan Hovold" <johan@kernel.org>
Subject: [PATCH 4/5] USB: serial: pl2303: tighten type HXN (G) detection
Date: Thu, 11 Mar 2021 17:14:50 +0100 [thread overview]
Message-ID: <20210311161451.1496-5-johan@kernel.org> (raw)
In-Reply-To: <20210311161451.1496-1-johan@kernel.org>
Tighten the detection of the new HXN (G) type instead of assuming that
every device which doesn't support the old read request is an HXN.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/serial/pl2303.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index cd2acd8c5246..e742187c8a7f 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -374,12 +374,22 @@ static int pl2303_calc_num_ports(struct usb_serial *serial,
return 1;
}
+static bool pl2303_supports_hx_status(struct usb_serial *serial)
+{
+ int ret;
+ u8 buf;
+
+ ret = usb_control_msg_recv(serial->dev, 0, VENDOR_READ_REQUEST,
+ VENDOR_READ_REQUEST_TYPE, PL2303_READ_TYPE_HX_STATUS,
+ 0, &buf, 1, 100, GFP_KERNEL);
+
+ return ret == 0;
+}
+
static int pl2303_detect_type(struct usb_serial *serial)
{
struct usb_device_descriptor *desc = &serial->dev->descriptor;
u16 bcdDevice, bcdUSB;
- int ret;
- u8 buf;
/*
* Legacy PL2303H, variants 0 and 1 (difference unknown).
@@ -394,20 +404,18 @@ static int pl2303_detect_type(struct usb_serial *serial)
return TYPE_H; /* variant 0 */
}
- /*
- * Assume it's an HXN-type if the device doesn't support the old read
- * request value.
- */
- ret = usb_control_msg_recv(serial->dev, 0, VENDOR_READ_REQUEST,
- VENDOR_READ_REQUEST_TYPE, PL2303_READ_TYPE_HX_STATUS,
- 0, &buf, 1, 100, GFP_KERNEL);
- if (ret)
- return TYPE_HXN;
-
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;
+ break;
case 0x300:
if (bcdUSB == 0x200)
return TYPE_TA;
--
2.26.2
next prev parent reply other threads:[~2021-03-11 16:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 16:14 [PATCH 0/5] USB: serial: pl2303: amend device-type detection Johan Hovold
2021-03-11 16:14 ` [PATCH 1/5] USB: serial: pl2303: clean up type detection Johan Hovold
2021-03-11 16:14 ` [PATCH 2/5] USB: serial: pl2303: amend and tighten " Johan Hovold
2021-03-11 16:14 ` [PATCH 3/5] USB: serial: pl2303: rename legacy PL2303H type Johan Hovold
2021-03-11 16:14 ` Johan Hovold [this message]
2021-03-11 16:14 ` [PATCH 5/5] USB: serial: pl2303: add device-type names Johan Hovold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210311161451.1496-5-johan@kernel.org \
--to=johan@kernel.org \
--cc=charles-yeh@prolific.com.tw \
--cc=charlesyeh522@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=michaelk@IEEE.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.