Skip to contentSkip to conversation

USB: usblp: don't call usb_set_interface if there's a single alt

PATCH In review Jeremy Figgins 2 participants 2 messages Jan 24, 2021 – Jan 25, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: usblp: don't call usb_set_interface if there's a single alt

Some devices, such as the Winbond Electronics Corp. Virtual Com Port (Vendor=0416, ProdId=5011), lockup when usb_set_interface() or usb_clear_halt() are called. This device has only a single altsetting, so it should not be necessary to call usb_set_interface().

---
An alternative fix was submitted previously as:

USB: usblp: add USBLP_QUIRK_NO_SETF_INTF flag

and this superscedes that patch. This is a different approach, so I submitted it as a new patch, rather than adding a v2 to the first one; I hope that was the correct thing to do in this case.

 drivers/usb/class/usblp.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/usb/class/usblp.c +11 -8
index 134dc2005ce9..c9f6e9758288 100644
@@ -1329,14 +1329,17 @@ static int usblp_set_protocol(struct usblp *usblp, int protocol)
 	if (protocol < USBLP_FIRST_PROTOCOL || protocol > USBLP_LAST_PROTOCOL)
 		return -EINVAL;
 
-	alts = usblp->protocol[protocol].alt_setting;
-	if (alts < 0)
-		return -EINVAL;
-	r = usb_set_interface(usblp->dev, usblp->ifnum, alts);
-	if (r < 0) {
-		printk(KERN_ERR "usblp: can't set desired altsetting %d on interface %d\n",
-			alts, usblp->ifnum);
-		return r;
+	/* Don't unnecessarily set the interface if there's a single alt. */
+	if (usblp->intf->num_altsetting > 1) {
+		alts = usblp->protocol[protocol].alt_setting;
+		if (alts < 0)
+			return -EINVAL;
+		r = usb_set_interface(usblp->dev, usblp->ifnum, alts);
+		if (r < 0) {
+			printk(KERN_ERR "usblp: can't set desired altsetting %d on interface %d\n",
+				alts, usblp->ifnum);
+			return r;
+		}
 	}
 
 	usblp->bidir = (usblp->protocol[protocol].epread != NULL);
Signature · 1 line
2.29.0
maintainer Acked-by on v1 1/1
#1 lore raw

drivers/usb/class/usblp.c static int usblp_set_protocol(struct usblp *usblp, int protocol) · line 1333

Quoted 4 lines · On Sat, 23 Jan 2021 18:21:36 -0600 Jeremy Figgins <[email protected]>…

+++ b/drivers/usb/class/usblp.c

drivers/usb/class/usblp.c +1 -0
+	if (usblp->intf->num_altsetting > 1) {

I am having some misgivings about it, but let's see if it works. At worst, someone will complain and we'll revert to quirks.

-- Pete