Commit ef665c1a authored by Randy Dunlap's avatar Randy Dunlap Committed by Greg Kroah-Hartman

sysfs: fix build errors: uevent with CONFIG_SYSFS=n

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: default avatarRandy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e4a3c3f0
...@@ -76,8 +76,6 @@ void sort_extable(struct exception_table_entry *start, ...@@ -76,8 +76,6 @@ void sort_extable(struct exception_table_entry *start,
struct exception_table_entry *finish); struct exception_table_entry *finish);
void sort_main_extable(void); void sort_main_extable(void);
extern struct subsystem module_subsys;
#ifdef MODULE #ifdef MODULE
#define MODULE_GENERIC_TABLE(gtype,name) \ #define MODULE_GENERIC_TABLE(gtype,name) \
extern const struct gtype##_id __mod_##gtype##_table \ extern const struct gtype##_id __mod_##gtype##_table \
...@@ -467,10 +465,6 @@ int unregister_module_notifier(struct notifier_block * nb); ...@@ -467,10 +465,6 @@ int unregister_module_notifier(struct notifier_block * nb);
extern void print_modules(void); 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... */ #else /* !CONFIG_MODULES... */
#define EXPORT_SYMBOL(sym) #define EXPORT_SYMBOL(sym)
#define EXPORT_SYMBOL_GPL(sym) #define EXPORT_SYMBOL_GPL(sym)
...@@ -568,18 +562,59 @@ static inline void print_modules(void) ...@@ -568,18 +562,59 @@ static inline void print_modules(void)
{ {
} }
#endif /* CONFIG_MODULES */
struct device_driver; struct device_driver;
#ifdef CONFIG_SYSFS
struct module; 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) #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
......
...@@ -169,10 +169,22 @@ extern int param_get_string(char *buffer, struct kernel_param *kp); ...@@ -169,10 +169,22 @@ extern int param_get_string(char *buffer, struct kernel_param *kp);
struct module; struct module;
#if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)
extern int module_param_sysfs_setup(struct module *mod, extern int module_param_sysfs_setup(struct module *mod,
struct kernel_param *kparam, struct kernel_param *kparam,
unsigned int num_params); unsigned int num_params);
extern void module_param_sysfs_remove(struct module *mod); 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 */ #endif /* _LINUX_MODULE_PARAMS_H */
...@@ -1074,7 +1074,8 @@ static inline void remove_sect_attrs(struct module *mod) ...@@ -1074,7 +1074,8 @@ static inline void remove_sect_attrs(struct module *mod)
} }
#endif /* CONFIG_KALLSYMS */ #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 *attr;
struct module_attribute *temp_attr; struct module_attribute *temp_attr;
...@@ -1100,7 +1101,7 @@ static int module_add_modinfo_attrs(struct module *mod) ...@@ -1100,7 +1101,7 @@ static int module_add_modinfo_attrs(struct module *mod)
return error; return error;
} }
static void module_remove_modinfo_attrs(struct module *mod) void module_remove_modinfo_attrs(struct module *mod)
{ {
struct module_attribute *attr; struct module_attribute *attr;
int i; int i;
...@@ -1115,8 +1116,10 @@ static void module_remove_modinfo_attrs(struct module *mod) ...@@ -1115,8 +1116,10 @@ static void module_remove_modinfo_attrs(struct module *mod)
} }
kfree(mod->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; int err;
...@@ -1139,7 +1142,7 @@ static int mod_sysfs_init(struct module *mod) ...@@ -1139,7 +1142,7 @@ static int mod_sysfs_init(struct module *mod)
return err; return err;
} }
static int mod_sysfs_setup(struct module *mod, int mod_sysfs_setup(struct module *mod,
struct kernel_param *kparam, struct kernel_param *kparam,
unsigned int num_params) unsigned int num_params)
{ {
...@@ -1175,6 +1178,7 @@ static int mod_sysfs_setup(struct module *mod, ...@@ -1175,6 +1178,7 @@ static int mod_sysfs_setup(struct module *mod,
out: out:
return err; return err;
} }
#endif
static void mod_kobject_remove(struct module *mod) static void mod_kobject_remove(struct module *mod)
{ {
...@@ -2348,6 +2352,7 @@ void print_modules(void) ...@@ -2348,6 +2352,7 @@ void print_modules(void)
printk("\n"); printk("\n");
} }
#ifdef CONFIG_SYSFS
static char *make_driver_name(struct device_driver *drv) static char *make_driver_name(struct device_driver *drv)
{ {
char *driver_name; char *driver_name;
...@@ -2422,6 +2427,7 @@ void module_remove_driver(struct device_driver *drv) ...@@ -2422,6 +2427,7 @@ void module_remove_driver(struct device_driver *drv)
} }
} }
EXPORT_SYMBOL(module_remove_driver); EXPORT_SYMBOL(module_remove_driver);
#endif
#ifdef CONFIG_MODVERSIONS #ifdef CONFIG_MODVERSIONS
/* Generate the signature for struct module here, too, for modversions. */ /* Generate the signature for struct module here, too, for modversions. */
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#define DEBUGP(fmt, a...) #define DEBUGP(fmt, a...)
#endif #endif
static struct kobj_type module_ktype;
static inline char dash2underscore(char c) static inline char dash2underscore(char c)
{ {
if (c == '-') if (c == '-')
...@@ -391,6 +389,7 @@ struct module_param_attrs ...@@ -391,6 +389,7 @@ struct module_param_attrs
struct param_attribute attrs[0]; struct param_attribute attrs[0];
}; };
#ifdef CONFIG_SYSFS
#define to_param_attr(n) container_of(n, struct param_attribute, mattr); #define to_param_attr(n) container_of(n, struct param_attribute, mattr);
static ssize_t param_attr_show(struct module_attribute *mattr, static ssize_t param_attr_show(struct module_attribute *mattr,
...@@ -426,6 +425,7 @@ static ssize_t param_attr_store(struct module_attribute *mattr, ...@@ -426,6 +425,7 @@ static ssize_t param_attr_store(struct module_attribute *mattr,
return len; return len;
return err; return err;
} }
#endif
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES
#define __modinit #define __modinit
...@@ -433,6 +433,7 @@ static ssize_t param_attr_store(struct module_attribute *mattr, ...@@ -433,6 +433,7 @@ static ssize_t param_attr_store(struct module_attribute *mattr,
#define __modinit __init #define __modinit __init
#endif #endif
#ifdef CONFIG_SYSFS
/* /*
* param_sysfs_setup - setup sysfs support for one module or KBUILD_MODNAME * param_sysfs_setup - setup sysfs support for one module or KBUILD_MODNAME
* @mk: struct module_kobject (contains parent kobject) * @mk: struct module_kobject (contains parent kobject)
...@@ -500,9 +501,7 @@ param_sysfs_setup(struct module_kobject *mk, ...@@ -500,9 +501,7 @@ param_sysfs_setup(struct module_kobject *mk,
return mp; return mp;
} }
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES
/* /*
* module_param_sysfs_setup - setup sysfs support for one module * module_param_sysfs_setup - setup sysfs support for one module
* @mod: module * @mod: module
...@@ -625,7 +624,6 @@ static void __init param_sysfs_builtin(void) ...@@ -625,7 +624,6 @@ static void __init param_sysfs_builtin(void)
/* module-related sysfs stuff */ /* module-related sysfs stuff */
#ifdef CONFIG_SYSFS
#define to_module_attr(n) container_of(n, struct module_attribute, attr); #define to_module_attr(n) container_of(n, struct module_attribute, attr);
#define to_module_kobject(n) container_of(n, struct module_kobject, kobj); #define to_module_kobject(n) container_of(n, struct module_kobject, kobj);
...@@ -673,6 +671,8 @@ static struct sysfs_ops module_sysfs_ops = { ...@@ -673,6 +671,8 @@ static struct sysfs_ops module_sysfs_ops = {
.store = module_attr_store, .store = module_attr_store,
}; };
static struct kobj_type module_ktype;
static int uevent_filter(struct kset *kset, struct kobject *kobj) static int uevent_filter(struct kset *kset, struct kobject *kobj)
{ {
struct kobj_type *ktype = get_ktype(kobj); struct kobj_type *ktype = get_ktype(kobj);
...@@ -686,19 +686,12 @@ static struct kset_uevent_ops module_uevent_ops = { ...@@ -686,19 +686,12 @@ static struct kset_uevent_ops module_uevent_ops = {
.filter = uevent_filter, .filter = uevent_filter,
}; };
#else decl_subsys(module, &module_ktype, &module_uevent_ops);
static struct sysfs_ops module_sysfs_ops = {
.show = NULL,
.store = NULL,
};
#endif
static struct kobj_type module_ktype = { static struct kobj_type module_ktype = {
.sysfs_ops = &module_sysfs_ops, .sysfs_ops = &module_sysfs_ops,
}; };
decl_subsys(module, &module_ktype, &module_uevent_ops);
/* /*
* param_sysfs_init - wrapper for built-in params support * param_sysfs_init - wrapper for built-in params support
*/ */
...@@ -720,6 +713,15 @@ static int __init param_sysfs_init(void) ...@@ -720,6 +713,15 @@ static int __init param_sysfs_init(void)
} }
subsys_initcall(param_sysfs_init); 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_set_byte);
EXPORT_SYMBOL(param_get_byte); EXPORT_SYMBOL(param_get_byte);
EXPORT_SYMBOL(param_set_short); EXPORT_SYMBOL(param_set_short);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment