From: Paul M. <pm...@mv...> - 2001-06-29 20:13:04
|
Hello, As I'm sure people have already begun noticing.. for frame buffer drivers, we typically have something like: int __init myfb_init(void) { ... } static void __exit myfb_exit(void) { ... } #ifdef MODULE module_init(myfb_init); #endif module_exit(myfb_exit); This is absolutely and completely broken beyond belief. module_init() takes care of inserting the init function into the .initcall.init section which does the initialization at boot time or when the module is inserted. In addition to this, we're making a function that should be private global, and we're using a cheap hack to use another cheap hack. Which brings me to my next point.. for this bit, I direct you to fbmem_init().. particularly: for (i =3D 0; i < NUM_FB_DRIVERS; i++) if (fb_drivers[i].init) fb_drivers[i].init(); Now this is cute and all, but it's about as practical as using a bulldozer to hunt down small furry creatures. I can see how the above method might've been necessary in 2.1 and most of 2.2, but it's certainly not needed anymore. The only time it would've been practical is when drivers were using the whole init_module()/cleanup_module= () thing.. where init_module() was simply a wrapper that ran the init routine from inside the driver. If there are any drivers left that are still using this, they're broken and out of date anyways, and should be fixed. Even 2.2 has supported the module_init()/module_exit() calls for quite awhile now.. For now, I suggest something like: --- linux.orig/drivers/video/fbmem.c Fri Jun 29 12:47:03 2001 +++ linux/drivers/video/fbmem.c Fri Jun 29 13:12:08 2001 @@ -826,10 +826,6 @@ */ for (i =3D 0; i < num_pref_init_funcs; i++) pref_init_funcs[i](); - - for (i =3D 0; i < NUM_FB_DRIVERS; i++) - if (fb_drivers[i].init) - fb_drivers[i].init(); } to get around stepping into the init function twice, so we can finally get rid of the #ifdef MODULE around the module_init(), and finally make the init call static. Ideally, I'd like to do away with the fb_drivers[] entirely and simply move to a linked list where drivers insert themselves when they register with register_framebuffer(). I plan to work on a patch for this on the weekend. Comments? Regards, --=20 Paul Mundt <pm...@mv...> MontaVista Software, Inc. |