Patch: usblp quirk for zebra printers
From: P. Christeas
Date: Wed May 21 2008 - 14:07:46 EST
Hi,
I guess such a quirk may be a little odd, but it has been a blocking point in
my system not being able to support more than one printer.
Please comment. (and cc. me)
From 2c87e2cbc8d33b49b6e7a20b9b85570840bb0e12 Mon Sep 17 00:00:00 2001
From: P.Christeas <p_christ@xxxxxx>
Date: Wed, 21 May 2008 20:47:52 +0300
Subject: [PATCH] USB: Quirk for Zebra printers not reporting their S/N.
Those printers (and maybe others) don't report their Serial
Number as a part of their IEEE1284 device id string. Thus,
printing backends like CUPS cannot select among multiple
devices at the same host.
Workaround this situation by appending the SN in usblp.c .
---
drivers/usb/class/usblp.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 0647164..a4d324b 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -210,6 +210,7 @@ struct quirk_printer_struct {
#define USBLP_QUIRK_BIDIR 0x1 /* reports bidir but requires unidirectional mode (no INs/reads) */
#define USBLP_QUIRK_USB_INIT 0x2 /* needs vendor USB init string */
#define USBLP_QUIRK_BAD_CLASS 0x4 /* descriptor uses vendor-specific Class or SubClass */
+#define USBLP_QUIRK_ID_NO_SERIAL 0x8 /* Printer does not report its serial no. in GET_ID request */
static const struct quirk_printer_struct quirk_printers[] = {
{ 0x03f0, 0x0004, USBLP_QUIRK_BIDIR }, /* HP DeskJet 895C */
@@ -227,6 +228,7 @@ static const struct quirk_printer_struct quirk_printers[] = {
{ 0x0409, 0xf1be, USBLP_QUIRK_BIDIR }, /* NEC Picty800 (HP OEM) */
{ 0x0482, 0x0010, USBLP_QUIRK_BIDIR }, /* Kyocera Mita FS 820, by zut <kernel@xxxxxx> */
{ 0x04b8, 0x0202, USBLP_QUIRK_BAD_CLASS }, /* Seiko Epson Receipt Printer M129C */
+ { 0x0a5f, 0x000a, USBLP_QUIRK_ID_NO_SERIAL }, /* Zebra printers don't report their serial */
{ 0, 0 }
};
@@ -1330,6 +1332,23 @@ static int usblp_cache_device_id_string(struct usblp *usblp)
length = 2;
else if (length >= USBLP_DEVICE_ID_SIZE)
length = USBLP_DEVICE_ID_SIZE - 1;
+
+ /* If printer doesn't report its serial, we append it */
+ if ((usblp->quirks & USBLP_QUIRK_ID_NO_SERIAL) && (usblp->dev->serial) &&
+ (length + strlen(usblp->dev->serial) + 5 <USBLP_DEVICE_ID_SIZE) ) {
+
+ if (usblp->device_id_string[length-1] != ';')
+ usblp->device_id_string[length++]= ';';
+
+ strcpy(&usblp->device_id_string[length],"SN:");
+ length+=3;
+ strcat(&usblp->device_id_string[length],usblp->dev->serial);
+ length += strlen(usblp->dev->serial);
+ usblp->device_id_string[length++]= ';';
+
+ *((__be16 *)usblp->device_id_string) = cpu_to_be16(length);
+ }
+
usblp->device_id_string[length] = '\0';
dbg("usblp%d Device ID string [len=%d]=\"%s\"",
--
1.5.4.3