Commit 2b8693c0 authored by Arjan van de Ven's avatar Arjan van de Ven Committed by Linus Torvalds
Browse files

[PATCH] mark struct file_operations const 3



Many struct file_operations in the kernel can be "const".  Marking them const
moves these to the .rodata section, which avoids false sharing with potential
dirty data.  In addition it'll catch accidental writes at compile time to
these shared resources.
Signed-off-by: default avatarArjan van de Ven <arjan@linux.intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5dfe4c96
......@@ -264,7 +264,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
}
static struct file_operations blk_dropped_fops = {
static const struct file_operations blk_dropped_fops = {
.owner = THIS_MODULE,
.open = blk_dropped_open,
.read = blk_dropped_read,
......
......@@ -101,7 +101,7 @@ static int crypto_info_open(struct inode *inode, struct file *file)
return seq_open(file, &crypto_seq_ops);
}
static struct file_operations proc_crypto_ops = {
static const struct file_operations proc_crypto_ops = {
.open = crypto_info_open,
.read = seq_read,
.llseek = seq_lseek,
......
......@@ -238,7 +238,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
}
static struct file_operations rtc_fops = {
static const struct file_operations rtc_fops = {
.ioctl = rtc_ioctl,
};
......
......@@ -7024,7 +7024,7 @@ static int DAC960_gam_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
}
static struct file_operations DAC960_gam_fops = {
static const struct file_operations DAC960_gam_fops = {
.owner = THIS_MODULE,
.ioctl = DAC960_gam_ioctl
};
......
......@@ -269,7 +269,7 @@ static int slm_get_pagesize( int device, int *w, int *h );
static DEFINE_TIMER(slm_timer, slm_test_ready, 0, 0);
static struct file_operations slm_fops = {
static const struct file_operations slm_fops = {
.owner = THIS_MODULE,
.read = slm_read,
.write = slm_write,
......
......@@ -233,7 +233,7 @@ loop:
}
}
static struct file_operations aoe_fops = {
static const struct file_operations aoe_fops = {
.write = aoechr_write,
.read = aoechr_read,
.open = aoechr_open,
......
......@@ -227,7 +227,7 @@ static struct class *pg_class;
/* kernel glue structures */
static struct file_operations pg_fops = {
static const struct file_operations pg_fops = {
.owner = THIS_MODULE,
.read = pg_read,
.write = pg_write,
......
......@@ -232,7 +232,7 @@ static char pt_scratch[512]; /* scratch block buffer */
/* kernel glue structures */
static struct file_operations pt_fops = {
static const struct file_operations pt_fops = {
.owner = THIS_MODULE,
.read = pt_read,
.write = pt_write,
......
......@@ -435,7 +435,7 @@ static int pkt_debugfs_fops_open(struct inode *inode, struct file *file)
return single_open(file, pkt_debugfs_seq_show, inode->i_private);
}
static struct file_operations debug_fops = {
static const struct file_operations debug_fops = {
.open = pkt_debugfs_fops_open,
.read = seq_read,
.llseek = seq_lseek,
......@@ -2725,7 +2725,7 @@ static int pkt_seq_open(struct inode *inode, struct file *file)
return single_open(file, pkt_seq_show, PDE(inode)->data);
}
static struct file_operations pkt_proc_fops = {
static const struct file_operations pkt_proc_fops = {
.open = pkt_seq_open,
.read = seq_read,
.llseek = seq_lseek,
......@@ -3052,7 +3052,7 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
}
static struct file_operations pkt_ctl_fops = {
static const struct file_operations pkt_ctl_fops = {
.ioctl = pkt_ctl_ioctl,
.owner = THIS_MODULE,
};
......
......@@ -332,7 +332,7 @@ static int vhci_fasync(int fd, struct file *file, int on)
return 0;
}
static struct file_operations vhci_fops = {
static const struct file_operations vhci_fops = {
.owner = THIS_MODULE,
.llseek = vhci_llseek,
.read = vhci_read,
......
......@@ -176,7 +176,7 @@ static int proc_viocd_open(struct inode *inode, struct file *file)
return single_open(file, proc_viocd_show, NULL);
}
static struct file_operations proc_viocd_operations = {
static const struct file_operations proc_viocd_operations = {
.open = proc_viocd_open,
.read = seq_read,
.llseek = seq_lseek,
......
......@@ -187,7 +187,7 @@ static ssize_t briq_panel_write(struct file *file, const char __user *buf, size_
return len;
}
static struct file_operations briq_panel_fops = {
static const struct file_operations briq_panel_fops = {
.owner = THIS_MODULE,
.read = briq_panel_read,
.write = briq_panel_write,
......
......@@ -371,7 +371,7 @@ void drm_exit(struct drm_driver *driver)
EXPORT_SYMBOL(drm_exit);
/** File operations structure */
static struct file_operations drm_stub_fops = {
static const struct file_operations drm_stub_fops = {
.owner = THIS_MODULE,
.open = drm_stub_open
};
......
......@@ -112,7 +112,7 @@ static int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
return 0;
}
static struct file_operations i810_buffer_fops = {
static const struct file_operations i810_buffer_fops = {
.open = drm_open,
.release = drm_release,
.ioctl = drm_ioctl,
......
......@@ -114,7 +114,7 @@ static int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
return 0;
}
static struct file_operations i830_buffer_fops = {
static const struct file_operations i830_buffer_fops = {
.open = drm_open,
.release = drm_release,
.ioctl = drm_ioctl,
......
......@@ -117,7 +117,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
return 0;
}
struct file_operations nvram_fops = {
const struct file_operations nvram_fops = {
.owner = THIS_MODULE,
.llseek = nvram_llseek,
.read = read_nvram,
......
......@@ -46,7 +46,7 @@ LIST_HEAD(soft_list);
/*
* file operations
*/
struct file_operations mbcs_ops = {
const struct file_operations mbcs_ops = {
.open = mbcs_open,
.llseek = mbcs_sram_llseek,
.read = mbcs_sram_read,
......
......@@ -291,7 +291,7 @@ uncached_mmap(struct file *file, struct vm_area_struct *vma)
return mspec_mmap(file, vma, MSPEC_UNCACHED);
}
static struct file_operations fetchop_fops = {
static const struct file_operations fetchop_fops = {
.owner = THIS_MODULE,
.mmap = fetchop_mmap
};
......@@ -302,7 +302,7 @@ static struct miscdevice fetchop_miscdev = {
.fops = &fetchop_fops
};
static struct file_operations cached_fops = {
static const struct file_operations cached_fops = {
.owner = THIS_MODULE,
.mmap = cached_mmap
};
......@@ -313,7 +313,7 @@ static struct miscdevice cached_miscdev = {
.fops = &cached_fops
};
static struct file_operations uncached_fops = {
static const struct file_operations uncached_fops = {
.owner = THIS_MODULE,
.mmap = uncached_mmap
};
......
......@@ -1117,14 +1117,14 @@ random_ioctl(struct inode * inode, struct file * file,
}
}
struct file_operations random_fops = {
const struct file_operations random_fops = {
.read = random_read,
.write = random_write,
.poll = random_poll,
.ioctl = random_ioctl,
};
struct file_operations urandom_fops = {
const struct file_operations urandom_fops = {
.read = urandom_read,
.write = random_write,
.ioctl = random_ioctl,
......
......@@ -441,7 +441,7 @@ static int tpm_ascii_bios_measurements_open(struct inode *inode,
return err;
}
struct file_operations tpm_ascii_bios_measurements_ops = {
const struct file_operations tpm_ascii_bios_measurements_ops = {
.open = tpm_ascii_bios_measurements_open,
.read = seq_read,
.llseek = seq_lseek,
......@@ -474,7 +474,7 @@ static int tpm_binary_bios_measurements_open(struct inode *inode,
return err;
}
struct file_operations tpm_binary_bios_measurements_ops = {
const struct file_operations tpm_binary_bios_measurements_ops = {
.open = tpm_binary_bios_measurements_open,
.read = seq_read,
.llseek = seq_lseek,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment