From: Tejun Heo <tj@home-tj.org>
To: greg@kroah.com, rusty@rustcorp.com.au, linux-kernel@vger.kernel.org
Subject: Re: [PATCH REPOST 2.6.10-rc3 1/4] module sysfs: make module.mkobj inline
Date: Mon, 20 Dec 2004 10:49:25 +0900 [thread overview]
Message-ID: <20041220014925.GB16197@home-tj.org> (raw)
In-Reply-To: <20041220014728.GA16197@home-tj.org>
01_mkobj_inline.patch
Make module.mkobj inline. As this is simpler and what's
usually done with kobjs when it's representing an entity.
Signed-off-by: Tejun Heo <tj@home-tj.org>
Index: linux-export/include/linux/module.h
===================================================================
--- linux-export.orig/include/linux/module.h 2004-11-23 10:57:37.000000000 +0900
+++ linux-export/include/linux/module.h 2004-11-23 15:08:01.000000000 +0900
@@ -250,7 +250,7 @@ struct module
char name[MODULE_NAME_LEN];
/* Sysfs stuff. */
- struct module_kobject *mkobj;
+ struct module_kobject mkobj;
struct param_kobject *params_kobject;
/* Exported symbols */
Index: linux-export/kernel/module.c
===================================================================
--- linux-export.orig/kernel/module.c 2004-11-23 10:57:37.000000000 +0900
+++ linux-export/kernel/module.c 2004-11-23 15:08:01.000000000 +0900
@@ -964,9 +964,6 @@ static void add_sect_attrs(struct module
unsigned int nloaded = 0, i;
struct module_sect_attr *sattr;
- if (!mod->mkobj)
- return;
-
/* Count loaded sections and allocate structures */
for (i = 0; i < nsect; i++)
if (sechdrs[i].sh_flags & SHF_ALLOC)
@@ -980,7 +977,7 @@ static void add_sect_attrs(struct module
memset(mod->sect_attrs, 0, sizeof(struct module_sections));
if (kobject_set_name(&mod->sect_attrs->kobj, "sections"))
goto out;
- mod->sect_attrs->kobj.parent = &mod->mkobj->kobj;
+ mod->sect_attrs->kobj.parent = &mod->mkobj.kobj;
mod->sect_attrs->kobj.ktype = &module_sect_ktype;
if (kobject_register(&mod->sect_attrs->kobj))
goto out;
@@ -1029,11 +1026,11 @@ static inline void remove_sect_attrs(str
#ifdef CONFIG_MODULE_UNLOAD
static inline int module_add_refcnt_attr(struct module *mod)
{
- return sysfs_create_file(&mod->mkobj->kobj, &refcnt.attr);
+ return sysfs_create_file(&mod->mkobj.kobj, &refcnt.attr);
}
static void module_remove_refcnt_attr(struct module *mod)
{
- return sysfs_remove_file(&mod->mkobj->kobj, &refcnt.attr);
+ return sysfs_remove_file(&mod->mkobj.kobj, &refcnt.attr);
}
#else
static inline int module_add_refcnt_attr(struct module *mod)
@@ -1052,17 +1049,13 @@ static int mod_sysfs_setup(struct module
{
int err;
- mod->mkobj = kmalloc(sizeof(struct module_kobject), GFP_KERNEL);
- if (!mod->mkobj)
- return -ENOMEM;
-
- memset(&mod->mkobj->kobj, 0, sizeof(mod->mkobj->kobj));
- err = kobject_set_name(&mod->mkobj->kobj, "%s", mod->name);
+ memset(&mod->mkobj.kobj, 0, sizeof(mod->mkobj.kobj));
+ err = kobject_set_name(&mod->mkobj.kobj, "%s", mod->name);
if (err)
goto out;
- kobj_set_kset_s(mod->mkobj, module_subsys);
- mod->mkobj->mod = mod;
- err = kobject_register(&mod->mkobj->kobj);
+ kobj_set_kset_s(&mod->mkobj, module_subsys);
+ mod->mkobj.mod = mod;
+ err = kobject_register(&mod->mkobj.kobj);
if (err)
goto out;
@@ -1077,11 +1070,8 @@ static int mod_sysfs_setup(struct module
return 0;
out_unreg:
- /* Calls module_kobj_release */
- kobject_unregister(&mod->mkobj->kobj);
- return err;
+ kobject_unregister(&mod->mkobj.kobj);
out:
- kfree(mod->mkobj);
return err;
}
@@ -1090,8 +1080,7 @@ static void mod_kobject_remove(struct mo
module_remove_refcnt_attr(mod);
module_param_sysfs_remove(mod);
- /* Calls module_kobj_release */
- kobject_unregister(&mod->mkobj->kobj);
+ kobject_unregister(&mod->mkobj.kobj);
}
/* Free a module, remove from lists, etc (must hold module mutex). */
@@ -2089,11 +2078,9 @@ void module_add_driver(struct module *mo
{
if (!mod || !drv)
return;
- if (!mod->mkobj)
- return;
/* Don't check return code; this call is idempotent */
- sysfs_create_link(&drv->kobj, &mod->mkobj->kobj, "module");
+ sysfs_create_link(&drv->kobj, &mod->mkobj.kobj, "module");
}
EXPORT_SYMBOL(module_add_driver);
Index: linux-export/kernel/params.c
===================================================================
--- linux-export.orig/kernel/params.c 2004-11-23 10:57:38.000000000 +0900
+++ linux-export/kernel/params.c 2004-11-23 15:08:01.000000000 +0900
@@ -567,7 +567,7 @@ int module_param_sysfs_setup(struct modu
{
struct param_kobject *pk;
- pk = param_sysfs_setup(mod->mkobj, kparam, num_params, 0);
+ pk = param_sysfs_setup(&mod->mkobj, kparam, num_params, 0);
if (IS_ERR(pk))
return PTR_ERR(pk);
@@ -610,8 +610,10 @@ static void __init kernel_param_sysfs_se
kobject_register(&mk->kobj);
/* no need to keep the kobject if no parameter is exported */
- if (!param_sysfs_setup(mk, kparam, num_params, name_skip))
+ if (!param_sysfs_setup(mk, kparam, num_params, name_skip)) {
kobject_unregister(&mk->kobj);
+ kfree(mk);
+ }
}
/*
@@ -710,14 +712,8 @@ static struct sysfs_ops module_sysfs_ops
};
#endif
-static void module_kobj_release(struct kobject *kobj)
-{
- kfree(container_of(kobj, struct module_kobject, kobj));
-}
-
static struct kobj_type module_ktype = {
.sysfs_ops = &module_sysfs_ops,
- .release = &module_kobj_release,
};
decl_subsys(module, &module_ktype, NULL);
next prev parent reply other threads:[~2004-12-20 1:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-20 1:47 [PATCH REPOST 2.6.10-rc3 0/4] module sysfs: module sysfs related cleanups Tejun Heo
2004-12-20 1:49 ` Tejun Heo [this message]
2004-12-20 1:50 ` [PATCH REPOST 2.6.10-rc3 2/4] module sysfs: expand module_attribute methods Tejun Heo
2004-12-20 1:52 ` [PATCH REPOST 2.6.10-rc3 3/4] module sysfs: sections attr reimplemented using attr group Tejun Heo
2004-12-20 1:54 ` [PATCH REPOST 2.6.10-rc3 4/4] module sysfs: module parameters " Tejun Heo
2004-12-21 18:37 ` [PATCH REPOST 2.6.10-rc3 0/4] module sysfs: module sysfs related cleanups Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041220014925.GB16197@home-tj.org \
--to=tj@home-tj.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®