mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 07:47:50 +00:00
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 <linux@weissschuh.net> Reviewed-by: Petr Pavlu <petr.pavlu@suse.com> Link: https://lore.kernel.org/r/20241216-sysfs-const-attr-module-v1-1-3790b53e0abf@weissschuh.net Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
This commit is contained in:
committed by
Petr Pavlu
parent
c8e0bd579e
commit
30d4460888
@@ -555,13 +555,13 @@ struct module_param_attrs
|
||||
};
|
||||
|
||||
#ifdef CONFIG_SYSFS
|
||||
#define to_param_attr(n) container_of(n, struct param_attribute, mattr)
|
||||
#define to_param_attr(n) container_of_const(n, struct param_attribute, mattr)
|
||||
|
||||
static ssize_t param_attr_show(struct module_attribute *mattr,
|
||||
struct module_kobject *mk, char *buf)
|
||||
{
|
||||
int count;
|
||||
struct param_attribute *attribute = to_param_attr(mattr);
|
||||
const struct param_attribute *attribute = to_param_attr(mattr);
|
||||
|
||||
if (!attribute->param->ops->get)
|
||||
return -EPERM;
|
||||
@@ -578,7 +578,7 @@ static ssize_t param_attr_store(struct module_attribute *mattr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
int err;
|
||||
struct param_attribute *attribute = to_param_attr(mattr);
|
||||
const struct param_attribute *attribute = to_param_attr(mattr);
|
||||
|
||||
if (!attribute->param->ops->set)
|
||||
return -EPERM;
|
||||
|
||||
Reference in New Issue
Block a user