Skip to content

Commit 34f5ec0

Browse files
t-8chpetrpavlu
authored andcommitted
module: sysfs: Drop 'struct module_sect_attr'
This is now an otherwise empty wrapper around a 'struct bin_attribute', not providing any functionality. Remove it. Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Petr Pavlu <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/20241227-sysfs-const-bin_attr-module-v2-3-e267275f0f37@weissschuh.net Signed-off-by: Petr Pavlu <[email protected]>
1 parent 4b2c11e commit 34f5ec0

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

kernel/module/sysfs.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@
1919
* J. Corbet <[email protected]>
2020
*/
2121
#ifdef CONFIG_KALLSYMS
22-
struct module_sect_attr {
23-
struct bin_attribute battr;
24-
};
25-
2622
struct module_sect_attrs {
2723
struct attribute_group grp;
28-
struct module_sect_attr attrs[];
24+
struct bin_attribute attrs[];
2925
};
3026

3127
#define MODULE_SECT_READ_SIZE (3 /* "0x", "\n" */ + (BITS_PER_LONG / 4))
@@ -69,8 +65,8 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
6965
{
7066
unsigned int nloaded = 0, i, size[2];
7167
struct module_sect_attrs *sect_attrs;
72-
struct module_sect_attr *sattr;
7368
struct bin_attribute **gattr;
69+
struct bin_attribute *sattr;
7470
int ret;
7571

7672
/* Count loaded sections and allocate structures */
@@ -95,18 +91,18 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
9591

9692
if (sect_empty(sec))
9793
continue;
98-
sysfs_bin_attr_init(&sattr->battr);
99-
sattr->battr.attr.name =
94+
sysfs_bin_attr_init(sattr);
95+
sattr->attr.name =
10096
kstrdup(info->secstrings + sec->sh_name, GFP_KERNEL);
101-
if (!sattr->battr.attr.name) {
97+
if (!sattr->attr.name) {
10298
ret = -ENOMEM;
10399
goto out;
104100
}
105-
sattr->battr.read = module_sect_read;
106-
sattr->battr.private = (void *)sec->sh_addr;
107-
sattr->battr.size = MODULE_SECT_READ_SIZE;
108-
sattr->battr.attr.mode = 0400;
109-
*(gattr++) = &(sattr++)->battr;
101+
sattr->read = module_sect_read;
102+
sattr->private = (void *)sec->sh_addr;
103+
sattr->size = MODULE_SECT_READ_SIZE;
104+
sattr->attr.mode = 0400;
105+
*(gattr++) = sattr++;
110106
}
111107
*gattr = NULL;
112108

@@ -186,7 +182,7 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info)
186182
continue;
187183
if (info->sechdrs[i].sh_type == SHT_NOTE) {
188184
sysfs_bin_attr_init(nattr);
189-
nattr->attr.name = mod->sect_attrs->attrs[loaded].battr.attr.name;
185+
nattr->attr.name = mod->sect_attrs->attrs[loaded].attr.name;
190186
nattr->attr.mode = 0444;
191187
nattr->size = info->sechdrs[i].sh_size;
192188
nattr->private = (void *)info->sechdrs[i].sh_addr;

0 commit comments

Comments
 (0)