From: Olaf Hering <olh@suse.de>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] simplify/change usb.usermap handling
Date: Sun, 08 Jun 2003 20:04:41 +0000 [thread overview]
Message-ID: <marc-linux-hotplug-105510292702025@msgid-missing> (raw)
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
--- etc/hotplug-beta/hotplug.functions 2003-06-07 19:30:03.000000000 +0200
+++ etc/hotplug-beta/hotplug.functions 2003-06-08 18:47:59.000000000 +0200
@@ -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 0x0082
--
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
reply other threads:[~2003-06-08 20:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-linux-hotplug-105510292702025@msgid-missing \
--to=olh@suse.de \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).