All of lore.kernel.org
 help / color / mirror / Atom feed
* build errors: uevent with CONFIG_SYSFS=n
@ 2007-02-12 21:50 Randy Dunlap
  2007-02-12 22:29 ` [PATCH] " Randy Dunlap
  0 siblings, 1 reply; 4+ messages in thread
From: Randy Dunlap @ 2007-02-12 21:50 UTC (permalink / raw)
  To: lkml; +Cc: gregkh


in kernel/params.c:

kernel/params.c:700: error: 'module_uevent_ops' undeclared here (not in a function)

in kernel/module.c:

kernel/built-in.o: In function `module_add_driver':
(.text+0x20c5b): undefined reference to `module_subsys'
kernel/built-in.o: In function `sys_init_module':
(.text+0x2177c): undefined reference to `module_subsys'
kernel/built-in.o: In function `sys_init_module':
(.text+0x21838): undefined reference to `module_subsys'
kernel/built-in.o: In function `kernel_param_sysfs_setup':
params.c:(.init.text+0x1492): undefined reference to `module_subsys'
kernel/built-in.o: In function `param_sysfs_init':
params.c:(.init.text+0x14f8): undefined reference to `module_subsys'

Are these already fixed?


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] build errors: uevent with CONFIG_SYSFS=n
  2007-02-12 21:50 build errors: uevent with CONFIG_SYSFS=n Randy Dunlap
@ 2007-02-12 22:29 ` Randy Dunlap
  2007-02-12 22:58   ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Randy Dunlap @ 2007-02-12 22:29 UTC (permalink / raw)
  To: akpm; +Cc: lkml, gregkh

On Mon, 12 Feb 2007 13:50:21 -0800 Randy Dunlap wrote:

> 
> in kernel/params.c:
> 
> kernel/params.c:700: error: 'module_uevent_ops' undeclared here (not in a function)
> 
> in kernel/module.c:
> 
> kernel/built-in.o: In function `module_add_driver':
> (.text+0x20c5b): undefined reference to `module_subsys'
> kernel/built-in.o: In function `sys_init_module':
> (.text+0x2177c): undefined reference to `module_subsys'
> kernel/built-in.o: In function `sys_init_module':
> (.text+0x21838): undefined reference to `module_subsys'
> kernel/built-in.o: In function `kernel_param_sysfs_setup':
> params.c:(.init.text+0x1492): undefined reference to `module_subsys'
> kernel/built-in.o: In function `param_sysfs_init':
> params.c:(.init.text+0x14f8): undefined reference to `module_subsys'
> 
> Are these already fixed?

Here's a patch, tested both ways (SYSFS=y, SYSFS=n).

---
From: Randy Dunlap <randy.dunlap@oracle.com>

Fix source files to build with CONFIG_SYSFS=n.
module_subsys is not available.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
 drivers/base/bus.c |    4 ++++
 kernel/module.c    |   10 ++++++++++
 kernel/params.c    |   20 ++++++++++----------
 3 files changed, 24 insertions(+), 10 deletions(-)

--- linux-2.6.20-git7.orig/kernel/params.c
+++ linux-2.6.20-git7/kernel/params.c
@@ -30,8 +30,6 @@
 #define DEBUGP(fmt, a...)
 #endif
 
-static struct kobj_type module_ktype;
-
 static inline char dash2underscore(char c)
 {
 	if (c == '-')
@@ -673,6 +671,8 @@ static struct sysfs_ops module_sysfs_ops
 	.store = module_attr_store,
 };
 
+static struct kobj_type module_ktype;
+
 static int uevent_filter(struct kset *kset, struct kobject *kobj)
 {
 	struct kobj_type *ktype = get_ktype(kobj);
@@ -686,19 +686,12 @@ static struct kset_uevent_ops module_uev
 	.filter = uevent_filter,
 };
 
-#else
-static struct sysfs_ops module_sysfs_ops = {
-	.show = NULL,
-	.store = NULL,
-};
-#endif
+decl_subsys(module, &module_ktype, &module_uevent_ops);
 
 static struct kobj_type module_ktype = {
 	.sysfs_ops =	&module_sysfs_ops,
 };
 
