]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
sysfs: treewide: constify attribute callback of bin_attribute::llseek()
authorThomas Weißschuh <linux@weissschuh.net>
Sun, 3 Nov 2024 17:03:36 +0000 (17:03 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Nov 2024 13:00:28 +0000 (14:00 +0100)
The llseek() callbacks should not modify the struct
bin_attribute passed as argument.
Enforce this by marking the argument as const.

As there are not many callback implementers perform this change
throughout the tree at once.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Krzysztof Wilczyński <kw@linux.com>
Link: https://lore.kernel.org/r/20241103-sysfs-const-bin_attr-v2-7-71110628844c@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pci/pci-sysfs.c
include/linux/sysfs.h

index 0ad3427228b12aa95325c6fc00e9686740559238..49bee70f7d375bca056476acd6528d19ead2c419 100644 (file)
@@ -841,7 +841,7 @@ static const struct attribute_group pci_dev_config_attr_group = {
 static __maybe_unused loff_t
 pci_llseek_resource(struct file *filep,
                    struct kobject *kobj __always_unused,
-                   struct bin_attribute *attr,
+                   const struct bin_attribute *attr,
                    loff_t offset, int whence)
 {
        return fixed_size_llseek(filep, offset, whence, attr->size);
index 9fcdc8cd3118f359742bfd8b708d5c3eff511042..cb2a5e277c2384f2e8add8fbf2907e8a819576ec 100644 (file)
@@ -307,7 +307,7 @@ struct bin_attribute {
                        char *, loff_t, size_t);
        ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *,
                         char *, loff_t, size_t);
-       loff_t (*llseek)(struct file *, struct kobject *, struct bin_attribute *,
+       loff_t (*llseek)(struct file *, struct kobject *, const struct bin_attribute *,
                         loff_t, int);
        int (*mmap)(struct file *, struct kobject *, const struct bin_attribute *attr,
                    struct vm_area_struct *vma);