Module rewrite series 1/5: KBUILD_MODNAME.
Subsystems (8)
PATCH 1/1 Module rewrite series 1/5: KBUILD_MODNAME.
OK, this includes the "fix intermodule" stuff as patch 5. I compiled a couple of drivers MTD and DRM drivers, but I have no way of testing that they actually work (PPC doesn't build, and no x86 boxes with DRM-compatible cards).
This has been stresstesting here in my 2-way x86 bot for 3 hours now (3 loopback mount/unmount, 3 ext2 insmod/rmmod, 3 random modprobe/rmmod). While compiling and working as usual.
Cheers,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Name: KBUILD_MODNAME define for build system
Author: Kai Germaschewski
Status: Tested on 2.5.45
D: This patch adds a -DKBUILD_MODNAME to the kernel compile, which
D: contains the base of the module name which is being built. D:
D: - Some sreorganization of the c_flags since they're needed for D: generating modversions (.ver) and compiling D: - Use the right KBUILD_MODNAME also when the user just wants a .i/.s/.lst D: file for debugging and also when generating modversions D: - It looks like with your current approach you can't have a ',' or '-' in D: KBUILD_MODNAME - however, that means that KBUILD_MODNAME is not quite D: right for passing module parameters for built-in modules on the command D: line, it would be confusing to pass parameters for ide-cd as D: ide_cd.foo=whatever. So that part could use a little more thought. D: - If you think your module_names trick makes a noticable difference, feel D: free to re-add it. D: - It's possible that objects are linked into more than one module - I D: suppose this shouldn't be a problem, since these objects hopefully D: don't have a module_init() nor do they export symbols. Not sure if your D: patch did handle this.
D:
D: --Kai
net/unix/af_unix.c +2 -0
@@ -79,6 +79,8 @@* with BSD names. */ +#undef unix/* KBUILD_MODNAME */ +#include <linux/module.h> #include <linux/config.h> #include <linux/kernel.h>
scripts/Makefile.build +12 -4
@@ -54,6 +54,7 @@ modkern_cflags := $(CFLAGS_KERNEL) $(real-objs-m) : modkern_cflags := $(CFLAGS_MODULE) $(real-objs-m:.o=.i) : modkern_cflags := $(CFLAGS_MODULE) +$(real-objs-m:.o=.s) : modkern_cflags := $(CFLAGS_MODULE) $(real-objs-m:.o=.lst): modkern_cflags := $(CFLAGS_MODULE) $(export-objs) : export_flags := $(EXPORT_FLAGS)
@@ -61,10 +62,17 @@ $(export-objs:.o=.i) : export_flags : $(export-objs:.o=.s) : export_flags := $(EXPORT_FLAGS) $(export-objs:.o=.lst): export_flags := $(EXPORT_FLAGS) -c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \ - $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \ - -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) \ - $(export_flags) +# Default for not multi-part modules +modname = $(*F) + +$(multi-objs-m) : modname = $(modname-multi) +$(multi-objs-m:.o=.i) : modname = $(modname-multi) +$(multi-objs-m:.o=.s) : modname = $(modname-multi) +$(multi-objs-m:.o=.lst) : modname = $(modname-multi) +$(multi-objs-y) : modname = $(modname-multi) +$(multi-objs-y:.o=.i) : modname = $(modname-multi) +$(multi-objs-y:.o=.s) : modname = $(modname-multi) +$(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $@ cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $<
scripts/Makefile.lib +21 -0
@@ -5,6 +5,8 @@ # Standard vars comma := , +empty := +space := $(empty) $(empty) # Figure out what we need to build from the various variables # ===========================================================================
@@ -40,11 +40,13 @@ __obj-m = $(filter-out export.o,$(obj-m) # if $(foo-objs) exists, foo.o is a composite object multi-used-y := $(sort $(foreach m,$(__obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) +multi-used := $(multi-used-y) $(multi-used-m) # Build list of the parts of our composite objects, our composite # objects depend on those (obviously) multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y))) multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) +multi-objs := $(multi-objs-y) $(multi-objs-m) # $(subdir-obj-y) is the list of objects in $(obj-y) which do not live # in the local directory
@@ -84,6 +86,23 @@ host-progs-multi-objs := $(addprefix $(o # contain a comma depfile = $(subst $(comma),_,$(@D)/.$(@F).d) +# These flags are needed for modversions and compiling, so we define them here +# already +# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will +# end up in (or would, if it gets compiled in) +# Note: It's possible that one object gets potentially linked into more +# than one module. In that case KBUILD_MODNAME will be set to foo_bar, +# where foo and bar are the name of the modules. +basename_flags = -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) +modname_flags = -DKBUILD_MODNAME=$(subst $(comma),_,$(subst -,_,$(modname))) +c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \ + $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \ + $(basename_flags) $(modname_flags) $(export_flags) + +# Finds the multi-part object the current object will be linked into +modname-multi = $(subst $(space),_,$(strip $(foreach m,$(multi-used),\ + $(if $(filter $(*F).o,$($(m:.o=-objs))),$(m:.o=))))) + # Shipped files # ===========================================================================
scripts/Makefile.modver +3 -4
@@ -48,11 +48,10 @@ CFLAGS_MODULE := $(filter-out -include i $(addprefix $(MODVERDIR)/,$(real-objs-y:.o=.ver)): modkern_cflags := $(CFLAGS_KERNEL) $(addprefix $(MODVERDIR)/,$(real-objs-m:.o=.ver)): modkern_cflags := $(CFLAGS_MODULE) $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver)): export_flags := -D__GENKSYMS__ +# Default for not multi-part modules +modname = $(*F) -c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \ - $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \ - -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) \ - $(export_flags) +$(addprefix $(MODVERDIR)/,$(multi-objs:.o=.ver)) : modname = $(modname-multi) # Our objects only depend on modversions.h, not on the individual .ver # files (fix-dep filters them), so touch modversions.h if any of the .ver
PATCH 1/1 Module rewrite series 2/5: Obsolete init_module
People seemed to cheer this change generally. If you use the old "init_module" style you need to have a separate init routing for non-modular anyway, which is horribly icky.
Name: init_module removal
Author: Rusty Russell
Status: Trivial
D: Modules in 2.4 can simply name functions init_module() and
D: cleanup_module(), and they will be called at module load and
D: unload. The preferred way is to use module_init(funcname) and
D: module_exit(funcname), and this is the only way once the
D: in-kernel-module loader is included.
D:
D: This is not all of them, just some examples (the ones I needed to
D: successfully compile).
drivers/net/ethertap.c +6 -2
@@ -346,7 +346,7 @@ static struct net_device dev_ethertap = 0, 0, 0, NULL, ethertap_probe }; -int init_module (void ) +static int init (void ) { dev_ethertap.base_addr=unit+NETLINK_TAPBASE ;sprintf (dev_ethertap.name,"tap%d" ,unit);
@@ -360,7 +360,7 @@ int init_module(void)return 0 ; } -void cleanup_module (void ) +static void cleanup (void ) { tap_map[dev_ethertap.base_addr]=NULL ;unregister_netdev (&dev_ethertap);
@@ -372,6 +372,10 @@ void cleanup_module(void)kfree (dev_ethertap.priv); dev_ethertap.priv = NULL; /* gets re-allocated by ethertap_probe */ } + +/* FIXME: Remove Space.c hardcoded crap --RR */ +module_init (init); +module_exit (cleanup);#endif /* MODULE */ MODULE_LICENSE ("GPL" );
drivers/net/slhc.c +5 -2
@@ -735,17 +735,20 @@ EXPORT_SYMBOL(slhc_toss);#ifdef MODULE -int init_module (void ) +static int init (void ) {printk (KERN_INFO "CSLIP: code copyright 1989 Regents of the University of California\n" );return 0 ; } -void cleanup_module (void ) +static void fini (void ) {return ; } +/* FIXME: Remove hard-coded initializers for builtin case */ +module_init (init); +module_exit (fini);#endif /* MODULE */ #else /* CONFIG_INET */
drivers/parport/init.c +5 -2
@@ -120,7 +120,7 @@ __setup ("parport=", parport_setup);#endif #ifdef MODULE -int init_module (void ) +static int init (void ) {#ifdef CONFIG_SYSCTL parport_default_proc_register ();
@@ -128,12 +128,15 @@ int init_module(void) return 0; } -void cleanup_module (void ) +static void fini (void ) {#ifdef CONFIG_SYSCTL parport_default_proc_unregister ();#endif } + +module_init (init); +module_exit (fini);#else
drivers/parport/parport_pc.c +6 -2
@@ -3069,7 +3069,7 @@ MODULE_PARM_DESC(verbose_probing, "Log cMODULE_PARM (verbose_probing,"i" );#endif -int init_module (void ) +static int init (void ) {/* Work out how many ports we have, then get parport_share to parse the irq values. */
@@ -3118,7 +3118,7 @@ int init_module(void)return ret; } -void cleanup_module (void ) +static void fini (void ) {/* We ought to keep track of which ports are actually ours. */ struct parport *p =parport_enumerate (), *tmp;
@@ -3134,4 +3134,8 @@ void cleanup_module(void) p = tmp; } } + +/* FIXME: Merge builtin and modular initializers --RR */ +module_init (init); +module_exit (fini);#endif
net/netlink/netlink_dev.c +6 -2
@@ -208,16 +208,20 @@ int __init init_netlink(void)MODULE_LICENSE ("GPL" ); -int init_module (void ) +static int init (void ) {printk (KERN_INFO "Network Kernel/User communications module 0.04\n" );return init_netlink (); } -void cleanup_module (void ) +static void fini (void ) {devfs_unregister (devfs_handle);unregister_chrdev (NETLINK_MAJOR ,"netlink" ); } + +/* FIXME: Remove harded init call in socket.c */ +module_init (init); +module_exit (fini);#endif
drivers/char/ftape/zftape/zftape-init.c +8 -0
@@ -393,20 +393,26 @@ KERN_INFO#ifdef MODULE + +#if 0 /* FIXME --RR */ /* Called by modules package before trying to unload the module */ static int can_unload (void ) {return (GET_USE_COUNT (THIS_MODULE )||zft_dirty ()||test_bit (0 ,&busy_flag))?-EBUSY :0 ; } +#endif +/* Called by modules package when installing the driver */ int init_module (void ) { +#if 0 /*FIXME --RR*/ if (!mod_member_present (&__this_module, can_unload)) {return -EBUSY ; } __this_module.can_unload = can_unload; +#endif return zft_init (); }
@@ -444,3 +450,5 @@ void cleanup_module(void) }#endif /* MODULE */ + +module_init (init_module);
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
PATCH 1/1 Module rewrite series 4/5: i386 support.
In reply to Rusty RussellStraightforward x86 mini linker.
Name: New Module Loader Base: x86 support
Author: Rusty Russell
Status: Tested on 2.5.45
Depends: Module/module.patch.gz
D: This patch provides basic x86 support for modules.
arch/i386/kernel/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_SOFTWARE_SUSPEND) += suspen obj-$(CONFIG_X86_NUMAQ) += numaq.o obj-$(CONFIG_PROFILING) += profile.o obj-$(CONFIG_EDD) += edd.o +obj-$(CONFIG_MODULES) += module.o EXTRA_AFLAGS := -traditional
arch/i386/kernel/entry.S +3 -3
@@ -610,10 +610,10 @@ ENTRY(sys_call_table) .long sys_adjtimex .long sys_mprotect /* 125 */ .long sys_sigprocmask - .long sys_create_module + .long sys_ni_syscall /* old "create_module" */ .long sys_init_module .long sys_delete_module - .long sys_get_kernel_syms /* 130 */ + .long sys_ni_syscall /* 130: old "get_kernel_syms" */ .long sys_quotactl .long sys_getpgid .long sys_fchdir
@@ -650,7 +650,7 @@ ENTRY(sys_call_table) .long sys_setresuid16 .long sys_getresuid16 /* 165 */ .long sys_vm86 - .long sys_query_module + .long sys_ni_syscall /* Old sys_query_module */ .long sys_poll .long sys_nfsservctl .long sys_setresgid16 /* 170 */
arch/i386/kernel/module.c +130 -0
130 lines not on this page · raw message
arch/i386/kernel/traps.c +4 -3
@@ -95,7 +95,8 @@ static int kstack_depth_to_print = 24;#ifdef CONFIG_MODULES -extern struct module kernel_module; +/* FIXME: Accessed without a lock --RR */ +extern struct list_head modules;static inline int kernel_text_address (unsigned long addr) {
@@ -106,11 +107,11 @@ static inline int kernel_text_address(un addr <= (unsigned long) &_etext)return 1 ; -for (mod = module_list; mod != &kernel_module; mod = mod->next) { +list_for_each_entry (mod, &modules, list) {/* mod_bound tests for addr being inside the vmalloc'ed * module area. Of course it'd be better to test only * for the .text subset... */ -if (mod_bound (addr,0 , mod)) { +if (mod_bound ((void *)addr,0 , mod)) { retval =1 ;break ; }
arch/i386/mm/extable.c +8 -6
@@ -44,15 +44,17 @@ search_exception_table(unsigned long addreturn ret;#else unsigned long flags; -/* The kernel is the last "module" -- no need to treat it special. */ -struct module *mp; +struct list_head *i; +/* The kernel is the last "module" -- no need to treat it special. */ spin_lock_irqsave (&modlist_lock, flags); -for (mp = module_list; mp !=NULL ; mp = mp->next) { -if (mp->ex_table_start ==NULL || !(mp->flags&(MOD_RUNNING |MOD_INITIALIZING ))) +list_for_each (i, &extables) { +struct exception_table *ex + = list_entry(i, struct exception_table, list); +if (ex->num_entries ==0 )continue ; - ret =search_one_table (mp->ex_table_start, - mp->ex_table_end -1 , addr); + ret =search_one_table (ex->entry, + ex->entry + ex->num_entries -1 , addr);if (ret)break ; }
arch/i386/vmlinux.lds.S +1 -0
@@ -26,6 +26,7 @@ SECTIONS __ex_table : { *(__ex_table) } __stop___ex_table = .; + . = ALIGN(64); __start___ksymtab = .; /* Kernel symbol table */ __ksymtab : { *(__ksymtab) } __stop___ksymtab = .;
include/asm-i386/module.h +7 -8
@@ -1,12 +1,11 @@#ifndef _ASM_I386_MODULE_H#define _ASM_I386_MODULE_H -/* -* This file contains the i386 architecture specific module code. -*/ - -#define module_map (x) vmalloc(x) -#define module_unmap (x) vfree(x) -#define module_arch_init (x) (0) -#define arch_init_modules (x) do { } while (0) +/* x86 is simple */ +struct mod_arch_specific +{ +}; +#define Elf_Shdr Elf32_Shdr +#define Elf_Sym Elf32_Sym +#define Elf_Ehdr Elf32_Ehdr#endif /* _ASM_I386_MODULE_H */
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
PATCH 1/1 Module rewrite series 5/5: DRM and MTD
In reply to Rusty RussellThis fixes the three inter_module* users (compile, but untested):
1) MTD really wants symbol_get, and now they have it. The solution uses weak symbols: you can return to #ifdef CONFIG_xxx if you want this to work on Sparc64.
2) DRM really wants symbol_get and symbol_put for AGP detection (although that still leaves you high and dry if you insmod it later). They also use it for piggybacking for multiple DRM
modules: I've simply dumped this in drivers/char/misc.c because it seems inherently broken.
For the record, the DRM code should be rewritten using standard kernel idioms so that it is readable by the rest of us.
Name: Removed inter_module functions
Author: Rusty Russell
Status: Untested
Depends: Module/module-i386.patch.gz
Depends: Module/module-ppc.patch.gz
D: Gets rid of inter_module* and fixes up DRM and mtd drivers.
drivers/char/agp/agp.c +2 -4
@@ -46,6 +46,7 @@ EXPORT_SYMBOL(agp_unbind_memory);EXPORT_SYMBOL (agp_enable);EXPORT_SYMBOL (agp_backend_acquire);EXPORT_SYMBOL (agp_backend_release); +EXPORT_SYMBOL (agp_drm);struct agp_bridge_data agp_bridge = { type:NOT_SUPPORTED };static int agp_try_unsupported__initdata =0 ;
@@ -1600,7 +1601,7 @@ static int agp_power(struct pm_dev *dev,extern int agp_frontend_initialize (void );extern void agp_frontend_cleanup (void ); -static const drm_agp_t drm_agp = { +const drm_agp_t agp_drm = { &agp_free_memory, &agp_allocate_memory, &agp_bind_memory,
@@ -1632,8 +1633,6 @@ static int agp_probe (struct pci_dev *dereturn ret_val; } -inter_module_register ("drm_agp" ,THIS_MODULE , &drm_agp); -pm_register (PM_PCI_DEV ,PM_PCI_ID (agp_bridge.dev), agp_power);return 0 ; }
@@ -1680,7 +1679,6 @@ static void __exit agp_cleanup(void)pm_unregister_all (agp_power);agp_frontend_cleanup ();agp_backend_cleanup (); -inter_module_unregister ("drm_agp" ); } }
drivers/char/drm/Makefile +2 -0
@@ -2,6 +2,8 @@ # Makefile for the drm device driver. This driver provides support for the # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. +export-objs := gamma.o tdfx.o r128.o radeon.o mga.o i810.i i830.o ffb.o + gamma-objs := gamma_drv.o gamma_dma.o tdfx-objs := tdfx_drv.o r128-objs := r128_drv.o r128_cce.o r128_state.o
drivers/char/drm/drm_agpsupport.h +2 -2
@@ -35,8 +35,8 @@#if __REALLY_HAVE_AGP -#define DRM_AGP_GET (drm_agp_t *)inter_module_get("drm_agp") -#define DRM_AGP_PUT inter_module_put("drm_agp") +#define DRM_AGP_GET symbol_get(agp_drm) +#define DRM_AGP_PUT symbol_put(agp_drm)static const drm_agp_t *drm_agp =NULL ;
drivers/char/drm/drm_stub.h +11 -5
@@ -97,6 +97,12 @@ static int DRM(stub_getminor)(const charreturn -1 ; } +/* Hacked into char/misc.c */ +extern void drm_stub_set (struct drm_stub_info *,struct module *owner); +extern void drm_stub_unset (void ); +extern struct drm_stub_info *drm_stub_get (void ); +extern void drm_stub_put (void ); +static int DRM (stub_putminor )(int minor) {if (minor <0 || minor >=DRM_STUB_MAXCARDS )return -1 ;
@@ -105,9 +111,9 @@ static int DRM(stub_putminor)(int minor)DRM (proc_cleanup)(minor,DRM (stub_root),DRM (stub_list)[minor].dev_root);if (minor) { -inter_module_put ("drm" ); +drm_stub_put (); }else { -inter_module_unregister ("drm" ); +drm_stub_unset ();DRM (free)(DRM (stub_list),sizeof (*DRM (stub_list)) *DRM_STUB_MAXCARDS ,DRM_MEM_STUB );
@@ -124,7 +130,7 @@ int DRM(stub_register)(const char *name,DRM_DEBUG ("\n" );if (register_chrdev (DRM_MAJOR ,"drm" , &DRM (stub_fops))) - i = (struct drm_stub_info *)inter_module_get ("drm" ); + i =drm_stub_get ();if (i) {/* Already registered */
@@ -134,8 +140,8 @@ int DRM(stub_register)(const char *name, }else if (DRM (stub_info).info_register !=DRM (stub_getminor)) {DRM (stub_info).info_register =DRM (stub_getminor);DRM (stub_info).info_unregister =DRM (stub_putminor); -DRM_DEBUG ("calling inter_module_register\n" ); -inter_module_register ("drm" ,THIS_MODULE , &DRM (stub_info)); +DRM_DEBUG ("calling drm_stub_set\n" ); +drm_stub_set (&DRM (stub_info),THIS_MODULE ); }if (DRM (stub_info).info_register)return DRM (stub_info).info_register (name, fops, dev);
drivers/char/misc.c +39 -0
@@ -287,3 +287,42 @@ int __init misc_init(void) }return 0 ; } + +/* This (racy) hack is here because the DRM coders are taking +Linux-incompatible drugs */ +#if defined(CONFIG_DRM ) || defined(CONFIG_DRM_MODULE ) +struct drm_stub_info ; + +static struct drm_stub_info *drm_stub; +static struct module *drm_stub_owner; + +/* Registers a new stub. */ +void drm_stub_set (struct drm_stub_info *stub_info,struct module *owner) +{ + drm_stub = stub_info; + drm_stub_owner = owner; +} +void drm_stub_unset (void ) +{ + drm_stub =NULL ; + drm_stub_owner =NULL ; +} + +/* Get and put. */ +struct drm_stub_info *drm_stub_get (void ) +{ +if (drm_stub) { +__MOD_INC_USE_COUNT (drm_stub_owner); +return drm_stub; + } +return NULL ; +} +void drm_stub_put (void ) +{ +module_put (drm_stub_owner); +} +EXPORT_SYMBOL (drm_stub_set); +EXPORT_SYMBOL (drm_stub_unset); +EXPORT_SYMBOL (drm_stub_get); +EXPORT_SYMBOL (drm_stub_put); +#endif
drivers/mtd/Makefile +0 -16
@@ -8,22 +8,6 @@ export-objs := mtdcore.o mtdpart.o redbo obj-y += chips/ maps/ devices/ nand/ -# *** BIG UGLY NOTE *** -# -# The shiny new inter_module_xxx has introduced yet another ugly link -# order dependency, which I'd previously taken great care to avoid. -# We now have to ensure that the chip drivers are initialised before the -# map drivers, and that the doc200[01] drivers are initialised before -# docprobe. -# -# We'll hopefully merge the doc200[01] drivers and docprobe back into -# a single driver some time soon, but the CFI drivers are going to have -# to stay like that. -# -# Urgh. -# -# dwmw2 21/11/0 - # Core functionality. obj-$(CONFIG_MTD) += mtdcore.o obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o
drivers/mtd/chips/Makefile +1 -8
@@ -3,14 +3,7 @@ # # $Id: Makefile,v 1.7 2001/10/05 06:53:51 dwmw2 Exp $ -export-objs := chipreg.o gen_probe.o - -# *** BIG UGLY NOTE *** -# -# The removal of get_module_symbol() and replacement with -# inter_module_register() et al has introduced a link order dependency -# here where previously there was none. We now have to ensure that -# the CFI command set drivers are linked before cfi_probe.o +export-objs := chipreg.o gen_probe.o cfi_cmdset_0001.o cfi_cmdset_0002.o obj-$(CONFIG_MTD) += chipreg.o obj-$(CONFIG_MTD_AMDSTD) += amd_flash.o
drivers/mtd/chips/cfi_cmdset_0001.c +4 -14
@@ -97,13 +97,6 @@ static void cfi_tell_features(struct cfi }#endif -/* This routine is made available to other mtd code via -* inter_module_register. It must only be accessed through -* inter_module_get which will bump the use count of this module. The -* addresses passed back in cfi are valid as long as the use count of -* this module is non-zero, i.e. between inter_module_get and -* inter_module_put. Keith Owens <[email protected]> 29 Oct 2000. -*/ struct mtd_info *cfi_cmdset_0001 (struct map_info *map,int primary) {struct cfi_private *cfi = map->fldrv_priv;
@@ -1601,22 +1594,19 @@ static void cfi_intelext_destroy(structkfree (cfi); } -static char im_name_1[]="cfi_cmdset_0001" ; -static char im_name_3[]="cfi_cmdset_0003" ; -int __init cfi_intelext_init (void ) { -inter_module_register (im_name_1,THIS_MODULE , &cfi_cmdset_0001); -inter_module_register (im_name_3,THIS_MODULE , &cfi_cmdset_0001);return 0 ; } static void __exit cfi_intelext_exit(void) { -inter_module_unregister (im_name_1); -inter_module_unregister (im_name_3); } +struct mtd_info *cfi_cmdset_0003 (struct map_info *map,int primary) __attribute__((alias ("cfi_cmdset_0001" ))); +EXPORT_SYMBOL (cfi_cmdset_0001); +EXPORT_SYMBOL (cfi_cmdset_0003); +module_init (cfi_intelext_init);module_exit (cfi_intelext_exit);
drivers/mtd/chips/cfi_cmdset_0002.c +2 -4
@@ -934,19 +934,17 @@ static void cfi_amdstd_destroy(struct mtkfree (cfi); } -static char im_name[]="cfi_cmdset_0002" ; -int __init cfi_amdstd_init (void ) { -inter_module_register (im_name,THIS_MODULE , &cfi_cmdset_0002);return 0 ; } static void __exit cfi_amdstd_exit(void) { -inter_module_unregister (im_name); } +EXPORT_SYMBOL (cfi_cmdset_0002); +module_init (cfi_amdstd_init);module_exit (cfi_amdstd_exit);
drivers/mtd/chips/gen_probe.c +28 -33
87 lines not on this page · raw message
drivers/mtd/devices/Makefile +1 -6
@@ -3,12 +3,7 @@ # # $Id: Makefile,v 1.4 2001/06/26 21:10:05 spse Exp $ -# *** BIG UGLY NOTE *** -# -# The removal of get_module_symbol() and replacement with -# inter_module_register() et al has introduced a link order dependency -# here where previously there was none. We now have to ensure that -# doc200[01].o are linked before docprobe.o +export-objs := doc1000.o doc2000.o doc2001.o obj-$(CONFIG_MTD_DOC1000) += doc1000.o obj-$(CONFIG_MTD_DOC2000) += doc2000.o
drivers/mtd/devices/doc2000.c +3 -12
@@ -503,16 +503,7 @@ static int DoC2k_is_alias(struct DiskOnCreturn retval; } -static const char im_name[] ="DoC2k_init" ; - -/* This routine is made available to other mtd code via -* inter_module_register. It must only be accessed through -* inter_module_get which will bump the use count of this module. The -* addresses passed back in mtd are valid as long as the use count of -* this module is non-zero, i.e. between inter_module_get and -* inter_module_put. Keith Owens <[email protected]> 29 Oct 2000. -*/ -static void DoC2k_init (struct mtd_info *mtd) +void DoC2k_init (struct mtd_info *mtd) {struct DiskOnChip *this = (struct DiskOnChip *) mtd->priv;struct DiskOnChip *old =NULL ;
@@ -1143,7 +1134,6 @@ static int doc_erase(struct mtd_info *mtint __init init_doc2000 (void ) { -inter_module_register (im_name,THIS_MODULE , &DoC2k_init);return 0 ; }
@@ -1162,9 +1152,10 @@ static void __exit cleanup_doc2000(void)kfree (this->chips);kfree (mtd); } -inter_module_unregister (im_name); } +EXPORT_SYMBOL (DoC2k_init); +module_exit (cleanup_doc2000);module_init (init_doc2000);
drivers/mtd/devices/doc2001.c +3 -12
@@ -318,16 +318,7 @@ static int DoCMil_is_alias(struct DiskOnreturn retval; } -static const char im_name[] ="DoCMil_init" ; - -/* This routine is made available to other mtd code via -* inter_module_register. It must only be accessed through -* inter_module_get which will bump the use count of this module. The -* addresses passed back in mtd are valid as long as the use count of -* this module is non-zero, i.e. between inter_module_get and -* inter_module_put. Keith Owens <[email protected]> 29 Oct 2000. -*/ -static void DoCMil_init (struct mtd_info *mtd) +void DoCMil_init (struct mtd_info *mtd) {struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;struct DiskOnChip *old =NULL ;
@@ -850,7 +841,6 @@ int doc_erase (struct mtd_info *mtd, strint __init init_doc2001 (void ) { -inter_module_register (im_name,THIS_MODULE , &DoCMil_init);return 0 ; }
@@ -869,12 +859,13 @@ static void __exit cleanup_doc2001(void)kfree (this->chips);kfree (mtd); } -inter_module_unregister (im_name); }module_exit (cleanup_doc2001);module_init (init_doc2001); +EXPORT_SYMBOL (DoCMil_init); +MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("David Woodhouse <[email protected]> et al." );MODULE_DESCRIPTION ("Alternative driver for DiskOnChip Millennium" );
drivers/mtd/devices/docprobe.c +4 -10
@@ -219,28 +219,22 @@ static void __init DoC_Probe(unsigned loswitch (ChipID) {case DOC_ChipID_Doc2k: name="2000" ; - im_funcname ="DoC2k_init" ; - im_modname ="doc2000" ; + initroutine =symbol_request (DoC2k_init);break ;case DOC_ChipID_DocMil: name="Millennium" ;#ifdef DOC_SINGLE_DRIVER - im_funcname ="DoC2k_init" ; - im_modname ="doc2000" ; + initroutine =symbol_request (DoC2k_init);#else - im_funcname ="DoCMil_init" ; - im_modname ="doc2001" ; + initroutine =symbol_request (DoCMil_init);#endif /* DOC_SINGLE_DRIVER */ break ; } -if (im_funcname) - initroutine =inter_module_get_request (im_funcname, im_modname); -if (initroutine) { (*initroutine)(mtd); -inter_module_put (im_funcname); +symbol_put_addr (initroutine);return ; }printk (KERN_NOTICE "Cannot find driver for DiskOnChip %s at 0x%lX\n" , name, physadr);
include/linux/agp_backend.h +2 -7
@@ -262,12 +262,7 @@ typedef struct { int (*copy_info)(agp_kern_info *); } drm_agp_t; -extern const drm_agp_t *drm_agp_p; - -/* -* Interface between drm and agp code. When agp initializes, it makes -* the above structure available via inter_module_register(), drm might -* use it. Keith Owens <[email protected]> 28 Oct 2000. -*/ +/* Used by drm. */ +extern const drm_agp_t agp_drm;#endif /* _AGP_BACKEND_H */
include/linux/mtd/cfi.h +0 -1
@@ -247,7 +247,6 @@ struct cfi_private {int mfr, id;int numchips;unsigned long chipshift;/* Because they're of the same type */ -const char *im_name;/* inter_module name for cmdset_setup */ struct flchip chips[0 ];/* per-chip data structure for each chip */ };
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
PATCH 1/1 Module rewrite series 3/5: KBUILD_MODNAME.
In reply to Rusty RussellSeparate lkml-attach version due to size. Note that your kernel won't compile after this: you need arch support, and almost all functionality other than loading and unloading is not implemented:
they are handled in follow-on patches (which all exist 8).
Diffstat breakdown:
Core:
include/linux/init.h | 100 - kernel/module.c | 10 include/linux/kmod.h | 1 include/linux/module.h | 698 ++------ kernel/kmod.c | 2 kernel/ksyms.c | 8 kernel/module.c | 2052 ++++++++++-------------- fs/proc/proc_misc.c | 12 include/linux/elf.h | 45 init/Kconfig | 21 init/main.c | 5 kernel/sys.c | 2
Build (and commenting out kallsyms for the moment):
Makefile | 17 kernel/Makefile | 4 arch/i386/Kconfig | 15 arch/ia64/Kconfig | 14 arch/ppc/Kconfig | 6 arch/x86_64/Kconfig | 14 scripts/Makefile.modinst | 4
Broken by module.h not including version.h:
drivers/block/floppy.c | 1
Uses can_unload():
drivers/char/ftape/compressor/zftape-compress.c | 9 net/ipv6/af_inet6.c | 5
Deref struct module even when !CONFIG_MODULES:
kernel/exec_domain.c | 7 net/ipv4/netfilter/ip_nat_helper.c | 8
Hacks refcounts directly:
fs/filesystems.c | 16
Needs "no_module_init;" declaration:
lib/zlib_deflate/deflate_syms.c | 2 lib/zlib_inflate/inflate_syms.c | 2 29 files changed, 1330 insertions(+), 1758 deletions(-)
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.