Re: [PATCH][RFC] more initcall cleanups
On Wed, 16 May 2001, Alexander Viro wrote: > a) I2C stuff got converted to module_init() nicely. That took > a lot of cruft away. Definitely makes sense. > b) init order is preserved. However, that worked only because > none of the i2c initialization functions touch stuff from random.c I don't think init order is preserved. > c) I had to put i2c before char to preserve the ordering. > Not a big deal, but I'm somewhat at loss here - how to do it without > really ugly drivers/Makefile. Suggestions? This part is not necessary. The ordering of subdir-y only has to do with compilation ordering, not with link order. The link order for drivers/char/* is set explicitly in the toplevel Makefile. > d) if we set CONFIG_I2C to 'y' we don't include drivers/i2c > into subdir-m. However, having i2c-core in kernel and the rest done as > modules is OK with i2c itself. And I seriously suspect that it's > a common situation. Am I right assuming that correct way to deal with > that is to put i2c into mod-subdirs? Yes, that's exactly what mod-subdirs is for. > e) looks like rand_initialize() is in the same class as handling > VFS/VM/etc. caches - global infrastructure. It definitely should be > called before all other drivers. Notice that old device_init() was asking > for trouble - it called parport_init() before chr_dev_init() (which calls > rand_initialize()), so if somebody would try to feed some entropy into > pool during the parport_init() we would get an interesting (and hard > to understand) problem. Maybe we should move the call into basic_setup()? I suppose I'm not the right one to comment on this, but it seems to make sense to me. > diff -urN S5-pre3-init-0/drivers/Makefile S5-pre3-init/drivers/Makefile > --- S5-pre3-init-0/drivers/Makefile Wed May 16 16:26:35 2001 > +++ S5-pre3-init/drivers/Makefile Wed May 16 20:47:52 2001 > @@ -9,8 +9,13 @@ > mod-subdirs := dio mtd sbus video macintosh usb input telephony sgi i2o ide \ > scsi md ieee1394 pnp isdn atm fc4 net/hamradio i2c acpi > > -subdir-y := parport char block net sound misc media cdrom > -subdir-m := $(subdir-y) > +subdir-y := parport > +subdir-m := parport > + > +subdir-$(CONFIG_I2C) += i2c > + > +subdir-y += char block net sound misc media cdrom > +subdir-m += char block net sound misc media cdrom > > > subdir-$(CONFIG_DIO) += dio > @@ -40,7 +45,6 @@ > > # CONFIG_HAMRADIO can be set without CONFIG_NETDEVICE being set -- ch > subdir-$(CONFIG_HAMRADIO)+= net/hamradio > -subdir-$(CONFIG_I2C) += i2c > subdir-$(CONFIG_ACPI)+= acpi > > include $(TOPDIR)/Rules.make As stated above, this change won't affect vmlinux at all. > diff -urN S5-pre3-init-0/drivers/char/random.c S5-pre3-init/drivers/char/random.c > --- S5-pre3-init-0/drivers/char/random.c Wed May 16 16:26:36 2001 > +++ S5-pre3-init/drivers/char/random.cWed May 16 20:40:12 2001 > @@ -1380,7 +1380,7 @@ > } > } > > -void __init rand_initialize(void) > +static int __init rand_initialize(void) > { > int i; > > @@ -1404,7 +1404,10 @@ > memset(_timer_state, 0, sizeof(struct timer_rand_state)); > memset(_timer_state, 0, sizeof(struct timer_rand_state)); > extract_timer_state.dont_count_entropy = 1; > + return 0; > } > + > +__initcall(rand_initialize); > > void rand_initialize_irq(int irq) > { prototype should be removed from include/linux/random.h --Kai - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH][RFC] more initcall cleanups
On Wed, 16 May 2001, Alexander Viro wrote: a) I2C stuff got converted to module_init() nicely. That took a lot of cruft away. Definitely makes sense. b) init order is preserved. However, that worked only because none of the i2c initialization functions touch stuff from random.c I don't think init order is preserved. c) I had to put i2c before char to preserve the ordering. Not a big deal, but I'm somewhat at loss here - how to do it without really ugly drivers/Makefile. Suggestions? This part is not necessary. The ordering of subdir-y only has to do with compilation ordering, not with link order. The link order for drivers/char/* is set explicitly in the toplevel Makefile. d) if we set CONFIG_I2C to 'y' we don't include drivers/i2c into subdir-m. However, having i2c-core in kernel and the rest done as modules is OK with i2c itself. And I seriously suspect that it's a common situation. Am I right assuming that correct way to deal with that is to put i2c into mod-subdirs? Yes, that's exactly what mod-subdirs is for. e) looks like rand_initialize() is in the same class as handling VFS/VM/etc. caches - global infrastructure. It definitely should be called before all other drivers. Notice that old device_init() was asking for trouble - it called parport_init() before chr_dev_init() (which calls rand_initialize()), so if somebody would try to feed some entropy into pool during the parport_init() we would get an interesting (and hard to understand) problem. Maybe we should move the call into basic_setup()? I suppose I'm not the right one to comment on this, but it seems to make sense to me. diff -urN S5-pre3-init-0/drivers/Makefile S5-pre3-init/drivers/Makefile --- S5-pre3-init-0/drivers/Makefile Wed May 16 16:26:35 2001 +++ S5-pre3-init/drivers/Makefile Wed May 16 20:47:52 2001 @@ -9,8 +9,13 @@ mod-subdirs := dio mtd sbus video macintosh usb input telephony sgi i2o ide \ scsi md ieee1394 pnp isdn atm fc4 net/hamradio i2c acpi -subdir-y := parport char block net sound misc media cdrom -subdir-m := $(subdir-y) +subdir-y := parport +subdir-m := parport + +subdir-$(CONFIG_I2C) += i2c + +subdir-y += char block net sound misc media cdrom +subdir-m += char block net sound misc media cdrom subdir-$(CONFIG_DIO) += dio @@ -40,7 +45,6 @@ # CONFIG_HAMRADIO can be set without CONFIG_NETDEVICE being set -- ch subdir-$(CONFIG_HAMRADIO)+= net/hamradio -subdir-$(CONFIG_I2C) += i2c subdir-$(CONFIG_ACPI)+= acpi include $(TOPDIR)/Rules.make As stated above, this change won't affect vmlinux at all. diff -urN S5-pre3-init-0/drivers/char/random.c S5-pre3-init/drivers/char/random.c --- S5-pre3-init-0/drivers/char/random.c Wed May 16 16:26:36 2001 +++ S5-pre3-init/drivers/char/random.cWed May 16 20:40:12 2001 @@ -1380,7 +1380,7 @@ } } -void __init rand_initialize(void) +static int __init rand_initialize(void) { int i; @@ -1404,7 +1404,10 @@ memset(mouse_timer_state, 0, sizeof(struct timer_rand_state)); memset(extract_timer_state, 0, sizeof(struct timer_rand_state)); extract_timer_state.dont_count_entropy = 1; + return 0; } + +__initcall(rand_initialize); void rand_initialize_irq(int irq) { prototype should be removed from include/linux/random.h --Kai - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH][RFC] more initcall cleanups
Linus, I've done a bit more cleaning the device initialization up (beginning of chr_dev_init()) and results were, well, interesting. a) I2C stuff got converted to module_init() nicely. That took a lot of cruft away. b) init order is preserved. However, that worked only because none of the i2c initialization functions touch stuff from random.c c) I had to put i2c before char to preserve the ordering. Not a big deal, but I'm somewhat at loss here - how to do it without really ugly drivers/Makefile. Suggestions? d) if we set CONFIG_I2C to 'y' we don't include drivers/i2c into subdir-m. However, having i2c-core in kernel and the rest done as modules is OK with i2c itself. And I seriously suspect that it's a common situation. Am I right assuming that correct way to deal with that is to put i2c into mod-subdirs? e) looks like rand_initialize() is in the same class as handling VFS/VM/etc. caches - global infrastructure. It definitely should be called before all other drivers. Notice that old device_init() was asking for trouble - it called parport_init() before chr_dev_init() (which calls rand_initialize()), so if somebody would try to feed some entropy into pool during the parport_init() we would get an interesting (and hard to understand) problem. Maybe we should move the call into basic_setup()? Comments? Very preliminary patch follows. Please, _don't_ apply it in that form - drivers/Makefile is just too ugly. Al diff -urN S5-pre3-init-0/drivers/Makefile S5-pre3-init/drivers/Makefile --- S5-pre3-init-0/drivers/Makefile Wed May 16 16:26:35 2001 +++ S5-pre3-init/drivers/Makefile Wed May 16 20:47:52 2001 @@ -9,8 +9,13 @@ mod-subdirs := dio mtd sbus video macintosh usb input telephony sgi i2o ide \ scsi md ieee1394 pnp isdn atm fc4 net/hamradio i2c acpi -subdir-y :=parport char block net sound misc media cdrom -subdir-m :=$(subdir-y) +subdir-y :=parport +subdir-m :=parport + +subdir-$(CONFIG_I2C) += i2c + +subdir-y +=char block net sound misc media cdrom +subdir-m +=char block net sound misc media cdrom subdir-$(CONFIG_DIO) += dio @@ -40,7 +45,6 @@ # CONFIG_HAMRADIO can be set without CONFIG_NETDEVICE being set -- ch subdir-$(CONFIG_HAMRADIO) += net/hamradio -subdir-$(CONFIG_I2C) += i2c subdir-$(CONFIG_ACPI) += acpi include $(TOPDIR)/Rules.make diff -urN S5-pre3-init-0/drivers/char/Makefile S5-pre3-init/drivers/char/Makefile --- S5-pre3-init-0/drivers/char/MakefileWed May 16 16:26:36 2001 +++ S5-pre3-init/drivers/char/Makefile Wed May 16 20:39:26 2001 @@ -16,7 +16,7 @@ O_TARGET := char.o -obj-y += mem.o tty_io.o n_tty.o tty_ioctl.o raw.o pty.o misc.o random.o +obj-y += random.o mem.o tty_io.o n_tty.o tty_ioctl.o raw.o pty.o misc.o # All of the (potential) objects that export symbols. # This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'. diff -urN S5-pre3-init-0/drivers/char/mem.c S5-pre3-init/drivers/char/mem.c --- S5-pre3-init-0/drivers/char/mem.c Wed May 16 16:26:36 2001 +++ S5-pre3-init/drivers/char/mem.c Wed May 16 20:48:51 2001 @@ -26,9 +26,6 @@ #include #include -#ifdef CONFIG_I2C -extern int i2c_init_all(void); -#endif #ifdef CONFIG_VIDEO_DEV extern int videodev_init(void); #endif @@ -615,10 +612,6 @@ if (devfs_register_chrdev(MEM_MAJOR,"mem",_fops)) printk("unable to get major %d for memory devs\n", MEM_MAJOR); memory_devfs_register(); - rand_initialize(); -#ifdef CONFIG_I2C - i2c_init_all(); -#endif #if defined (CONFIG_FB) fbmem_init(); #endif diff -urN S5-pre3-init-0/drivers/char/random.c S5-pre3-init/drivers/char/random.c --- S5-pre3-init-0/drivers/char/random.cWed May 16 16:26:36 2001 +++ S5-pre3-init/drivers/char/random.c Wed May 16 20:40:12 2001 @@ -1380,7 +1380,7 @@ } } -void __init rand_initialize(void) +static int __init rand_initialize(void) { int i; @@ -1404,7 +1404,10 @@ memset(_timer_state, 0, sizeof(struct timer_rand_state)); memset(_timer_state, 0, sizeof(struct timer_rand_state)); extract_timer_state.dont_count_entropy = 1; + return 0; } + +__initcall(rand_initialize); void rand_initialize_irq(int irq) { diff -urN S5-pre3-init-0/drivers/i2c/i2c-algo-bit.c S5-pre3-init/drivers/i2c/i2c-algo-bit.c --- S5-pre3-init-0/drivers/i2c/i2c-algo-bit.c Sun Apr 1 23:56:45 2001 +++ S5-pre3-init/drivers/i2c/i2c-algo-bit.c Wed May 16 20:54:07 2001 @@ -607,7 +607,7 @@ return 0; } -int __init i2c_algo_bit_init (void) +static int __init i2c_algo_bit_init (void) { printk("i2c-algo-bit.o: i2c bit algorithm module\n"); return 0; @@ -618,7 +618,6 @@ EXPORT_SYMBOL(i2c_bit_add_bus); EXPORT_SYMBOL(i2c_bit_del_bus); -#ifdef MODULE MODULE_AUTHOR("Simon G. Vogl <[EMAIL
[PATCH][RFC] more initcall cleanups
Linus, I've done a bit more cleaning the device initialization up (beginning of chr_dev_init()) and results were, well, interesting. a) I2C stuff got converted to module_init() nicely. That took a lot of cruft away. b) init order is preserved. However, that worked only because none of the i2c initialization functions touch stuff from random.c c) I had to put i2c before char to preserve the ordering. Not a big deal, but I'm somewhat at loss here - how to do it without really ugly drivers/Makefile. Suggestions? d) if we set CONFIG_I2C to 'y' we don't include drivers/i2c into subdir-m. However, having i2c-core in kernel and the rest done as modules is OK with i2c itself. And I seriously suspect that it's a common situation. Am I right assuming that correct way to deal with that is to put i2c into mod-subdirs? e) looks like rand_initialize() is in the same class as handling VFS/VM/etc. caches - global infrastructure. It definitely should be called before all other drivers. Notice that old device_init() was asking for trouble - it called parport_init() before chr_dev_init() (which calls rand_initialize()), so if somebody would try to feed some entropy into pool during the parport_init() we would get an interesting (and hard to understand) problem. Maybe we should move the call into basic_setup()? Comments? Very preliminary patch follows. Please, _don't_ apply it in that form - drivers/Makefile is just too ugly. Al diff -urN S5-pre3-init-0/drivers/Makefile S5-pre3-init/drivers/Makefile --- S5-pre3-init-0/drivers/Makefile Wed May 16 16:26:35 2001 +++ S5-pre3-init/drivers/Makefile Wed May 16 20:47:52 2001 @@ -9,8 +9,13 @@ mod-subdirs := dio mtd sbus video macintosh usb input telephony sgi i2o ide \ scsi md ieee1394 pnp isdn atm fc4 net/hamradio i2c acpi -subdir-y :=parport char block net sound misc media cdrom -subdir-m :=$(subdir-y) +subdir-y :=parport +subdir-m :=parport + +subdir-$(CONFIG_I2C) += i2c + +subdir-y +=char block net sound misc media cdrom +subdir-m +=char block net sound misc media cdrom subdir-$(CONFIG_DIO) += dio @@ -40,7 +45,6 @@ # CONFIG_HAMRADIO can be set without CONFIG_NETDEVICE being set -- ch subdir-$(CONFIG_HAMRADIO) += net/hamradio -subdir-$(CONFIG_I2C) += i2c subdir-$(CONFIG_ACPI) += acpi include $(TOPDIR)/Rules.make diff -urN S5-pre3-init-0/drivers/char/Makefile S5-pre3-init/drivers/char/Makefile --- S5-pre3-init-0/drivers/char/MakefileWed May 16 16:26:36 2001 +++ S5-pre3-init/drivers/char/Makefile Wed May 16 20:39:26 2001 @@ -16,7 +16,7 @@ O_TARGET := char.o -obj-y += mem.o tty_io.o n_tty.o tty_ioctl.o raw.o pty.o misc.o random.o +obj-y += random.o mem.o tty_io.o n_tty.o tty_ioctl.o raw.o pty.o misc.o # All of the (potential) objects that export symbols. # This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'. diff -urN S5-pre3-init-0/drivers/char/mem.c S5-pre3-init/drivers/char/mem.c --- S5-pre3-init-0/drivers/char/mem.c Wed May 16 16:26:36 2001 +++ S5-pre3-init/drivers/char/mem.c Wed May 16 20:48:51 2001 @@ -26,9 +26,6 @@ #include asm/io.h #include asm/pgalloc.h -#ifdef CONFIG_I2C -extern int i2c_init_all(void); -#endif #ifdef CONFIG_VIDEO_DEV extern int videodev_init(void); #endif @@ -615,10 +612,6 @@ if (devfs_register_chrdev(MEM_MAJOR,mem,memory_fops)) printk(unable to get major %d for memory devs\n, MEM_MAJOR); memory_devfs_register(); - rand_initialize(); -#ifdef CONFIG_I2C - i2c_init_all(); -#endif #if defined (CONFIG_FB) fbmem_init(); #endif diff -urN S5-pre3-init-0/drivers/char/random.c S5-pre3-init/drivers/char/random.c --- S5-pre3-init-0/drivers/char/random.cWed May 16 16:26:36 2001 +++ S5-pre3-init/drivers/char/random.c Wed May 16 20:40:12 2001 @@ -1380,7 +1380,7 @@ } } -void __init rand_initialize(void) +static int __init rand_initialize(void) { int i; @@ -1404,7 +1404,10 @@ memset(mouse_timer_state, 0, sizeof(struct timer_rand_state)); memset(extract_timer_state, 0, sizeof(struct timer_rand_state)); extract_timer_state.dont_count_entropy = 1; + return 0; } + +__initcall(rand_initialize); void rand_initialize_irq(int irq) { diff -urN S5-pre3-init-0/drivers/i2c/i2c-algo-bit.c S5-pre3-init/drivers/i2c/i2c-algo-bit.c --- S5-pre3-init-0/drivers/i2c/i2c-algo-bit.c Sun Apr 1 23:56:45 2001 +++ S5-pre3-init/drivers/i2c/i2c-algo-bit.c Wed May 16 20:54:07 2001 @@ -607,7 +607,7 @@ return 0; } -int __init i2c_algo_bit_init (void) +static int __init i2c_algo_bit_init (void) { printk(i2c-algo-bit.o: i2c bit algorithm module\n); return 0; @@ -618,7 +618,6 @@ EXPORT_SYMBOL(i2c_bit_add_bus); EXPORT_SYMBOL(i2c_bit_del_bus); -#ifdef MODULE