Skip to content

Commit 94a20fb

Browse files
t-8chgregkh
authored andcommitted
sysfs: treewide: constify attribute callback of bin_attribute::mmap()
The mmap() 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 <[email protected]> Acked-by: Andrew Donnellan <[email protected]> # ocxl Acked-by: Krzysztof Wilczyński <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b626816 commit 94a20fb

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

arch/alpha/kernel/pci-sysfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static int __pci_mmap_fits(struct pci_dev *pdev, int num,
6464
* Return: %0 on success, negative error code otherwise
6565
*/
6666
static int pci_mmap_resource(struct kobject *kobj,
67-
struct bin_attribute *attr,
67+
const struct bin_attribute *attr,
6868
struct vm_area_struct *vma, int sparse)
6969
{
7070
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
@@ -93,14 +93,14 @@ static int pci_mmap_resource(struct kobject *kobj,
9393
}
9494

9595
static int pci_mmap_resource_sparse(struct file *filp, struct kobject *kobj,
96-
struct bin_attribute *attr,
96+
const struct bin_attribute *attr,
9797
struct vm_area_struct *vma)
9898
{
9999
return pci_mmap_resource(kobj, attr, vma, 1);
100100
}
101101

102102
static int pci_mmap_resource_dense(struct file *filp, struct kobject *kobj,
103-
struct bin_attribute *attr,
103+
const struct bin_attribute *attr,
104104
struct vm_area_struct *vma)
105105
{
106106
return pci_mmap_resource(kobj, attr, vma, 0);

drivers/misc/ocxl/sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static const struct vm_operations_struct global_mmio_vmops = {
125125
};
126126

127127
static int global_mmio_mmap(struct file *filp, struct kobject *kobj,
128-
struct bin_attribute *bin_attr,
128+
const struct bin_attribute *bin_attr,
129129
struct vm_area_struct *vma)
130130
{
131131
struct ocxl_afu *afu = to_afu(kobj_to_dev(kobj));

drivers/pci/p2pdma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static ssize_t published_show(struct device *dev, struct device_attribute *attr,
9090
static DEVICE_ATTR_RO(published);
9191

9292
static int p2pmem_alloc_mmap(struct file *filp, struct kobject *kobj,
93-
struct bin_attribute *attr, struct vm_area_struct *vma)
93+
const struct bin_attribute *attr, struct vm_area_struct *vma)
9494
{
9595
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
9696
size_t len = vma->vm_end - vma->vm_start;

drivers/pci/pci-sysfs.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ static ssize_t pci_write_legacy_io(struct file *filp, struct kobject *kobj,
910910
* memory space.
911911
*/
912912
static int pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj,
913-
struct bin_attribute *attr,
913+
const struct bin_attribute *attr,
914914
struct vm_area_struct *vma)
915915
{
916916
struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
@@ -930,7 +930,7 @@ static int pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj,
930930
* memory space. Returns -ENOSYS if the operation isn't supported
931931
*/
932932
static int pci_mmap_legacy_io(struct file *filp, struct kobject *kobj,
933-
struct bin_attribute *attr,
933+
const struct bin_attribute *attr,
934934
struct vm_area_struct *vma)
935935
{
936936
struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
@@ -1034,7 +1034,7 @@ void pci_remove_legacy_files(struct pci_bus *b)
10341034
*
10351035
* Use the regular PCI mapping routines to map a PCI resource into userspace.
10361036
*/
1037-
static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
1037+
static int pci_mmap_resource(struct kobject *kobj, const struct bin_attribute *attr,
10381038
struct vm_area_struct *vma, int write_combine)
10391039
{
10401040
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
@@ -1059,14 +1059,14 @@ static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
10591059
}
10601060

10611061
static int pci_mmap_resource_uc(struct file *filp, struct kobject *kobj,
1062-
struct bin_attribute *attr,
1062+
const struct bin_attribute *attr,
10631063
struct vm_area_struct *vma)
10641064
{
10651065
return pci_mmap_resource(kobj, attr, vma, 0);
10661066
}
10671067

10681068
static int pci_mmap_resource_wc(struct file *filp, struct kobject *kobj,
1069-
struct bin_attribute *attr,
1069+
const struct bin_attribute *attr,
10701070
struct vm_area_struct *vma)
10711071
{
10721072
return pci_mmap_resource(kobj, attr, vma, 1);

drivers/platform/x86/intel/pmt/class.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ intel_pmt_read(struct file *filp, struct kobject *kobj,
103103

104104
static int
105105
intel_pmt_mmap(struct file *filp, struct kobject *kobj,
106-
struct bin_attribute *attr, struct vm_area_struct *vma)
106+
const struct bin_attribute *attr, struct vm_area_struct *vma)
107107
{
108108
struct intel_pmt_entry *entry = container_of(attr,
109109
struct intel_pmt_entry,

drivers/uio/uio_hv_generic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static void hv_uio_rescind(struct vmbus_channel *channel)
135135
* The ring buffer is allocated as contiguous memory by vmbus_open
136136
*/
137137
static int hv_uio_ring_mmap(struct file *filp, struct kobject *kobj,
138-
struct bin_attribute *attr,
138+
const struct bin_attribute *attr,
139139
struct vm_area_struct *vma)
140140
{
141141
struct vmbus_channel *channel

include/linux/sysfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ struct bin_attribute {
309309
char *, loff_t, size_t);
310310
loff_t (*llseek)(struct file *, struct kobject *, struct bin_attribute *,
311311
loff_t, int);
312-
int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
312+
int (*mmap)(struct file *, struct kobject *, const struct bin_attribute *attr,
313313
struct vm_area_struct *vma);
314314
};
315315

0 commit comments

Comments
 (0)