module: Constify 'struct module_attribute'
These structs are never modified, move them to read-only memory. This makes the API clearer and also prepares for the constification of 'struct attribute' itself. While at it, also constify 'modinfo_attrs_count'. 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-3-3790b53e0abf@weissschuh.net Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
This commit is contained in:
1 parent
38e3fe6595
commit
f3227ffda0
5 files changed
+34
-34
No files matched your search
+6
-6
@@ -538,7 +538,7 @@ const struct kernel_param_ops param_ops_string = {
|
||||
EXPORT_SYMBOL(param_ops_string);
|
||||
|
||||
/* sysfs output in /sys/modules/XYZ/parameters/ */
|
||||
#define to_module_attr(n) container_of(n, struct module_attribute, attr)
|
||||
#define to_module_attr(n) container_of_const(n, struct module_attribute, attr)
|
||||
#define to_module_kobject(n) container_of(n, struct module_kobject, kobj)
|
||||
|
||||
struct param_attribute
|
||||
@@ -557,7 +557,7 @@ struct module_param_attrs
|
||||
#ifdef CONFIG_SYSFS
|
||||
#define to_param_attr(n) container_of_const(n, struct param_attribute, mattr)
|
||||
|
||||
static ssize_t param_attr_show(struct module_attribute *mattr,
|
||||
static ssize_t param_attr_show(const struct module_attribute *mattr,
|
||||
struct module_kobject *mk, char *buf)
|
||||
{
|
||||
int count;
|
||||
@@ -573,7 +573,7 @@ static ssize_t param_attr_show(struct module_attribute *mattr,
|
||||
}
|
||||
|
||||
/* sysfs always hands a nul-terminated string in buf. We rely on that. */
|
||||
static ssize_t param_attr_store(struct module_attribute *mattr,
|
||||
static ssize_t param_attr_store(const struct module_attribute *mattr,
|
||||
struct module_kobject *mk,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
@@ -857,7 +857,7 @@ static void __init param_sysfs_builtin(void)
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t __modver_version_show(struct module_attribute *mattr,
|
||||
ssize_t __modver_version_show(const struct module_attribute *mattr,
|
||||
struct module_kobject *mk, char *buf)
|
||||
{
|
||||
const struct module_version_attribute *vattr =
|
||||
@@ -892,7 +892,7 @@ static ssize_t module_attr_show(struct kobject *kobj,
|
||||
struct attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct module_attribute *attribute;
|
||||
const struct module_attribute *attribute;
|
||||
struct module_kobject *mk;
|
||||
int ret;
|
||||
|
||||
@@ -911,7 +911,7 @@ static ssize_t module_attr_store(struct kobject *kobj,
|
||||
struct attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct module_attribute *attribute;
|
||||
const struct module_attribute *attribute;
|
||||
struct module_kobject *mk;
|
||||
int ret;
|
||||
|
||||
|
||||
Reference in new issue
Block a user