ChangeSet 1.1743.3.1, 2004/05/24 17:01:41-07:00, errandir_news@mph.eclipse.co.uk [PATCH] USB: usblp printer GET_DEVICE_ID fix There is a problem in the usblp GET_DEVICE_ID ioctl() implementation. The patch below (against 2.6 current) fixes the code to be according to the official usb printer spec. Most printers are not affected by this fix, as they use interface 0 and alternate 0. For those, nothing changes. But my printer/scanner uses interface 1 for the printer. drivers/usb/class/usblp.c | 21 +++++++++++++++++---- 1 files changed, 17 insertions(+), 4 deletions(-) diff -Nru a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c --- a/drivers/usb/class/usblp.c Fri May 28 14:41:50 2004 +++ b/drivers/usb/class/usblp.c Fri May 28 14:41:50 2004 @@ -226,11 +226,21 @@ 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 index = usblp->ifnum; + + /* High byte has the interface index. + Low byte has the alternate setting. + */ + if ((request == USBLP_REQ_GET_ID) && (type == USB_TYPE_CLASS)) { + index = (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); - dbg("usblp_control_msg: rq: 0x%02x dir: %d recip: %d value: %d len: %#x result: %d", - request, !!dir, recip, value, len, retval); + request, type | dir | recip, value, index, buf, len, USBLP_WRITE_TIMEOUT); + dbg("usblp_control_msg: rq: 0x%02x dir: %d recip: %d value: %d idx: %d len: %#x result: %d", + request, !!dir, recip, value, index, len, retval); return retval < 0 ? retval : 0; } @@ -439,6 +449,9 @@ retval = -ENODEV; goto done; } + + dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd), + _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd) ); if (_IOC_TYPE(cmd) == 'P') /* new-style ioctl number */