-decl_subsys(module, &module_ktype, &module_uevent_ops);
-
 /*
  * param_sysfs_init - wrapper for built-in params support
  */
@@ -719,6 +712,13 @@ static int __init param_sysfs_init(void)
 }
 subsys_initcall(param_sysfs_init);
 
+#else
+static struct sysfs_ops module_sysfs_ops = {
+	.show = NULL,
+	.store = NULL,
+};
+#endif
+
 EXPORT_SYMBOL(param_set_byte);
 EXPORT_SYMBOL(param_get_byte);
 EXPORT_SYMBOL(param_set_short);
--- linux-2.6.20-git7.orig/kernel/module.c
+++ linux-2.6.20-git7/kernel/module.c
@@ -1110,6 +1110,7 @@ static void module_remove_modinfo_attrs(
 	kfree(mod->modinfo_attrs);
 }
 
+#ifdef CONFIG_SYSFS
 static int mod_sysfs_init(struct module *mod)
 {
 	int err;
@@ -1148,6 +1149,7 @@ static int mod_sysfs_setup(struct module
 	if (!mod->holders_dir)
 		goto out_unreg;
 
+#ifdef CONFIG_SYSFS
 	err = module_param_sysfs_setup(mod, kparam, num_params);
 	if (err)
 		goto out_unreg_holders;
@@ -1155,6 +1157,7 @@ static int mod_sysfs_setup(struct module
 	err = module_add_modinfo_attrs(mod);
 	if (err)
 		goto out_unreg_param;
+#endif
 
 	kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD);
 	return 0;
@@ -1169,6 +1172,7 @@ out_unreg:
 out:
 	return err;
 }
+#endif
 
 static void mod_kobject_remove(struct module *mod)
 {
@@ -1782,9 +1786,11 @@ static struct module *load_module(void _
 	/* Now we've moved module, initialize linked lists, etc. */
 	module_unload_init(mod);
 
+#ifdef CONFIG_SYSFS
 	/* Initialize kobject, so we can reference it. */
 	if (mod_sysfs_init(mod) != 0)
 		goto cleanup;
+#endif
 
 	/* Set up license info based on the info section */
 	set_license(mod, get_modinfo(sechdrs, infoindex, "license"));
@@ -1917,6 +1923,7 @@ static struct module *load_module(void _
 	if (err < 0)
 		goto arch_cleanup;
 
+#ifdef CONFIG_SYSFS
 	err = mod_sysfs_setup(mod, 
 			      (struct kernel_param *)
 			      sechdrs[setupindex].sh_addr,
@@ -1924,6 +1931,7 @@ static struct module *load_module(void _
 			      / sizeof(struct kernel_param));
 	if (err < 0)
 		goto arch_cleanup;
+#endif
 	add_sect_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
 
 	/* Size of section 0 is 0, so this works well if no unwind info. */
@@ -2366,6 +2374,7 @@ static void module_create_drivers_dir(st
 	mk->drivers_dir = kobject_add_dir(&mk->kobj, "drivers");
 }
 
+#ifdef CONFIG_SYSFS
 void module_add_driver(struct module *mod, struct device_driver *drv)
 {
 	char *driver_name;
@@ -2419,6 +2428,7 @@ void module_remove_driver(struct device_
 	}
 }
 EXPORT_SYMBOL(module_remove_driver);
+#endif
 
 #ifdef CONFIG_MODVERSIONS
 /* Generate the signature for struct module here, too, for modversions. */
--- linux-2.6.20-git7.orig/drivers/base/bus.c
+++ linux-2.6.20-git7/drivers/base/bus.c
@@ -547,7 +547,9 @@ int bus_add_driver(struct device_driver 
 	if (error)
 		goto out_unregister;
 	klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
+#ifdef CONFIG_SYSFS
 	module_add_driver(drv->owner, drv);
+#endif
 
 	error = driver_add_attrs(bus, drv);
 	if (error) {
@@ -589,7 +591,9 @@ void bus_remove_driver(struct device_dri
 	klist_remove(&drv->knode_bus);
 	pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
 	driver_detach(drv);
+#ifdef CONFIG_SYSFS
 	module_remove_driver(drv);
+#endif
 	kobject_unregister(&drv->kobj);
 	put_bus(drv->bus);
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] build errors: uevent with CONFIG_SYSFS=n
  2007-02-12 22:29 ` [PATCH] " Randy Dunlap
@ 2007-02-12 22:58   ` Andrew Morton
  2007-02-13 23:19     ` [PATCH v2] " Randy Dunlap
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2007-02-12 22:58 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-kernel, gregkh

> On Mon, 12 Feb 2007 14:29:19 -0800 Randy Dunlap <randy.dunlap@oracle.com> wrote:
> Here's a patch, tested both ways (SYSFS=y, SYSFS=n).
> 
> ---
> From: Randy Dunlap <randy.dunlap@oracle.com>
> 
> Fix source files to build with CONFIG_SYSFS=n.
> module_subsys is not available.

erk.  Can we get some stubs in the header file to reduce the need for ifdeffing?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] build errors: uevent with CONFIG_SYSFS=n
  2007-02-12 22:58   ` Andrew Morton
@ 2007-02-13 23:19     ` Randy Dunlap
  0 siblings, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2007-02-13 23:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, gregkh

On Mon, 12 Feb 2007 14:58:23 -0800 Andrew Morton wrote:

> > On Mon, 12 Feb 2007 14:29:19 -0800 Randy Dunlap <randy.dunlap@oracle.com> wrote:
> > Here's a patch, tested both ways (SYSFS=y, SYSFS=n).
> > 
> > ---
> > From: Randy Dunlap <randy.dunlap@oracle.com>
> > 
> > Fix source files to build with CONFIG_SYSFS=n.
> > module_subsys is not available.
> 
> erk.  Can we get some stubs in the header file to reduce the need for ifdeffing?

er, ok.  This now builds cleanly with all 4 combinations of
SYSFS * MODULES.  No idea how it meshes with what's in -mm.
---


From: Randy Dunlap <randy.dunlap@oracle.com>

Fix source files to build with CONFIG_SYSFS=n.
module_subsys is not available.

SYSFS=n, MODULES=y:	T:y
SYSFS=n, MODULES=n:	T:y

SYSFS=y, MODULES=y:	T:y
SYSFS=y, MODULES=n:	T:y

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
 include/linux/module.h      |   53 ++++++++++++++++++++++++++++++++++++--------
 include/linux/moduleparam.h |   12 +++++++++
 kernel/module.c             |   14 ++++++++---
 kernel/params.c             |   28 ++++++++++++-----------
 4 files changed, 81 insertions(+), 26 deletions(-)

--- linux-2.6.20-git7.orig/kernel/params.c
+++ linux-2.6.20-git7/kernel/params.c
@@ -30,8 +30,6 @@
 #define DEBUGP(fmt, a...)
 #endif
 
-static struct kobj_type module_ktype;
-
 static inline char dash2underscore(char c)
 {
 	if (c == '-')
@@ -391,6 +389,7 @@ struct module_param_attrs
 	struct param_attribute attrs[0];
 };
 
+#ifdef CONFIG_SYSFS
 #define to_param_attr(n) container_of(n, struct param_attribute, mattr);
 
 static ssize_t param_attr_show(struct module_attribute *mattr,
@@ -426,6 +425,7 @@ static ssize_t param_attr_store(struct m
 		return len;
 	return err;
 }
+#endif
 
 #ifdef CONFIG_MODULES
 #define __modinit
@@ -433,6 +433,7 @@ static ssize_t param_attr_store(struct m
 #define __modinit __init
 #endif
 
+#ifdef CONFIG_SYSFS
 /*
  * param_sysfs_setup - setup sysfs support for one module or KBUILD_MODNAME
  * @mk: struct module_kobject (contains parent kobject)
@@ -500,9 +501,7 @@ param_sysfs_setup(struct module_kobject 
 	return mp;
 }
 
-
 #ifdef CONFIG_MODULES
-
 /*
  * module_param_sysfs_setup - setup sysfs support for one module
  * @mod: module
@@ -625,7 +624,6 @@ static void __init param_sysfs_builtin(v
 
 
 /* module-related sysfs stuff */
-#ifdef CONFIG_SYSFS
 
 #define to_module_attr(n) container_of(n, struct module_attribute, attr);
 #define to_module_kobject(n) container_of(n, struct module_kobject, kobj);
@@ -673,6 +671,8 @@ static struct sysfs_ops module_sysfs_ops
 	.store = module_attr_store,
 };
 
+static struct kobj_type module_ktype;
+
 static int uevent_filter(struct kset *kset, struct kobject *kobj)
 {
 	struct kobj_type *ktype = get_ktype(kobj);
@@ -686,19 +686,12 @@ static struct kset_uevent_ops module_uev
 	.filter = uevent_filter,
 };
 
-#else
-static struct sysfs_ops module_sysfs_ops = {
-	.show = NULL,
-	.store = NULL,
-};
-#endif
+decl_subsys(module, &module_ktype, &module_uevent_ops);
 
 static struct kobj_type module_ktype = {
 	.sysfs_ops =	&module_sysfs_ops,
 };
 
-decl_subsys(module, &module_ktype, &module_uevent_ops);
-
 /*
  * param_sysfs_init - wrapper for built-in params support
  */
@@ -719,6 +712,15 @@ static int __init param_sysfs_init(void)
 }
 subsys_initcall(param_sysfs_init);
 
+#else
+#if 0
+static struct sysfs_ops module_sysfs_ops = {
+	.show = NULL,
+	.store = NULL,
+};
+#endif
+#endif
+
 EXPORT_SYMBOL(param_set_byte);
 EXPORT_SYMBOL(param_get_byte);
 EXPORT_SYMBOL(param_set_short);
--- linux-2.6.20-git7.orig/kernel/module.c
+++ linux-2.6.20-git7/kernel/module.c
@@ -1068,7 +1068,8 @@ static inline void remove_sect_attrs(str
 }
 #endif /* CONFIG_KALLSYMS */
 
-static int module_add_modinfo_attrs(struct module *mod)
+#ifdef CONFIG_SYSFS
+int module_add_modinfo_attrs(struct module *mod)
 {
 	struct module_attribute *attr;
 	struct module_attribute *temp_attr;
@@ -1094,7 +1095,7 @@ static int module_add_modinfo_attrs(stru
 	return error;
 }
 
-static void module_remove_modinfo_attrs(struct module *mod)
+void module_remove_modinfo_attrs(struct module *mod)
 {
 	struct module_attribute *attr;
 	int i;
@@ -1109,8 +1110,10 @@ static void module_remove_modinfo_attrs(
 	}
 	kfree(mod->modinfo_attrs);
 }
+#endif
 
-static int mod_sysfs_init(struct module *mod)
+#ifdef CONFIG_SYSFS
+int mod_sysfs_init(struct module *mod)
 {
 	int err;
 
@@ -1133,7 +1136,7 @@ out:
 	return err;
 }
 
-static int mod_sysfs_setup(struct module *mod,
+int mod_sysfs_setup(struct module *mod,
 			   struct kernel_param *kparam,
 			   unsigned int num_params)
 {
@@ -1169,6 +1172,7 @@ out_unreg:
 out:
 	return err;
 }
+#endif
 
 static void mod_kobject_remove(struct module *mod)
 {
@@ -2345,6 +2349,7 @@ void print_modules(void)
 	printk("\n");
 }
 
+#ifdef CONFIG_SYSFS
 static char *make_driver_name(struct device_driver *drv)
 {
 	char *driver_name;
@@ -2419,6 +2424,7 @@ void module_remove_driver(struct device_
 	}
 }
 EXPORT_SYMBOL(module_remove_driver);
+#endif
 
 #ifdef CONFIG_MODVERSIONS
 /* Generate the signature for struct module here, too, for modversions. */
--- linux-2.6.20-git7.orig/include/linux/module.h
+++ linux-2.6.20-git7/include/linux/module.h
@@ -76,8 +76,6 @@ void sort_extable(struct exception_table
 		  struct exception_table_entry *finish);
 void sort_main_extable(void);
 
-extern struct subsystem module_subsys;
-
 #ifdef MODULE
 #define MODULE_GENERIC_TABLE(gtype,name)			\
 extern const struct gtype##_id __mod_##gtype##_table		\
@@ -467,10 +465,6 @@ int unregister_module_notifier(struct no
 
 extern void print_modules(void);
 
-struct device_driver;
-void module_add_driver(struct module *, struct device_driver *);
-void module_remove_driver(struct device_driver *);
-
 #else /* !CONFIG_MODULES... */
 #define EXPORT_SYMBOL(sym)
 #define EXPORT_SYMBOL_GPL(sym)
@@ -568,18 +562,59 @@ static inline void print_modules(void)
 {
 }
 
+#endif /* CONFIG_MODULES */
+
 struct device_driver;
+#ifdef CONFIG_SYSFS
 struct module;
 
-static inline void module_add_driver(struct module *module, struct device_driver *driver)
+extern struct subsystem module_subsys;
+
+int mod_sysfs_init(struct module *mod);
+int mod_sysfs_setup(struct module *mod,
+			   struct kernel_param *kparam,
+			   unsigned int num_params);
+int module_add_modinfo_attrs(struct module *mod);
+void module_remove_modinfo_attrs(struct module *mod);
+
+#else /* !CONFIG_SYSFS */
+
+static inline int mod_sysfs_init(struct module *mod)
 {
+	return 0;
 }
 
-static inline void module_remove_driver(struct device_driver *driver)
+static inline int mod_sysfs_setup(struct module *mod,
+			   struct kernel_param *kparam,
+			   unsigned int num_params)
 {
+	return 0;
 }
 
-#endif /* CONFIG_MODULES */
+static inline int module_add_modinfo_attrs(struct module *mod)
+{
+	return 0;
+}
+
+static inline void module_remove_modinfo_attrs(struct module *mod)
+{ }
+
+#endif /* CONFIG_SYSFS */
+
+#if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)
+
+void module_add_driver(struct module *mod, struct device_driver *drv);
+void module_remove_driver(struct device_driver *drv);
+
+#else /* not both CONFIG_SYSFS && CONFIG_MODULES */
+
+static inline void module_add_driver(struct module *mod, struct device_driver *drv)
+{ }
+
+static inline void module_remove_driver(struct device_driver *drv)
+{ }
+
+#endif
 
 #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
 
--- linux-2.6.20-git7.orig/include/linux/moduleparam.h
+++ linux-2.6.20-git7/include/linux/moduleparam.h
@@ -169,10 +169,22 @@ extern int param_get_string(char *buffer
 
 struct module;
 
+#if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)
 extern int module_param_sysfs_setup(struct module *mod,
 				    struct kernel_param *kparam,
 				    unsigned int num_params);
 
 extern void module_param_sysfs_remove(struct module *mod);
+#else
+static inline int module_param_sysfs_setup(struct module *mod,
+			     struct kernel_param *kparam,
+			     unsigned int num_params)
+{
+	return 0;
+}
+
+static inline void module_param_sysfs_remove(struct module *mod)
+{ }
+#endif
 
 #endif /* _LINUX_MODULE_PARAMS_H */

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-02-13 23:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-12 21:50 build errors: uevent with CONFIG_SYSFS=n Randy Dunlap
2007-02-12 22:29 ` [PATCH] " Randy Dunlap
2007-02-12 22:58   ` Andrew Morton
2007-02-13 23:19     ` [PATCH v2] " Randy Dunlap

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.