From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olaf Hering Date: Sat, 07 Jun 2003 16:56:04 +0000 Subject: [PATCH] hotplug usb.rc changes Message-Id: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: linux-hotplug@vger.kernel.org A few updates for usb.rc: - do not use /etc/sysconfig/usb anymore, use /etc/sysconfig/hotplug instead - better check if usb was successfully activated - wait up to 3 seconds for active usb events - add two new /etc/sysconfig/hotplug variables: * use HOTPLUG_USB_HOSTCONTROLLER_LIST to load a fixed list of host controller drivers * use HOTPLUG_USB_STATIC_MODULES to load a fixed list of drivers (for input) Index: etc/hotplug/usb.rc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D--- etc/hotplug/usb.rc (revision 15) +++ etc/hotplug/usb.rc (revision 16) @@ -21,9 +21,6 @@ =20 PATH=3D/sbin:/bin:/usr/sbin:/usr/bin =20 -STATIC_MODULE_LIST-X11_USBMICE_HACK=FAlse - # source function library if [ -f /etc/init.d/functions ]; then . /etc/init.d/functions @@ -31,22 +28,6 @@ . /etc/rc.d/init.d/functions fi =20 - -# override any of the defaults above? -if [ -f /etc/sysconfig/usb ]; then - . /etc/sysconfig/usb -fi - - -MOUSE_MODULES=3D"mousedev input" - -# In its currently-recommended configuration, XFree86 3.3.6 always opens -# /dev/input/mice; so mousedev and input must be loaded before X11 starts. -if [ $X11_USBMICE_HACK =3D true ]; then - STATIC_MODULE_LIST=3D"$MOUSE_MODULES $STATIC_MODULE_LIST" -fi - - # # "COLD PLUG" ... recovery from partial USB init that may have happened # before the OS could really handle hotplug, perhaps because /sbin or @@ -109,8 +90,7 @@ =20 maybe_start_usb () { - local COUNT SYNTHESIZE - COUNT=3D0 + local SYNTHESIZE =20 # if USB is partially initted then synthesize "cold plug" events. the # kernel probably dropped many "hot plug" events, and those it didn't @@ -154,32 +134,16 @@ # FIXME: some of this should be driven by PCI hotplugging, and have # the blacklist control which uhci driver gets used (before 2.5). =20 - # "new style" HCDs ... more common code - modprobe -q ehci-hcd >/dev/null 2>&1 - modprobe -q ohci-hcd >/dev/null 2>&1 - modprobe -q uhci-hcd >/dev/null 2>&1 - - # "old style" HCDs ... more driver-specific bugs - modprobe -q usb-ohci >/dev/null 2>&1 - # NOTE: this prefers "uhci"; you may prefer "usb-uhci". - # modprobe -q usb-uhci >/dev/null 2>&1 || modprobe -q uhci >/dev/null = 2>&1 - modprobe -q uhci >/dev/null 2>&1 || modprobe -q usb-uhci >/dev/null 2>= &1 - - # ... add any non-PCI HCDS here. Examples include the - # CRIS usb-host, Philips ISP-1161, Symlogic 811HS, and so on. - # ohci-hcd can handle some non-pci variants. + # Load Host Controller Drivers (HCDs) specified in /etc/sysconfig/hotp= lug + for i in $HOTPLUG_USB_HOSTCONTROLLER_LIST ; do + modprobe -q $i >/dev/null 2>&1 && mesg "loaded HCD: $i" + done =20 if [ -d /proc/bus/usb ]; then # If we see there are no busses, we "failed" and # can report so even if we're partially nonmodular. - # - # NOTE: this fails on older kernels, where usbdevfs had two files - # ('devices' and 'drivers') with no hcds registered, but works on - # newer kernels where usbfs has zero files until hcds register, - # and might not have the 'drivers' file. - COUNT=3D`ls /proc/bus/usb | wc -l` - if [ $COUNT -lt 2 ]; then - umount /proc/bus/usb + if [ ! -d /proc/bus/usb/001 ] ; then + test -f /proc/bus/usb/devices && umount /proc/bus/usb rmmod usbcore >/dev/null 2>&1 return 1 fi @@ -199,10 +163,17 @@ =20 # Some modules are statically loaded, perhaps because they are # needed to activate filesystem device nodes. - for MODULE in $STATIC_MODULE_LIST; do + for MODULE in $HOTPLUG_USB_STATIC_MODULES ; do modprobe $MODULE done =20 + # there could be still some active hotplug events + # wait for them because other rc scripts may need the drivers + sleep 3 & DELAY_PID=3D$! + until [ "`ls /var/run/usb/*.queue.* 2>/dev/null`" =3D "" ] ; do + test -d /proc/$DELAY_PID || break + done + # we did everything we could ... return 0 } Index: etc/sysconfig/hotplug =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D--- etc/sysconfig/hotplug (revision 15) +++ etc/sysconfig/hotplug (revision 16) @@ -3,3 +3,16 @@ # Enable debugging for all hotplug actions? yes/no # HOTPLUG_DEBUG=3Dno +##################################################################### +# +# The hostcontroller drivers will be probed in that order +# It is useful for the uhci/usb-uhci battle +# +HOTPLUG_USB_HOSTCONTROLLER_LIST=3D"ehci-hcd ohci-hcd uhci-hcd usb-ohci usb= -uhci uhci" +##################################################################### +# +# These modules will be loaded when usb hotplug starts. These are at least +# modules for which no hotplug events is created e.g. input devices +# If you are going to use old XFree86 3.x you may add 'input'. +# +HOTPLUG_USB_STATIC_MODULES=3D"input keybdev evdev joydev mousedev" --=20 USB is for mice, FireWire is for men! ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The best thread debugger on the planet. Designed with thread debugging features you've never dreamed of, try TotalView 6 free at www.etnus.com. _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel