aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/module.h53
-rw-r--r--include/linux/moduleparam.h12
-rw-r--r--kernel/module.c14
-rw-r--r--kernel/params.c28
4 files changed, 81 insertions, 26 deletions
diff --git a/include/linux/module.h b/include/linux/module.h
index 419d3ef293dd..95679eb8571e 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -76,8 +76,6 @@ void sort_extable(struct exception_table_entry *start,
76 struct exception_table_entry *finish); 76 struct exception_table_entry *finish);
77void sort_main_extable(void); 77void sort_main_extable(void);
78 78
79extern struct subsystem module_subsys;
80
81#ifdef MODULE 79#ifdef MODULE
82#define MODULE_GENERIC_TABLE(gtype,name) \ 80#define MODULE_GENERIC_TABLE(gtype,name) \
83extern const struct gtype##_id __mod_##gtype##_table \ 81extern const struct gtype##_id __mod_##gtype##_table \
@@ -467,10 +465,6 @@ int unregister_module_notifier(struct notifier_block * nb);
467 465
468extern void print_modules(void); 466extern void print_modules(void);
469 467
470struct device_driver;
471void module_add_driver(struct module *, struct device_driver *);
472void module_remove_driver(struct device_driver *);
473
474#else /* !CONFIG_MODULES... */ 468#else /* !CONFIG_MODULES... */
475#define EXPORT_SYMBOL(sym) 469#define EXPORT_SYMBOL(sym)
476#define EXPORT_SYMBOL_GPL(sym) 470#define EXPORT_SYMBOL_GPL(sym)
@@ -568,18 +562,59 @@ static inline void print_modules(void)
568{ 562{
569} 563}
570 564
565#endif /* CONFIG_MODULES */
566
571struct device_driver; 567struct device_driver;
568#ifdef CONFIG_SYSFS
572struct module; 569struct module;
573 570
574static inline void module_add_driver(struct module *module, struct device_driver *driver) 571extern struct subsystem module_subsys;
572
573int mod_sysfs_init(struct module *mod);
574int mod_sysfs_setup(struct module *mod,
575 struct kernel_param *kparam,
576 unsigned int num_params);
577int module_add_modinfo_attrs(struct module *mod);
578void module_remove_modinfo_attrs(struct module *mod);
579
580#else /* !CONFIG_SYSFS */
581
582static inline int mod_sysfs_init(struct module *mod)
575{ 583{
584 return 0;
576} 585}
577 586
578static inline void module_remove_driver(struct device_driver *driver) 587static inline int mod_sysfs_setup(struct module *mod,
588 struct kernel_param *kparam,
589 unsigned int num_params)
579{ 590{
591 return 0;
580} 592}
581 593
582#endif /* CONFIG_MODULES */ 594static inline int module_add_modinfo_attrs(struct module *mod)
595{
596 return 0;
597}
598
599static inline void module_remove_modinfo_attrs(struct module *mod)
600{ }
601
602#endif /* CONFIG_SYSFS */
603
604#if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)
605
606void module_add_driver(struct module *mod, struct device_driver *drv);
607void module_remove_driver(struct device_driver *drv);
608
609#else /* not both CONFIG_SYSFS && CONFIG_MODULES */
610
611static inline void module_add_driver(struct module *mod, struct device_driver *drv)
612{ }
613
614static inline void module_remove_driver(struct device_driver *drv)
615{ }
616
617#endif
583 618
584#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) 619#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
585 620
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 4a189dadb160..b26b2e5fedc7 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -169,10 +169,22 @@ extern int param_get_string(char *buffer, struct kernel_param *kp);
169 169
170struct module; 170struct module;
171 171
172#if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)
172extern int module_param_sysfs_setup(struct module *mod, 173extern int module_param_sysfs_setup(struct module *mod,
173 struct kernel_param *kparam, 174 struct kernel_param *kparam,
174 unsigned int num_params); 175 unsigned int num_params);
175 176
176extern void module_param_sysfs_remove(struct module *mod); 177extern void module_param_sysfs_remove(struct module *mod);
178#else
179static inline int module_param_sysfs_setup(struct module *mod,
180 struct kernel_param *kparam,
181 unsigned int num_params)
182{
183 return 0;
184}
185
186static inline void module_param_sysfs_remove(struct module *mod)
187{ }
188#endif
177 189
178#endif /* _LINUX_MODULE_PARAMS_H */ 190#endif /* _LINUX_MODULE_PARAMS_H */
diff --git a/kernel/module.c b/kernel/module.c
index e06b77af23fd..8c25b1a04fa6 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1074,7 +1074,8 @@ static inline void remove_sect_attrs(struct module *mod)
1074} 1074}
1075#endif /* CONFIG_KALLSYMS */ 1075#endif /* CONFIG_KALLSYMS */
1076 1076
1077static int module_add_modinfo_attrs(struct module *mod) 1077#ifdef CONFIG_SYSFS
1078int module_add_modinfo_attrs(struct module *mod)
1078{ 1079{
1079 struct module_attribute *attr; 1080 struct module_attribute *attr;
1080 struct module_attribute *temp_attr; 1081 struct module_attribute *temp_attr;
@@ -1100,7 +1101,7 @@ static int module_add_modinfo_attrs(struct module *mod)
1100 return error; 1101 return error;
1101} 1102}
1102 1103
1103static void module_remove_modinfo_attrs(struct module *mod) 1104void module_remove_modinfo_attrs(struct module *mod)
1104{ 1105{
1105 struct module_attribute *attr; 1106 struct module_attribute *attr;
1106 int i; 1107 int i;
@@ -1115,8 +1116,10 @@ static void module_remove_modinfo_attrs(struct module *mod)
1115 } 1116 }
1116 kfree(mod->modinfo_attrs); 1117 kfree(mod->modinfo_attrs);
1117} 1118}
1119#endif
1118 1120
1119static int mod_sysfs_init(struct module *mod) 1121#ifdef CONFIG_SYSFS
1122int mod_sysfs_init(struct module *mod)
1120{ 1123{
1121 int err; 1124 int err;
1122 1125
@@ -1139,7 +1142,7 @@ out:
1139 return err; 1142 return err;
1140} 1143}
1141 1144
1142static int mod_sysfs_setup(struct module *mod, 1145int mod_sysfs_setup(struct module *mod,
1143 struct kernel_param *kparam, 1146 struct kernel_param *kparam,
1144 unsigned int num_params) 1147 unsigned int num_params)
1145{ 1148{
@@ -1175,6 +1178,7 @@ out_unreg:
1175out: 1178out:
1176 return err; 1179 return err;
1177} 1180}
1181#endif
1178 1182
1179static void mod_kobject_remove(struct module *mod) 1183static void mod_kobject_remove(struct module *mod)
1180{ 1184{
@@ -2348,6 +2352,7 @@ void print_modules(void)
2348 printk("\n"); 2352 printk("\n");
2349} 2353}
2350 2354
2355#ifdef CONFIG_SYSFS
2351static char *make_driver_name(struct device_driver *drv) 2356static char *make_driver_name(struct device_driver *drv)
2352{ 2357{
2353 char *driver_name; 2358 char *driver_name;
@@ -2422,6 +2427,7 @@ void module_remove_driver(struct device_driver *drv)
2422 } 2427 }
2423} 2428}
2424EXPORT_SYMBOL(module_remove_driver); 2429EXPORT_SYMBOL(module_remove_driver);
2430#endif
2425 2431
2426#ifdef CONFIG_MODVERSIONS 2432#ifdef CONFIG_MODVERSIONS
2427/* Generate the signature for struct module here, too, for modversions. */ 2433/* Generate the signature for struct module here, too, for modversions. */
diff --git a/kernel/params.c b/kernel/params.c
index 7d231c6c1334..7a751570b56d 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -30,8 +30,6 @@
30#define DEBUGP(fmt, a...) 30#define DEBUGP(fmt, a...)
31#endif 31#endif
32 32
33static struct kobj_type module_ktype;
34
35static inline char dash2underscore(char c) 33static inline char dash2underscore(char c)
36{ 34{
37 if (c == '-') 35 if (c == '-')
@@ -391,6 +389,7 @@ struct module_param_attrs
391 struct param_attribute attrs[0]; 389 struct param_attribute attrs[0];
392}; 390};
393 391
392#ifdef CONFIG_SYSFS
394#define to_param_attr(n) container_of(n, struct param_attribute, mattr); 393#define to_param_attr(n) container_of(n, struct param_attribute, mattr);
395 394
396static ssize_t param_attr_show(struct module_attribute *mattr, 395static ssize_t param_attr_show(struct module_attribute *mattr,
@@ -426,6 +425,7 @@ static ssize_t param_attr_store(struct module_attribute *mattr,
426 return len; 425 return len;
427 return err; 426 return err;
428} 427}
428#endif
429 429
430#ifdef CONFIG_MODULES 430#ifdef CONFIG_MODULES
431#define __modinit 431#define __modinit
@@ -433,6 +433,7 @@ static ssize_t param_attr_store(struct module_attribute *mattr,
433#define __modinit __init 433#define __modinit __init
434#endif 434#endif
435 435
436#ifdef CONFIG_SYSFS
436/* 437/*
437 * param_sysfs_setup - setup sysfs support for one module or KBUILD_MODNAME 438 * param_sysfs_setup - setup sysfs support for one module or KBUILD_MODNAME
438 * @mk: struct module_kobject (contains parent kobject) 439 * @mk: struct module_kobject (contains parent kobject)
@@ -500,9 +501,7 @@ param_sysfs_setup(struct module_kobject *mk,
500 return mp; 501 return mp;
501} 502}
502 503
503
504#ifdef CONFIG_MODULES 504#ifdef CONFIG_MODULES
505
506/* 505/*
507 * module_param_sysfs_setup - setup sysfs support for one module 506 * module_param_sysfs_setup - setup sysfs support for one module
508 * @mod: module 507 * @mod: module
@@ -625,7 +624,6 @@ static void __init param_sysfs_builtin(void)
625 624
626 625
627/* module-related sysfs stuff */ 626/* module-related sysfs stuff */
628#ifdef CONFIG_SYSFS
629 627
630#define to_module_attr(n) container_of(n, struct module_attribute, attr); 628#define to_module_attr(n) container_of(n, struct module_attribute, attr);
631#define to_module_kobject(n) container_of(n, struct module_kobject, kobj); 629#define to_module_kobject(n) container_of(n, struct module_kobject, kobj);
@@ -673,6 +671,8 @@ static struct sysfs_ops module_sysfs_ops = {
673 .store = module_attr_store, 671 .store = module_attr_store,
674}; 672};
675 673
674static struct kobj_type module_ktype;
675
676static int uevent_filter(struct kset *kset, struct kobject *kobj) 676static int uevent_filter(struct kset *kset, struct kobject *kobj)
677{ 677{
678 struct kobj_type *ktype = get_ktype(kobj); 678 struct kobj_type *ktype = get_ktype(kobj);
@@ -686,19 +686,12 @@ static struct kset_uevent_ops module_uevent_ops = {
686 .filter = uevent_filter, 686 .filter = uevent_filter,
687}; 687};
688 688
689#else 689decl_subsys(module, &module_ktype, &module_uevent_ops);
690static struct sysfs_ops module_sysfs_ops = {
691 .show = NULL,
692 .store = NULL,
693};
694#endif
695 690
696static struct kobj_type module_ktype = { 691static struct kobj_type module_ktype = {
697 .sysfs_ops = &module_sysfs_ops, 692 .sysfs_ops = &module_sysfs_ops,
698}; 693};
699 694
700decl_subsys(module, &module_ktype, &module_uevent_ops);
701
702/* 695/*
703 * param_sysfs_init - wrapper for built-in params support 696 * param_sysfs_init - wrapper for built-in params support
704 */ 697 */
@@ -720,6 +713,15 @@ static int __init param_sysfs_init(void)
720} 713}
721subsys_initcall(param_sysfs_init); 714subsys_initcall(param_sysfs_init);
722 715
716#else
717#if 0
718static struct sysfs_ops module_sysfs_ops = {
719 .show = NULL,
720 .store = NULL,
721};
722#endif
723#endif
724
723EXPORT_SYMBOL(param_set_byte); 725EXPORT_SYMBOL(param_set_byte);
724EXPORT_SYMBOL(param_get_byte); 726EXPORT_SYMBOL(param_get_byte);
725EXPORT_SYMBOL(param_set_short); 727EXPORT_SYMBOL(param_set_short);