mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usblp: Add serial number to device ID
@ 2006-12-12 15:00 Dirk Eibach
  0 siblings, 0 replies; only message in thread
From: Dirk Eibach @ 2006-12-12 15:00 UTC (permalink / raw)
  To: linux-usb-devel; +Cc: linux-kernel

I noticed that some USB-printers, e.g. Canon PIXMA iP3000 don't add
their serial number to the IEEE-1284 device ID string as expected by
userspace apps like cups.
Because of this, connecting multiple printers of the same type to a
system does not work properly.

This patch adds the usb serial number to the device ID if it is left
out by the printer.

This patch applies to kernel 2.6.18.

Signed-off-by: Dirk Eibach <eibach@gdsys.de>
---
--- a/drivers/usb/class/usblp.c	2006-09-20 05:42:06.000000000 +0200
+++ b/drivers/usb/class/usblp.c	2006-12-12 15:27:23.000000000 +0100
@@ -1134,6 +1134,18 @@ static int usblp_cache_device_id_string(
 		length = USBLP_DEVICE_ID_SIZE - 1;
 	usblp->device_id_string[length] = '\0';
 
+	/* Insert serial number into the device ID string if the printer
+	 * is braindead enough to leave it out. */
+	if ( (usblp->dev->serial)
+		&& (length + strlen(usblp->dev->serial) + 6 < USBLP_DEVICE_ID_SIZE)
+		&& !strstr(usblp->device_id_string+2, "SERN:")
+		&& !strstr(usblp->device_id_string+2, "SER:") )
+	{
+		sprintf(usblp->device_id_string+length, "SERN:%s;", usblp->dev->serial);
+		length += 6 + strlen(usblp->dev->serial);
+		*((__be16 *)usblp->device_id_string) = cpu_to_be16(length);
+	}
+
 	dbg("usblp%d Device ID string [len=%d]=\"%s\"",
 		usblp->minor, length, &usblp->device_id_string[2]);
 




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-12-12 15:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-12 15:00 [PATCH] usblp: Add serial number to device ID Dirk Eibach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®