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.

This is the 2.4.23-pre2 flavored version of the patch.

-- 
Adam Lazur, Cluster Monkey
diff -uNr linux-2.4.23-pre2.vanilla/drivers/usb/printer.c 
linux-2.4.23-pre2/drivers/usb/printer.c
--- linux-2.4.23-pre2.vanilla/drivers/usb/printer.c     2003-09-02 10:20:31.000000000 
-0400
+++ linux-2.4.23-pre2/drivers/usb/printer.c     2003-09-02 10:28:16.000000000 -0400
@@ -210,9 +210,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