Skip to content

Commit 30d4460

Browse files
t-8chpetrpavlu
authored andcommitted
params: Prepare for 'const struct module_attribute *'
The 'struct module_attribute' sysfs callbacks are about to change to receive a 'const struct module_attribute *' parameter. Prepare for that by avoid casting away the constness through container_of() and using const pointers to 'struct param_attribute'. Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Petr Pavlu <[email protected]> Link: https://lore.kernel.org/r/20241216-sysfs-const-attr-module-v1-1-3790b53e0abf@weissschuh.net Signed-off-by: Petr Pavlu <[email protected]>
1 parent c8e0bd5 commit 30d4460

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/params.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,13 @@ struct module_param_attrs
555555
};
556556

557557
#ifdef CONFIG_SYSFS
558-
#define to_param_attr(n) container_of(n, struct param_attribute, mattr)
558+
#define to_param_attr(n) container_of_const(n, struct param_attribute, mattr)
559559

560560
static ssize_t param_attr_show(struct module_attribute *mattr,
561561
struct module_kobject *mk, char *buf)
562562
{
563563
int count;
564-
struct param_attribute *attribute = to_param_attr(mattr);
564+
const struct param_attribute *attribute = to_param_attr(mattr);
565565

566566
if (!attribute->param->ops->get)
567567
return -EPERM;
@@ -578,7 +578,7 @@ static ssize_t param_attr_store(struct module_attribute *mattr,
578578
const char *buf, size_t len)
579579
{
580580
int err;
581-
struct param_attribute *attribute = to_param_attr(mattr);
581+
const struct param_attribute *attribute = to_param_attr(mattr);
582582

583583
if (!attribute->param->ops->set)
584584
return -EPERM;

0 commit comments

Comments
 (0)