From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simone Gotti Date: Thu, 22 Apr 2004 18:14:54 +0000 Subject: Re: Little script for ISAPNP hotplug Message-Id: <200404222014.54987.simone.gotti@email.it> MIME-Version: 1 Content-Type: multipart/mixed; boundary="Boundary-00=_euAiAnICXDzA1lS" List-Id: References: <200404092044.54429.simone.gotti@email.it> In-Reply-To: <200404092044.54429.simone.gotti@email.it> To: linux-hotplug@vger.kernel.org --Boundary-00=_euAiAnICXDzA1lS Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline I did these patches. They were tested by some people on the gentoo Italian forums with my hotplug agent and they worked well. This is a copy of the mail that I sent to Vojtech Pavlik: [start] Hi, Some days ago I've did an hotplug agent for isapnp devices. I've noticed that there wasn't an hotplug agent for this kind of devices and for this reason all the modules for isapnp devices weren't loaded by hotplug. I've did this agent (that is attached) and now I can manage the coldplugging of modules like 8250_pnp, parport_pc, ns558 etc... I've noticed that there are some modules using ISA devices (or at least I think) that aren't loaded by my hotplug scripts because they aren't "hotplug compliant". They don't export any isapnp id via the MODULE_DEVICE_TABLE macro and so the file /lib/modules/`uname -r`/modules.isapnpmap hasn't any information on which module to load. I've found 3 of this modules: psmouse (The PSmouse module) pcspkr (PC Speaker) rtc (real time clock) I know that you are the mantainer of the input subsystem so I'm writing to you for the first 2 modules. For the psmouse modules, I don't know it this is the right way to do the things because I'm not very expert and I don't know if there are other busses (like PCI) for managing PS connectors. The patches are against kernel 2.6.5. Do you think that these are right and they can be usefull? Thanks for your time. [end] I hope this can be useful. Bye! -- Simone Gotti --Boundary-00=_euAiAnICXDzA1lS Content-Type: application/x-shellscript; name="isapnp.agent" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="isapnp.agent" #!/bin/sh # # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # ISAPNP-specific hotplug policy agent. # # This should handle 2.4.* and 2.6.* ISAPNP (for now only coldplugging), # # Kernel ISAPNP params are: # # ACTION=%s [add or remove] # ISAPNP_ID=%08X # # Copyright (C) 2004 Simone Gotti, All Rights Reserved. # # HISTORY: # # 2004/04/08 Simone Gotti first version # 2004/04/11 Simone Gotti make the modules.isapnp parsing more fast # we don't need the isapnpmodules C program anymore. # cd /etc/hotplug . ./hotplug.functions # generated by modutils, for current 2.4.x kernels MAP_CURRENT=$MODULE_DIR/modules.isapnpmap # accumulates list of modules we may care about DRIVERS= if [ "$ISAPNP_ID" = "" ]; then mesg Bad ISAPNP agent invocation exit 1 fi # # stdin is "modules.isapnpmap" syntax # on return, ONE matching module was added to $DRIVERS # isapnp_map_modules () { local module ignored # comment line lists (current) isapnp_device_id field names read ignored while read module cardvendor carddevice driver_data therest do # comments are lines that start with "#" ... # be careful, they still get parsed by bash! case "$module" in \#*) continue ;; esac : checkmatch $module set $therest while [ $# -gt 0 ] do id_temp=$2$1 if [ $id_temp == $CHECKED_ID ]; then DRIVERS="$module $DRIVERS" : drivers $DRIVERS break fi shift shift done done } # # What to do with this ISAPNP hotplug event? # case $ACTION in add) LABEL="ISAPNP id $ISAPNP_ID" CHECKED_ID="0x`echo $ISAPNP_ID | cut -b1-4`0x`echo $ISAPNP_ID | cut -b5-8`" # on 2.4 systems, modutils maintains MAP_CURRENT if [ -r $MAP_CURRENT ]; then load_drivers isapnp $MAP_CURRENT "$LABEL" fi if [ "$DRIVERS" = "" ]; then debug_mesg "... no modules for $LABEL" exit 2 fi ;; *) debug_mesg ISAPNP $ACTION event not supported exit 1 ;; esac --Boundary-00=_euAiAnICXDzA1lS Content-Type: application/x-shellscript; name="isapnp.rc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="isapnp.rc" #!/bin/sh # vim: syntax=sh # # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # isapnp.rc mostly to recover lost boot-time isapnp hotplug events # # Copyright (C) 2004 Simone Gotti, All Rights Reserved. # # 2004/04/08 Simone Gotti (simone.gotti@email.it) # 2004/04/11 Alexander E. Patrakov (patrakov@ums.usu.ru) # Bash functions for converting ISAPNP_STRING to ID # # PATH=/sbin:/bin:/usr/sbin:/usr/bin cd /etc/hotplug . ./hotplug.functions decode_isapnp_vendor() { echo -n $1 | od -A n -t d1 | ( read A B C printf '%x\n' $(( ( ( $A & 0x3f ) << 2) | \ ( ( $B & 0x18 ) >> 3) | \ ( ( $B & 0x07 ) <<13) | \ ( ( $C & 0x1f ) << 8) )) ) } hex_swab() { echo `echo $1 | cut -b3-4``echo $1 | cut -b1-2` } isapnp_boot_events () { # make sure the isapnp agent will run ACTION=add DOCK=0/0/0 ISAPNP_SLOT=00:00 ISAPNP_ID= export ACTION DOCK ISAPNP_ID if [ -d /sys/bus ]; then # 2.6 kernels if [ -d /sys/bus/pnp/devices/ ]; then cd /sys/bus/pnp/devices/ for ISAPNP_DEVICE in *; do # read the String id value ISAPNP_STRING=`cat $ISAPNP_DEVICE/id` #convert the string in the ISAPNP_ID rawcardvendor=`echo $ISAPNP_STRING | cut -b1-3` rawcarddevice=`echo $ISAPNP_STRING | cut -b4-7` cardvendor=`decode_isapnp_vendor $rawcardvendor` carddevice=`hex_swab $rawcarddevice` ISAPNP_ID=$carddevice$cardvendor /sbin/hotplug isapnp done fi else # Check for /proc/bus/pnp/ if [ -d /proc/bus/pnp/ ]; then cat /proc/bus/pnp/devices | while read line do ISAPNP_ID=`echo $line | cut -d' ' -f2` /sbin/hotplug isapnp done # Check for /proc/bus/isapnp/ elif [ -d /proc/bus/isapnp/ ]; then cat /proc/bus/isapnp/devices | while read line do ISAPNP_ID=`echo $line | cut -d' ' -f2` /sbin/hotplug isapnp done #else #echo "/proc/bus/pnp/ or /proc/bus/isapnp/ not found, Is it enabled in your kernel?" fi fi return 0 } # See how we were called. case "$1" in start) isapnp_boot_events ;; stop) # echo $"isapnp stop -- ignored" ;; status) # echo $"isapnp status -- ignored" ;; restart) # always invoke by absolute path, else PATH=$PATH: $0 stop && $0 start ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 1 esac --Boundary-00=_euAiAnICXDzA1lS Content-Type: text/x-diff; charset="iso-8859-1"; name="psmouse-base-isapnpsupport.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="psmouse-base-isapnpsupport.diff" --- linux-2.6.5/drivers/input/mouse/psmouse-base.c 2004-04-04 18:08:37.000000000 +0200 +++ linux-2.6.5-prova01/drivers/input/mouse/psmouse-base.c 2004-04-19 10:37:56.000000000 +0200 @@ -18,6 +18,7 @@ #include #include #include +#include #include "psmouse.h" #include "synaptics.h" #include "logips2pp.h" @@ -739,5 +740,13 @@ serio_unregister_device(&psmouse_dev); } +static const struct pnp_device_id pnp_dev_table[] = { + /* PS/2 port for PS/2-style mice */ + { "PNP0f13", 0 }, + { "", 0 } +}; + +MODULE_DEVICE_TABLE(pnp, pnp_dev_table); + module_init(psmouse_init); module_exit(psmouse_exit); --Boundary-00=_euAiAnICXDzA1lS Content-Type: text/x-diff; charset="iso-8859-1"; name="pcspkr-isapnpsupport.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pcspkr-isapnpsupport.diff" --- linux-2.6.5/drivers/input/misc/pcspkr.c 2004-04-19 11:26:59.000000000 +0200 +++ linux-2.6.5-prova01/drivers/input/misc/pcspkr.c 2004-04-21 14:27:59.503811584 +0200 @@ -16,6 +16,7 @@ #include #include #include +#include #include MODULE_AUTHOR("Vojtech Pavlik "); @@ -90,5 +91,13 @@ input_unregister_device(&pcspkr_dev); } +static const struct pnp_device_id pnp_dev_table[] = { + /* AT-style speaker sound */ + { "PNP0800", 0 }, + { "", 0 } +}; + +MODULE_DEVICE_TABLE(pnp, pnp_dev_table); + module_init(pcspkr_init); module_exit(pcspkr_exit); --Boundary-00=_euAiAnICXDzA1lS Content-Type: text/x-diff; charset="iso-8859-1"; name="rtc-isapnpsupport.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rtc-isapnpsupport.diff" --- linux-2.6.5/drivers/char/rtc.c 2004-04-04 18:08:34.000000000 +0200 +++ linux-2.6.5-prova01/drivers/char/rtc.c 2004-04-19 10:59:35.000000000 +0200 @@ -77,6 +77,7 @@ #include #include #include +#include #include #include @@ -1346,6 +1347,14 @@ } #endif +static const struct pnp_device_id pnp_dev_table[] = { + /* AT real-time clock */ + { "PNP0b00", 0 }, + { "", 0 } +}; + +MODULE_DEVICE_TABLE(pnp, pnp_dev_table); + MODULE_AUTHOR("Paul Gortmaker"); MODULE_LICENSE("GPL"); MODULE_ALIAS_MISCDEV(RTC_MINOR); --Boundary-00=_euAiAnICXDzA1lS-- ------------------------------------------------------- This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th! http://www.thinkgeek.com/freeshipping/?cpg=12297 _______________________________________________ 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