Skip to content

Commit b83815a

Browse files
t-8chpetrpavlu
authored andcommitted
module: sysfs: Use const 'struct bin_attribute'
The sysfs core is switching to 'const struct bin_attribute's. Prepare for that. 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-6-e267275f0f37@weissschuh.net Signed-off-by: Petr Pavlu <[email protected]>
1 parent 4723f16 commit b83815a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

kernel/module/sysfs.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct module_sect_attrs {
2626

2727
#define MODULE_SECT_READ_SIZE (3 /* "0x", "\n" */ + (BITS_PER_LONG / 4))
2828
static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
29-
struct bin_attribute *battr,
29+
const struct bin_attribute *battr,
3030
char *buf, loff_t pos, size_t count)
3131
{
3232
char bounce[MODULE_SECT_READ_SIZE + 1];
@@ -54,18 +54,18 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
5454

5555
static void free_sect_attrs(struct module_sect_attrs *sect_attrs)
5656
{
57-
struct bin_attribute **bin_attr;
57+
const struct bin_attribute *const *bin_attr;
5858

59-
for (bin_attr = sect_attrs->grp.bin_attrs; *bin_attr; bin_attr++)
59+
for (bin_attr = sect_attrs->grp.bin_attrs_new; *bin_attr; bin_attr++)
6060
kfree((*bin_attr)->attr.name);
61-
kfree(sect_attrs->grp.bin_attrs);
61+
kfree(sect_attrs->grp.bin_attrs_new);
6262
kfree(sect_attrs);
6363
}
6464

6565
static int add_sect_attrs(struct module *mod, const struct load_info *info)
6666
{
6767
struct module_sect_attrs *sect_attrs;
68-
struct bin_attribute **gattr;
68+
const struct bin_attribute **gattr;
6969
struct bin_attribute *sattr;
7070
unsigned int nloaded = 0, i;
7171
int ret;
@@ -86,7 +86,7 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
8686

8787
/* Setup section attributes. */
8888
sect_attrs->grp.name = "sections";
89-
sect_attrs->grp.bin_attrs = gattr;
89+
sect_attrs->grp.bin_attrs_new = gattr;
9090

9191
sattr = &sect_attrs->attrs[0];
9292
for (i = 0; i < info->hdr->e_shnum; i++) {
@@ -101,7 +101,7 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
101101
ret = -ENOMEM;
102102
goto out;
103103
}
104-
sattr->read = module_sect_read;
104+
sattr->read_new = module_sect_read;
105105
sattr->private = (void *)sec->sh_addr;
106106
sattr->size = MODULE_SECT_READ_SIZE;
107107
sattr->attr.mode = 0400;
@@ -144,15 +144,15 @@ struct module_notes_attrs {
144144

145145
static void free_notes_attrs(struct module_notes_attrs *notes_attrs)
146146
{
147-
kfree(notes_attrs->grp.bin_attrs);
147+
kfree(notes_attrs->grp.bin_attrs_new);
148148
kfree(notes_attrs);
149149
}
150150

151151
static int add_notes_attrs(struct module *mod, const struct load_info *info)
152152
{
153153
unsigned int notes, loaded, i;
154154
struct module_notes_attrs *notes_attrs;
155-
struct bin_attribute **gattr;
155+
const struct bin_attribute **gattr;
156156
struct bin_attribute *nattr;
157157
int ret;
158158

@@ -178,7 +178,7 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info)
178178
}
179179

180180
notes_attrs->grp.name = "notes";
181-
notes_attrs->grp.bin_attrs = gattr;
181+
notes_attrs->grp.bin_attrs_new = gattr;
182182

183183
nattr = &notes_attrs->attrs[0];
184184
for (loaded = i = 0; i < info->hdr->e_shnum; ++i) {

0 commit comments

Comments
 (0)