This is a repost of a patch I sent to the linux-usb-devel list ~4 months
ago.

The patch updates the wIndex field for the printer class GET_DEVICE_ID
control request to take into account the interface and alternate
numbers. As per the printer class spec, for GET_DEVICE_ID requests, the
high byte is the device interface and the low byte is the alternate.

The current code ignores the alternate, and sticks the interface number
in the low byte... which works fine for other printer class requests.
With GET_DEVICE_ID we're just getting lucky that most printers are 0/0
for alternate/interface, so it doesn't matter.

Attached is a patch which will fill in the alternate/interface numbers
for GET_DEVICE_ID requests.

A patch for 2.4.23-pre2 will follow shortly.

-- 
Adam Lazur, Cluster Monkey
Binary files linux-2.6.0-test4.vanilla/drivers/usb/class/.usblp.c.swp and 
linux-2.6.0-test4/drivers/usb/class/.usblp.c.swp differ
diff -uNr linux-2.6.0-test4.vanilla/drivers/usb/class/usblp.c 
linux-2.6.0-test4/drivers/usb/class/usblp.c
--- linux-2.6.0-test4.vanilla/drivers/usb/class/usblp.c 2003-08-22 19:52:57.000000000 
-0400
+++ linux-2.6.0-test4/drivers/usb/class/usblp.c 2003-09-02 10:44:20.000000000 -0400
@@ -222,9 +222,15 @@
 
 static int usblp_ctrl_msg(struct usblp *usblp, int request, int type, int dir, int 
recip, int value, void *buf, int len)
 {
-       int retval = usb_control_msg(usblp->dev,
+       int retval;
+       int wIndex = usblp->ifnum;
+       if (request == USBLP_REQ_GET_ID)
+               wIndex = (usblp->ifnum << 8) |
+                       usblp->protocol[usblp->current_protocol].alt_setting;
+
+       retval = usb_control_msg(usblp->dev,
                dir ? usb_rcvctrlpipe(usblp->dev, 0) : usb_sndctrlpipe(usblp->dev, 0),
-               request, type | dir | recip, value, usblp->ifnum, buf, len, 
USBLP_WRITE_TIMEOUT);
+               request, type | dir | recip, value, wIndex, buf, len, 
USBLP_WRITE_TIMEOUT);
        dbg("usblp_control_msg: rq: 0x%02x dir: %d recip: %d value: %d len: %#x 
result: %d",
                request, !!dir, recip, value, len, retval);
        return retval < 0 ? retval : 0;

Reply via email to