Commit 5dfe4c96 authored by Arjan van de Ven's avatar Arjan van de Ven Committed by Linus Torvalds
Browse files

[PATCH] mark struct file_operations const 2



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.

[akpm@osdl.org: sparc64 fix]
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 54047320
......@@ -329,7 +329,7 @@ static int rtc_fasync(int fd, struct file *file, int on)
return fasync_helper(fd, file, on, &rtc_async_queue);
}
static struct file_operations rtc_fops = {
static const struct file_operations rtc_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = rtc_read,
......
......@@ -407,7 +407,7 @@ static int at91_clk_open(struct inode *inode, struct file *file)
return single_open(file, at91_clk_show, NULL);
}
static struct file_operations at91_clk_operations = {
static const struct file_operations at91_clk_operations = {
.open = at91_clk_open,
.read = seq_read,
.llseek = seq_lseek,
......
......@@ -360,7 +360,7 @@ static int tlb_open(struct inode *inode, struct file *file)
return seq_open(file, &tlb_ops);
}
static struct file_operations proc_tlb_operations = {
static const struct file_operations proc_tlb_operations = {
.open = tlb_open,
.read = seq_read,
.llseek = seq_lseek,
......
......@@ -499,7 +499,7 @@ print_rtc_status(void)
/* The various file operations we support. */
static struct file_operations rtc_fops = {
static const struct file_operations rtc_fops = {
.owner = THIS_MODULE,
.ioctl = rtc_ioctl,
};
......
......@@ -172,7 +172,7 @@ static const char eeprom_name[] = "eeprom";
static struct eeprom_type eeprom;
/* This is the exported file-operations structure for this device. */
struct file_operations eeprom_fops =
const struct file_operations eeprom_fops =
{
.llseek = eeprom_lseek,
.read = eeprom_read,
......
......@@ -838,7 +838,7 @@ gpio_leds_ioctl(unsigned int cmd, unsigned long arg)
return 0;
}
struct file_operations gpio_fops = {
const struct file_operations gpio_fops = {
.owner = THIS_MODULE,
.poll = gpio_poll,
.ioctl = gpio_ioctl,
......
......@@ -692,7 +692,7 @@ i2c_ioctl(struct inode *inode, struct file *file,
return 0;
}
static struct file_operations i2c_fops = {
static const struct file_operations i2c_fops = {
.owner = THIS_MODULE,
.ioctl = i2c_ioctl,
.open = i2c_open,
......
......@@ -56,7 +56,7 @@ static const unsigned char days_in_month[] =
int pcf8563_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
static struct file_operations pcf8563_fops = {
static const struct file_operations pcf8563_fops = {
.owner = THIS_MODULE,
.ioctl = pcf8563_ioctl,
};
......
......@@ -266,7 +266,7 @@ static void print_user_dma_lists(struct cryptocop_dma_list_operation *dma_op);
struct file_operations cryptocop_fops = {
const struct file_operations cryptocop_fops = {
owner: THIS_MODULE,
open: cryptocop_open,
release: cryptocop_release,
......
......@@ -705,7 +705,7 @@ gpio_leds_ioctl(unsigned int cmd, unsigned long arg)
return 0;
}
struct file_operations gpio_fops = {
const struct file_operations gpio_fops = {
.owner = THIS_MODULE,
.poll = gpio_poll,
.ioctl = gpio_ioctl,
......
......@@ -573,7 +573,7 @@ i2c_ioctl(struct inode *inode, struct file *file,
return 0;
}
static struct file_operations i2c_fops = {
static const struct file_operations i2c_fops = {
owner: THIS_MODULE,
ioctl: i2c_ioctl,
open: i2c_open,
......
......@@ -50,7 +50,7 @@ int pcf8563_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
int pcf8563_open(struct inode *, struct file *);
int pcf8563_release(struct inode *, struct file *);
static struct file_operations pcf8563_fops = {
static const struct file_operations pcf8563_fops = {
owner: THIS_MODULE,
ioctl: pcf8563_ioctl,
open: pcf8563_open,
......
......@@ -187,7 +187,7 @@ static struct sync_port ports[]=
#define NUMBER_OF_PORTS (sizeof(ports)/sizeof(sync_port))
static struct file_operations sync_serial_fops = {
static const struct file_operations sync_serial_fops = {
.owner = THIS_MODULE,
.write = sync_serial_write,
.read = sync_serial_read,
......
......@@ -50,7 +50,7 @@ write_cris_profile(struct file *file, const char __user *buf,
memset(sample_buffer, 0, SAMPLE_BUFFER_SIZE);
}
static struct file_operations cris_proc_profile_operations = {
static const struct file_operations cris_proc_profile_operations = {
.read = read_cris_profile,
.write = write_cris_profile,
};
......
......@@ -1894,7 +1894,7 @@ static int __init apm_setup(char *str)
__setup("apm=", apm_setup);
#endif
static struct file_operations apm_bios_fops = {
static const struct file_operations apm_bios_fops = {
.owner = THIS_MODULE,
.read = do_read,
.poll = do_poll,
......
......@@ -339,7 +339,7 @@ static int mtrr_open(struct inode *inode, struct file *file)
return single_open(file, mtrr_seq_show, NULL);
}
static struct file_operations mtrr_fops = {
static const struct file_operations mtrr_fops = {
.owner = THIS_MODULE,
.open = mtrr_open,
.read = seq_read,
......
......@@ -148,7 +148,7 @@ static int cpuid_open(struct inode *inode, struct file *file)
/*
* File operations we support
*/
static struct file_operations cpuid_fops = {
static const struct file_operations cpuid_fops = {
.owner = THIS_MODULE,
.llseek = cpuid_seek,
.read = cpuid_read,
......
......@@ -451,7 +451,7 @@ static ssize_t microcode_write (struct file *file, const char __user *buf, size_
return ret;
}
static struct file_operations microcode_fops = {
static const struct file_operations microcode_fops = {
.owner = THIS_MODULE,
.write = microcode_write,
.open = microcode_open,
......
......@@ -230,7 +230,7 @@ static int msr_open(struct inode *inode, struct file *file)
/*
* File operations we support
*/
static struct file_operations msr_fops = {
static const struct file_operations msr_fops = {
.owner = THIS_MODULE,
.llseek = msr_seek,
.read = msr_read,
......
......@@ -1881,7 +1881,7 @@ ioc_open(struct inode *inode, struct file *file)
return seq_open(file, &ioc_seq_ops);
}
static struct file_operations ioc_fops = {
static const struct file_operations ioc_fops = {
.open = ioc_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