Commit 4befb026 authored by Kay Sievers's avatar Kay Sievers Committed by Rusty Russell

module: change attr callbacks to take struct module_kobject

This simplifies the next patch, where we have an attribute on a
builtin module (ie. module == NULL).
Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (split into 2)
parent 66574cc0
...@@ -48,10 +48,18 @@ struct modversion_info ...@@ -48,10 +48,18 @@ struct modversion_info
struct module; struct module;
struct module_kobject {
struct kobject kobj;
struct module *mod;
struct kobject *drivers_dir;
struct module_param_attrs *mp;
};
struct module_attribute { struct module_attribute {
struct attribute attr; struct attribute attr;
ssize_t (*show)(struct module_attribute *, struct module *, char *); ssize_t (*show)(struct module_attribute *, struct module_kobject *,
ssize_t (*store)(struct module_attribute *, struct module *, char *);
ssize_t (*store)(struct module_attribute *, struct module_kobject *,
const char *, size_t count); const char *, size_t count);
void (*setup)(struct module *, const char *); void (*setup)(struct module *, const char *);
int (*test)(struct module *); int (*test)(struct module *);
...@@ -65,15 +73,8 @@ struct module_version_attribute { ...@@ -65,15 +73,8 @@ struct module_version_attribute {
} __attribute__ ((__aligned__(sizeof(void *)))); } __attribute__ ((__aligned__(sizeof(void *))));
extern ssize_t __modver_version_show(struct module_attribute *, extern ssize_t __modver_version_show(struct module_attribute *,
struct module *, char *); struct module_kobject *, char *);
struct module_kobject
{
struct kobject kobj;
struct module *mod;
struct kobject *drivers_dir;
struct module_param_attrs *mp;
};
/* These are either module local, or the kernel's dummy ones. */ /* These are either module local, or the kernel's dummy ones. */
extern int init_module(void); extern int init_module(void);
......
...@@ -545,9 +545,9 @@ static void setup_modinfo_##field(struct module *mod, const char *s) \ ...@@ -545,9 +545,9 @@ static void setup_modinfo_##field(struct module *mod, const char *s) \
mod->field = kstrdup(s, GFP_KERNEL); \ mod->field = kstrdup(s, GFP_KERNEL); \
} \ } \
static ssize_t show_modinfo_##field(struct module_attribute *mattr, \ static ssize_t show_modinfo_##field(struct module_attribute *mattr, \
struct module *mod, char *buffer) \ struct module_kobject *mk, char *buffer) \
{ \ { \
return sprintf(buffer, "%s\n", mod->field); \ return sprintf(buffer, "%s\n", mk->mod->field); \
} \ } \
static int modinfo_##field##_exists(struct module *mod) \ static int modinfo_##field##_exists(struct module *mod) \
{ \ { \
...@@ -902,9 +902,9 @@ void symbol_put_addr(void *addr) ...@@ -902,9 +902,9 @@ void symbol_put_addr(void *addr)
EXPORT_SYMBOL_GPL(symbol_put_addr); EXPORT_SYMBOL_GPL(symbol_put_addr);
static ssize_t show_refcnt(struct module_attribute *mattr, static ssize_t show_refcnt(struct module_attribute *mattr,
struct module *mod, char *buffer) struct module_kobject *mk, char *buffer)
{ {
return sprintf(buffer, "%u\n", module_refcount(mod)); return sprintf(buffer, "%u\n", module_refcount(mk->mod));
} }
static struct module_attribute refcnt = { static struct module_attribute refcnt = {
...@@ -952,11 +952,11 @@ static inline int module_unload_init(struct module *mod) ...@@ -952,11 +952,11 @@ static inline int module_unload_init(struct module *mod)
#endif /* CONFIG_MODULE_UNLOAD */ #endif /* CONFIG_MODULE_UNLOAD */
static ssize_t show_initstate(struct module_attribute *mattr, static ssize_t show_initstate(struct module_attribute *mattr,
struct module *mod, char *buffer) struct module_kobject *mk, char *buffer)
{ {
const char *state = "unknown"; const char *state = "unknown";
switch (mod->state) { switch (mk->mod->state) {
case MODULE_STATE_LIVE: case MODULE_STATE_LIVE:
state = "live"; state = "live";
break; break;
...@@ -1187,7 +1187,7 @@ struct module_sect_attrs ...@@ -1187,7 +1187,7 @@ struct module_sect_attrs
}; };
static ssize_t module_sect_show(struct module_attribute *mattr, static ssize_t module_sect_show(struct module_attribute *mattr,
struct module *mod, char *buf) struct module_kobject *mk, char *buf)
{ {
struct module_sect_attr *sattr = struct module_sect_attr *sattr =
container_of(mattr, struct module_sect_attr, mattr); container_of(mattr, struct module_sect_attr, mattr);
......
...@@ -511,7 +511,7 @@ struct module_param_attrs ...@@ -511,7 +511,7 @@ struct module_param_attrs
#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,
struct module *mod, char *buf) struct module_kobject *mk, char *buf)
{ {
int count; int count;
struct param_attribute *attribute = to_param_attr(mattr); struct param_attribute *attribute = to_param_attr(mattr);
...@@ -531,7 +531,7 @@ static ssize_t param_attr_show(struct module_attribute *mattr, ...@@ -531,7 +531,7 @@ static ssize_t param_attr_show(struct module_attribute *mattr,
/* sysfs always hands a nul-terminated string in buf. We rely on that. */ /* sysfs always hands a nul-terminated string in buf. We rely on that. */
static ssize_t param_attr_store(struct module_attribute *mattr, static ssize_t param_attr_store(struct module_attribute *mattr,
struct module *owner, struct module_kobject *km,
const char *buf, size_t len) const char *buf, size_t len)
{ {
int err; int err;
...@@ -807,7 +807,7 @@ static void __init param_sysfs_builtin(void) ...@@ -807,7 +807,7 @@ static void __init param_sysfs_builtin(void)
} }
ssize_t __modver_version_show(struct module_attribute *mattr, ssize_t __modver_version_show(struct module_attribute *mattr,
struct module *mod, char *buf) struct module_kobject *mk, char *buf)
{ {
struct module_version_attribute *vattr = struct module_version_attribute *vattr =
container_of(mattr, struct module_version_attribute, mattr); container_of(mattr, struct module_version_attribute, mattr);
...@@ -852,7 +852,7 @@ static ssize_t module_attr_show(struct kobject *kobj, ...@@ -852,7 +852,7 @@ static ssize_t module_attr_show(struct kobject *kobj,
if (!attribute->show) if (!attribute->show)
return -EIO; return -EIO;
ret = attribute->show(attribute, mk->mod, buf); ret = attribute->show(attribute, mk, buf);
return ret; return ret;
} }
...@@ -871,7 +871,7 @@ static ssize_t module_attr_store(struct kobject *kobj, ...@@ -871,7 +871,7 @@ static ssize_t module_attr_store(struct kobject *kobj,
if (!attribute->store) if (!attribute->store)
return -EIO; return -EIO;
ret = attribute->store(attribute, mk->mod, buf, len); ret = attribute->store(attribute, mk, buf, len);
return ret; return ret;
} }
......
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