Skip to content

Commit 49c1940

Browse files
Jean Delvaregregkh
authored andcommitted
sysfs: sysfs_chmod_file's attr can be const
sysfs_chmod_file doesn't change the attribute it operates on, so this attribute can be marked const. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 3317fad commit 49c1940

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎fs/sysfs/file.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,8 @@ EXPORT_SYMBOL_GPL(sysfs_add_file_to_group);
593593
* @mode: file permissions.
594594
*
595595
*/
596-
int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
596+
int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr,
597+
mode_t mode)
597598
{
598599
struct sysfs_dirent *sd;
599600
struct iattr newattrs;

‎include/linux/sysfs.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ int __must_check sysfs_create_file(struct kobject *kobj,
136136
const struct attribute *attr);
137137
int __must_check sysfs_create_files(struct kobject *kobj,
138138
const struct attribute **attr);
139-
int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr,
140-
mode_t mode);
139+
int __must_check sysfs_chmod_file(struct kobject *kobj,
140+
const struct attribute *attr, mode_t mode);
141141
void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr);
142142
void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr);
143143

@@ -225,7 +225,7 @@ static inline int sysfs_create_files(struct kobject *kobj,
225225
}
226226

227227
static inline int sysfs_chmod_file(struct kobject *kobj,
228-
struct attribute *attr, mode_t mode)
228+
const struct attribute *attr, mode_t mode)
229229
{
230230
return 0;
231231
}

0 commit comments

Comments
 (0)