aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/params.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/params.c')
-rw-r--r--kernel/params.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/kernel/params.c b/kernel/params.c
index 718945da8f58..e265b13195b1 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -389,6 +389,7 @@ struct module_param_attrs
389 struct param_attribute attrs[0]; 389 struct param_attribute attrs[0];
390}; 390};
391 391
392#ifdef CONFIG_SYSFS
392#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);
393 394
394static ssize_t param_attr_show(struct module_attribute *mattr, 395static ssize_t param_attr_show(struct module_attribute *mattr,
@@ -424,6 +425,7 @@ static ssize_t param_attr_store(struct module_attribute *mattr,
424 return len; 425 return len;
425 return err; 426 return err;
426} 427}
428#endif
427 429
428#ifdef CONFIG_MODULES 430#ifdef CONFIG_MODULES
429#define __modinit 431#define __modinit
@@ -431,6 +433,7 @@ static ssize_t param_attr_store(struct module_attribute *mattr,
431#define __modinit __init 433#define __modinit __init
432#endif 434#endif
433 435
436#ifdef CONFIG_SYSFS
434/* 437/*
435 * 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
436 * @mk: struct module_kobject (contains parent kobject) 439 * @mk: struct module_kobject (contains parent kobject)
@@ -498,9 +501,7 @@ param_sysfs_setup(struct module_kobject *mk,
498 return mp; 501 return mp;
499} 502}
500 503
501
502#ifdef CONFIG_MODULES 504#ifdef CONFIG_MODULES
503
504/* 505/*
505 * module_param_sysfs_setup - setup sysfs support for one module 506 * module_param_sysfs_setup - setup sysfs support for one module
506 * @mod: module 507 * @mod: module
@@ -561,14 +562,11 @@ static void __init kernel_param_sysfs_setup(const char *name,
561 mk->mod = THIS_MODULE; 562 mk->mod = THIS_MODULE;
562 kobj_set_kset_s(mk, module_subsys); 563 kobj_set_kset_s(mk, module_subsys);
563 kobject_set_name(&mk->kobj, name); 564 kobject_set_name(&mk->kobj, name);
564 ret = kobject_register(&mk->kobj); 565 kobject_init(&mk->kobj);
566 ret = kobject_add(&mk->kobj);
565 BUG_ON(ret < 0); 567 BUG_ON(ret < 0);
566 568 param_sysfs_setup(mk, kparam, num_params, name_skip);
567 /* no need to keep the kobject if no parameter is exported */ 569 kobject_uevent(&mk->kobj, KOBJ_ADD);
568 if (!param_sysfs_setup(mk, kparam, num_params, name_skip)) {
569 kobject_unregister(&mk->kobj);
570 kfree(mk);
571 }
572} 570}
573 571
574/* 572/*
@@ -626,7 +624,6 @@ static void __init param_sysfs_builtin(void)
626 624
627 625
628/* module-related sysfs stuff */ 626/* module-related sysfs stuff */
629#ifdef CONFIG_SYSFS
630 627
631#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);
632#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);
@@ -674,19 +671,27 @@ static struct sysfs_ops module_sysfs_ops = {
674 .store = module_attr_store, 671 .store = module_attr_store,
675}; 672};
676 673
677#else 674static struct kobj_type module_ktype;
678static struct sysfs_ops module_sysfs_ops = { 675
679 .show = NULL, 676static int uevent_filter(struct kset *kset, struct kobject *kobj)
680 .store = NULL, 677{
678 struct kobj_type *ktype = get_ktype(kobj);
679
680 if (ktype == &module_ktype)
681 return 1;
682 return 0;
683}
684
685static struct kset_uevent_ops module_uevent_ops = {
686 .filter = uevent_filter,
681}; 687};
682#endif 688
689decl_subsys(module, &module_ktype, &module_uevent_ops);
683 690
684static struct kobj_type module_ktype = { 691static struct kobj_type module_ktype = {
685 .sysfs_ops = &module_sysfs_ops, 692 .sysfs_ops = &module_sysfs_ops,
686}; 693};
687 694
688decl_subsys(module, &module_ktype, NULL);
689
690/* 695/*
691 * param_sysfs_init - wrapper for built-in params support 696 * param_sysfs_init - wrapper for built-in params support
692 */ 697 */
@@ -707,6 +712,15 @@ static int __init param_sysfs_init(void)
707} 712}
708subsys_initcall(param_sysfs_init); 713subsys_initcall(param_sysfs_init);
709 714
715#else
716#if 0
717static struct sysfs_ops module_sysfs_ops = {
718 .show = NULL,
719 .store = NULL,
720};
721#endif
722#endif
723
710EXPORT_SYMBOL(param_set_byte); 724EXPORT_SYMBOL(param_set_byte);
711EXPORT_SYMBOL(param_get_byte); 725EXPORT_SYMBOL(param_get_byte);
712EXPORT_SYMBOL(param_set_short); 726EXPORT_SYMBOL(param_set_short);