diethotplug-0.4 utility patch
Hi Greg,
I send you patch for diethotplug-0.4, witch:
- adds remove action
- adds pci.rc & usb.rc
- usb.rc script remove modules not by fixed list as hotplug, but from list gotten from depend files when compiled
- for USB: matching by vendor & class, not only by vendor (-ENODEV bug)
Regards,
Signature · 5 lines
------------------------------------------------------- David "Dave" Jez Brno, CZ, Europe E-mail: [email protected] PGP key: finger [email protected] ---------=[ ~EOF ]=------------------------------------
ChangeLog +6 -0
@@ -1,3 +1,9 @@ +0.4-djz (20031023) * fixed -ENODEV bug. + + add remove action + + add rc/pci.rc for loading modules for PCI devices + + add rc/usb.rc for loading USB subsystem + TODO ? add rc/isapnp.rc for loading modules for ISA PnP devices + - rc binaries can not be compiled with klibc yet 0.4 - patch for the Makefile and dietlibc stuff from Erik Andersen. - renamed the dietlibc subdirectory to klibc - synced with my previous klibc changes
Makefile +13 -1
@@ -152,10 +152,22 @@ $(CC) $(LDFLAGS) -o $(ROOT) $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS) $(STRIPCMD) $(ROOT) + +rc: rc/pci.rc rc/usb.rc + +rc/pci.rc: pci_modules.h logging.o util.o rc/pci-rc.o + $(CC) $(LDFLAGS) -o rc/pci.rc logging.o util.o rc/pci-rc.o $(LIB_OBJS) $(ARCH_LIB_OBJS) + $(STRIPCMD) rc/pci.rc + +rc/usb.rc: usb_modules.h logging.o util.o rc/usb-rc.o + $(CC) $(LDFLAGS) -o rc/usb.rc logging.o util.o rc/usb-rc.o $(LIB_OBJS) $(ARCH_LIB_OBJS) + $(STRIPCMD) rc/usb.rc + + clean: -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \ | xargs rm -f - -rm -f core $(ROOT) $(GEN_HEADERS) + -rm -f core $(ROOT) $(GEN_HEADERS) rc/isapnp.rc rc/pci.rc rc/usb.rc $(MAKE) -C klibc clean DISTFILES = $(shell find . \( -not -name '.' \) -print | grep -v CVS | grep -v "\.tar\.gz" | grep -v "\/\." | grep -v releases | grep -v BitKeeper | grep -v SCCS )
README +0 -2
@@ -35,5 +35,3 @@ uncomment the comment in the line: #DEBUG = y in the Makefile - -
convert_ieee1394.pl +0 -1
@@ -54,4 +54,3 @@ } print "\t{NULL}\n};\n"; -
convert_pci.pl +0 -1
@@ -54,4 +54,3 @@ } print "\t{NULL}\n};\n"; -
convert_usb.pl +0 -1
@@ -61,4 +61,3 @@ } print "\t{NULL}\n};\n"; -
hotplug.c +0 -1
@@ -64,4 +64,3 @@*/ return call_subsystem (argv[1 ], main_subsystem); } -
hotplug.h +4 -1
@@ -33,6 +33,9 @@int (* handler) (void ); }; +#define ACTION_ADD 1 +#define ACTION_REMOVE 0 +#ifdef DEBUG #include <syslog.h> #define dbg(format, arg...) do { log_message (LOG_DEBUG, __FUNCTION__ ": " format, ## arg); } while (0)
@@ -47,10 +50,10 @@extern int split_2values (const char *string,int base,unsigned int * value1,unsigned int * value2);extern int call_subsystem (const char *string,struct subsystem *subsystem);extern int load_module (const char *module_name); +extern int remove_module (const char *module_name);extern int usb_handler (void );extern int pci_handler (void );extern int ieee1394_handler (void );#endif -
ieee1394.c +18 -9
@@ -35,7 +35,7 @@#define IEEE1394_MATCH_VERSION 0x0008 -static int match (unsigned int vendor_id,unsigned int specifier_id,unsigned int version) +static int match (unsigned int vendor_id,unsigned int specifier_id,unsigned int version,int action) {int i;int retval;
@@ -69,17 +69,22 @@continue ; }/* found one! */ -dbg ("loading %s" , ieee1394_module_map[i].module_name); - retval =load_module (ieee1394_module_map[i].module_name); +if (action ==ACTION_ADD ) { +dbg ("loading %s" , ieee1394_module_map[i].module_name); + retval =load_module (ieee1394_module_map[i].module_name); + }else { +dbg ("removing %s" , ieee1394_module_map[i].module_name); + retval =remove_module (ieee1394_module_map[i].module_name); + }if (retval)return retval; } -return -ENODEV ; +return 0 ; } -static int ieee1394_add (void ) +static int ieee1394_add_remove (int action) {char *vendor_env;char *specifier_env;
@@ -102,16 +107,21 @@ specifier_id =strtoul (specifier_env,NULL ,16 ); version =strtoul (version_env,NULL ,16 ); - error =match (vendor_id, specifier_id, version); + error =match (vendor_id, specifier_id, version, action);return error; } +static int ieee1394_add (void ) +{ +return ieee1394_add_remove (ACTION_ADD ); +} + +static int ieee1394_remove (void ) { -/* right now we don't do anything here :) */ -return 0 ; +return ieee1394_add_remove (ACTION_REMOVE ); }
@@ -135,4 +145,3 @@return call_subsystem (action, ieee1394_subsystem); } -
pci.c +17 -9
@@ -31,7 +31,7 @@static int match_vendor (unsigned int vendor,unsigned int device,unsigned int subvendor,unsigned int subdevice, -unsigned int pci_class) +unsigned int pci_class,int action) {int i;int retval;
@@ -76,8 +76,13 @@ }/* found one! */ -dbg ("loading %s" , pci_module_map[i].module_name); - retval =load_module (pci_module_map[i].module_name); +if (action ==ACTION_ADD ) { +dbg ("loading %s" , pci_module_map[i].module_name); + retval =load_module (pci_module_map[i].module_name); + }else { +dbg ("removing %s" , pci_module_map[i].module_name); + retval =remove_module (pci_module_map[i].module_name); + }if (retval)return retval; }
@@ -85,7 +90,7 @@return 0 ; } -static int pci_add (void ) +static int pci_add_remove (int action) {char *class_env;char *id_env;
@@ -115,16 +120,21 @@return error; class =strtoul (class_env,NULL ,16 ); - error =match_vendor (vendor, device, subvendor, subdevice, class); + error =match_vendor (vendor, device, subvendor, subdevice, class, action);return error; } +static int pci_add (void ) +{ +return pci_add_remove (ACTION_ADD ); +} + +static int pci_remove (void ) { -/* right now we don't do anything here :) */ -return 0 ; +return pci_add_remove (ACTION_REMOVE ); }static struct subsystem pci_subsystem[] = {
@@ -146,5 +156,3 @@return call_subsystem (action, pci_subsystem); } - -
rc/pci-rc.c +150 -0
150 lines not on this page · raw message
rc/usb-rc.c +162 -0
162 lines not on this page · raw message
usb.c +39 -20
134 lines not on this page · raw message
util.c +24 -0
@@ -209,3 +209,27 @@return 0 ; } + +int remove_module (const char *module_name) +{ +char *argv[4 ]; + + argv[0 ] ="/sbin/rmmod" ; + argv[1 ] ="-r" ; + argv[2 ] = (char *)module_name; + argv[3 ] =NULL ; +dbg ("removing module %s" , module_name); +switch (fork ()) { +case 0 : +/* we are the child, so lets run the program */ +execv ("/sbin/rmmod" , argv); +exit (0 ); +break ; +case (-1 ): +dbg ("fork failed." ); +break ; +default : +break ; + } +return 0 ; +}
Quoted 4 lines · David Jez
Hi Greg,
I send you patch for diethotplug-0.4, witch:
- adds remove action
Hm, remove action will not work. See the linux-hotplug-devel mailing list archives for why we can not do this.
Quoted 1 line
- adds pci.rc & usb.rc
Why do you need this? What's wrong with a small shell script to do this? Are you using this for a system? I guess it could be useful for a system that has no shell.
Quoted 2 lines
- usb.rc script remove modules not by fixed list as hotplug, but from list gotten from depend files when compiled
I don't understand, what does this do?
Quoted 1 line
- for USB: matching by vendor & class, not only by vendor (
-ENODEVbug)
Can you split this patch out? It looks useful.
convert_ieee1394.pl line 57
Quoted 6 lines
+++
diethotplug-0.4/convert_ieee1394.plThu Apr 10 11:16:00 2003convert_ieee1394.pl +0
-1@@ -54,4 +54,3 @@ } print "\t{NULL}\n};\n"; -
Hm, you have a few diffs like this, I don't think it's really necessary :)
thanks,
greg k-h
Quoted 2 lines · Greg KH
Hm, remove action will not work. See the linux-hotplug-devel mailing list archives for why we can not do this.
OK, i'll see. But this realy helps me.
Quoted 5 lines
Quoted 1 line
- adds pci.rc & usb.rc
Why do you need this? What's wrong with a small shell script to do this? Are you using this for a system? I guess it could be useful for a system that has no shell.
Nothing wrong on shell script, but i use this on system without perl,
awk, if, ...etc... binaries.
Quoted 3 lines
Quoted 1 line
- for USB: matching by vendor & class, not only by vendor (
-ENODEVbug)Can you split this patch out? It looks useful.
of course
Signature · 5 lines
------------------------------------------------------- David "Dave" Jez Brno, CZ, Europe E-mail: [email protected] PGP key: finger [email protected] ---------=[ ~EOF ]=------------------------------------
Quoted 4 lines · David Jez
Quoted 2 lines · Greg KH
Hm, remove action will not work. See the linux-hotplug-devel mailing list archives for why we can not do this.
OK, i'll see. But this realy helps me.
But it's wrong. You can't get this correct, and you will end up removing modules for devices that are currently in use. The moment you have 2 devices that use the same module this will happen. You will end up with some very unhappy users.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
- adds pci.rc & usb.rc
Why do you need this? What's wrong with a small shell script to do this? Are you using this for a system? I guess it could be useful for a system that has no shell.
Nothing wrong on shell script, but i use this on system without perl,
awk, if, ...etc... binaries.
Ok, care to send these as a separate patch then too?
thanks,
greg k-h
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
- for USB: matching by vendor & class, not only by vendor (
-ENODEVbug)Can you split this patch out? It looks useful.
of course
Signature · 5 lines
------------------------------------------------------- David "Dave" Jez Brno, CZ, Europe E-mail: [email protected] PGP key: finger [email protected] ---------=[ ~EOF ]=------------------------------------
ieee1394.c +1 -1
@@ -75,7 +75,7 @@return retval; } -return -ENODEV ; +return 0 ; }
usb.c +3 -3
@@ -84,7 +84,7 @@ } } -return -ENODEV ; +return 0 ; }
@@ -121,7 +121,7 @@ } } -return -ENODEV ; +return 0 ; }
@@ -158,7 +158,7 @@ } } -return -ENODEV ; +return 0 ; }
Quoted 4 lines · David Jez
Quoted 2 lines · Greg KH
Hm, remove action will not work. See the linux-hotplug-devel mailing list archives for why we can not do this.
OK, i'll see. But this realy helps me.
But it's wrong. You can't get this correct, and you will end up removing modules for devices that are currently in use. The moment you have 2 devices that use the same module this will happen. You will end up with some very unhappy users.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
- adds pci.rc & usb.rc
Why do you need this? What's wrong with a small shell script to do this? Are you using this for a system? I guess it could be useful for a system that has no shell.
Nothing wrong on shell script, but i use this on system without perl,
awk, if, ...etc... binaries.
Ok, care to send these as a separate patch then too?
thanks,
greg k-h