mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-26 14:17:26 -04:00
kobject: remove the static array for the name
Due to historical reasons, struct kobject contained a static array for the name, and a dynamic pointer in case the name got bigger than the array. That's just dumb, as people didn't always know which variable to reference, even with the accessor for the kobject name. This patch removes the static array, potentially saving a lot of memory as the majority of kobjects do not have a very long name. Thanks to Kay for the idea to do this. Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
34980ca8fa
commit
ce2c9cb025
2 changed files with 41 additions and 43 deletions
|
@ -63,7 +63,6 @@ extern const char *kobject_actions[];
|
|||
|
||||
struct kobject {
|
||||
const char * k_name;
|
||||
char name[KOBJ_NAME_LEN];
|
||||
struct kref kref;
|
||||
struct list_head entry;
|
||||
struct kobject * parent;
|
||||
|
@ -188,18 +187,18 @@ extern struct kobject * kset_find_obj(struct kset *, const char *);
|
|||
* Use this when initializing an embedded kset with no other
|
||||
* fields to initialize.
|
||||
*/
|
||||
#define set_kset_name(str) .kset = { .kobj = { .name = str } }
|
||||
#define set_kset_name(str) .kset = { .kobj = { .k_name = str } }
|
||||
|
||||
|
||||
#define decl_subsys(_name,_type,_uevent_ops) \
|
||||
struct kset _name##_subsys = { \
|
||||
.kobj = { .name = __stringify(_name) }, \
|
||||
.kobj = { .k_name = __stringify(_name) }, \
|
||||
.ktype = _type, \
|
||||
.uevent_ops =_uevent_ops, \
|
||||
}
|
||||
#define decl_subsys_name(_varname,_name,_type,_uevent_ops) \
|
||||
struct kset _varname##_subsys = { \
|
||||
.kobj = { .name = __stringify(_name) }, \
|
||||
.kobj = { .k_name = __stringify(_name) }, \
|
||||
.ktype = _type, \
|
||||
.uevent_ops =_uevent_ops, \
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue