simplify/change usb.usermap handling
PATCH 1/1 simplify/change usb.usermap handling
Hi,
the are are currently 3 kind of maps for device drivers /lib/modules/*/modules.usbmap for the running kernel (and the "sane" drivers) /etc/hotplug/usb.handmap for some hid devices that do not trigger events /etc/hotplug/usb.distmap for the old 2.2 kernel
and /etc/hotplug/usb.usermap which is empty. All have a 'complicated' syntax.
We should have a way to simply use this syntax:
module 0x$vendor ox$product
script 0x$vendor ox$product
The attached patch fixes also some devices that do not like the usbmodules --device /proc/bus/usb/x/y call.
It fills $DRIVERS and LISTER is not called if the devices is listed in a *.simple_usermap
hotplug-beta/hotplug.functions +2 -2
@@ -73,7 +73,6 @@ MODPROBE="/sbin/modprobe -s" load_drivers () { local LOADED TYPE FILENAME DESCRIPTION LISTER - DRIVERS="" # make this routine more readable TYPE=$1
@@ -100,7 +99,8 @@ load_drivers () # ... doesn't handle comment syntax either if [ "$DEVICE" = "" -o ! -f "$DEVICE" ]; then LISTER- else + # DRIVERS could be set via usb.simple_usermap, skip usbmodules in this case + elif [ "$DRIVERS" = "" ] ; then DRIVERS=`$LISTER --mapfile $FILENAME --device $DEVICE` fi ;; --- etc/hotplug-beta/usb.agent 2003-06-07 19:30:03.000000000 +0200
+++ etc/hotplug-beta/usb.agent 2003-06-08 21:55:03.000000000 +0200
@@ -105,6 +105,8 @@ MAP_HANDMAP=$HOTPLUG_DIR/usb.handmap
#
MAP_USERMAP=$HOTPLUG_DIR/usb.usermap
+# same as above, but with simpler syntax +MAP_SIMPLEUSERMAP=$HOTPLUG_DIR/usb.simple_usermap
# accumulates list of modules we may care about DRIVERS="" @@ -235,6 +237,51 @@ declare -i USB_MATCH_INT_SUBCLASS=0x0100 declare -i USB_MATCH_INT_PROTOCOL=0x0200
#
+# stdin is "modules.simple_usermap" syntax
+# on return, all matching modules were added to $DRIVERS +#
+usb_map_simple_usermodules ()
+{
+ # convert the usb_device_id fields to integers as we read them + local line module + declare -i idVendor idProduct
+
+ # look at each usb_device_id entry
+ # collect all matches in $DRIVERS
+
+ while read line
+ do
+ # comments are lines that start with "#" ...
+ # be careful, they still get parsed by bash!
+ case "$line" in
+ \#*) continue ;;
+ esac
+
+ set $line
+
+ module=$1
+
+ idVendor=$2
+ idProduct=$3
+
+ : checkmatch $module
+
+ : idVendor $idVendor $usb_idVendor
+ if [ $idVendor -ne $usb_idVendor ]; then
+ continue
+ fi
+
+ : idProduct $idProduct $usb_idProduct
+ if [ $idProduct -ne $usb_idProduct ]; then
+ continue
+ fi
+
+ # It was a match!
+ DRIVERS="$module $DRIVERS"
+ : drivers $DRIVERS
+ done
+}
+#
# stdin is "modules.usbmap" syntax
# on return, all matching modules were added to $DRIVERS
#
@@ -386,6 +458,21 @@ add)
rm -f "$REMOVER"
fi+ # some devices have user-mode drivers (no kernel module, but config) + # or specialized user-mode setup helpers, + # they will be triggered via load_drivers + # some devices do not like the usbmodules --device poking + # a non-empty $DRIVERS will skip the usbmodules call + for MAP in $MAP_SIMPLEUSERMAP $HOTPLUG_DIR/usb/*.simple_usermap + do
+ if [ -r $MAP ]; then
+ usb_map_simple_usermodules < $MAP
+ if [ "$DRIVERS" != "" ]; then
+ FOUND=true
+ fi
+ fi
+ done
+
# on 2.4 systems, modutils 2.4.2+ maintains MAP_CURRENT
# ... otherwise we can't rely on it (sigh)
case "$KERNEL" in
--- etc/hotplug-beta/usb.simple_usermap 2003-06-08 21:45:58.000000000 +0200
+++ etc/hotplug-beta/usb.simple_usermap 2003-06-08 21:45:42.000000000 +0200
@@ -0,0 +1,10 @@
+# syntax of this file:
+# lines starting with # are ignored
+# driver matching (values in hex):
+# usb_module idVendor idProduct
+# or
+# usb/helperscript idVendor idProduct
+#
+# U.S. Robotics (3Com) 0082 OfficeConnect Analog Modem
+# does not like the usbmodules --device /proc/bus/usb/x/y
+acm 0x04c1 0x0082Signature · 11 lines
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 [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel