Hi,
Does this patch to usb.c look ok?
We hacked hotplug badly to fit our needs. I will clean that up and
submit it to the hotplug list, hopefully this weekend.
The reason is, that coldplug must be finished with driver loading before
the booting proceeds.
(no printer.o == no printing == no fun) and so on
---------- Forwarded message ----------
Date: Mon, 30 Sep 2002 23:21:29 +0200 (METDST)
From: Jochen Karrer <[EMAIL PROTECTED]>
To: Andreas Klein <[EMAIL PROTECTED]>
Subject: hotplug dauert 9 Minuten
Hi,
"hotplug usb" needed about nine Minutes when booting SuSE-8.1.
The reason:
-----------
hotplug reads from /proc/bus/usb/devices line by line with the
shell builtin "read". The contents of this proc-file is dynamically
recreated on every read system call. This is 87 times on my
computer because my /proc/bus/usb/devices is 86 lines long.
The Device-Descriptor of my Scanner HP-4100C reports the existence
of a Product-String and a Manufacturer string. So the scanner is
queried 86 times for the Manufacturer string and for the Product string.
The function usb_get_string in usb.c is always called with a stringlen of
255 Bytes. The scanner doesn't like this request because the stringlen is
only 10-20 Bytes. It doesn't respond. So I have to wait for the
timeout 87*2 * 3 seconds.
The solutions:
---------------
Query for stringlen before reading a string in usb.c (patch to kernel appended)
Do not cause one "read" systemcall per line when reading /proc/bus/usb/devices
with the shell-builtin "read". Instead use "cat" and read
from pipe. (patch appended) This causes only 2 systemcalls.
Jochen Karrer
Content-Description: usb kernel patch
--- drivers/usb/usb.c.orig 2002-09-30 21:12:23.000000000 +0200
+++ drivers/usb/usb.c 2002-09-30 21:25:21.000000000 +0200
@@ -2121,7 +2121,7 @@
int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
{
unsigned char *tbuf;
- int err;
+ int err, len;
unsigned int u, idx;
if (size <= 0 || !buf || !index)
@@ -2151,10 +2151,15 @@
}
/*
- * Just ask for a maximum length string and then take the length
- * that was returned.
+ * ask for the length of the string
*/
- err = usb_get_string(dev, dev->string_langid, index, tbuf, 255);
+
+ err = usb_get_string(dev, dev->string_langid, index, tbuf, 2);
+ if(err<2)
+ goto errout;
+ len=tbuf[0];
+
+ err = usb_get_string(dev, dev->string_langid, index, tbuf, len);
if (err < 0)
goto errout;
Content-Description: hotplug patch
--- hotplug/usb.rc.orig 2002-09-30 21:44:41.000000000 +0200
+++ hotplug/usb.rc 2002-09-30 08:28:43.000000000 +0200
@@ -138,14 +138,14 @@
# wc -l) * 2 + 1 + $HOTPLUG_USB_DELAY]
# for i in `seq 1 $HOTPLUG_USB_DELAY` ; do echo -n . >&3 ; sleep 1 ; done
sleep "$HOTPLUG_USB_DELAY"
- while read LINE; do
+ cat /proc/bus/usb/devices | (while read LINE; do
case $LINE in
I:*Driver=*none*)
echo -n . >&3 ; sleep 1
echo -n . >&3 ; sleep 1
;;
esac
- done < /proc/bus/usb/devices
+ done)
# we did everything we could ...
return 0
----- End forwarded message -----
--
$ man clone
BUGS
Main feature not yet implemented...
-------------------------------------------------------
This sf.net email is sponsored by: DEDICATED SERVERS only $89!
Linux or FreeBSD, FREE setup, FAST network. Get your own server
today at http://www.ServePath.com/indexfm.htm
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel