Skip to content

Commit

Permalink
[PATCH] mark struct file_operations const 2
Browse files Browse the repository at this point in the history
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.

[[email protected]: sparc64 fix]
Signed-off-by: Arjan van de Ven <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
fenrus75 authored and Linus Torvalds committed Feb 12, 2007
1 parent 5404732 commit 5dfe4c9
Show file tree
Hide file tree
Showing 59 changed files with 94 additions and 94 deletions.
2 changes: 1 addition & 1 deletion arch/arm/common/rtctime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91rm9200/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/avr32/mm/tlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v10/drivers/ds1302.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v10/drivers/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v10/drivers/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v10/drivers/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v10/drivers/pcf8563.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v32/drivers/cryptocop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v32/drivers/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v32/drivers/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v32/drivers/pcf8563.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v32/drivers/sync_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/kernel/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion arch/i386/kernel/apm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/i386/kernel/cpu/mtrr/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/i386/kernel/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/i386/kernel/microcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/i386/kernel/msr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/hp/common/sba_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions arch/ia64/kernel/perfmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ EXPORT_PER_CPU_SYMBOL_GPL(pfm_syst_info);


/* forward declaration */
static struct file_operations pfm_file_ops;
static const struct file_operations pfm_file_ops;

/*
* forward declarations
Expand Down Expand Up @@ -2126,7 +2126,7 @@ pfm_no_open(struct inode *irrelevant, struct file *dontcare)



static struct file_operations pfm_file_ops = {
static const struct file_operations pfm_file_ops = {
.llseek = no_llseek,
.read = pfm_read,
.write = pfm_write,
Expand Down Expand Up @@ -6596,7 +6596,7 @@ pfm_probe_pmu(void)
return 0;
}

static struct file_operations pfm_proc_fops = {
static const struct file_operations pfm_proc_fops = {
.open = pfm_proc_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
4 changes: 2 additions & 2 deletions arch/ia64/kernel/salinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ salinfo_event_read(struct file *file, char __user *buffer, size_t count, loff_t
return size;
}

static struct file_operations salinfo_event_fops = {
static const struct file_operations salinfo_event_fops = {
.open = salinfo_event_open,
.read = salinfo_event_read,
};
Expand Down Expand Up @@ -568,7 +568,7 @@ salinfo_log_write(struct file *file, const char __user *buffer, size_t count, lo
return count;
}

static struct file_operations salinfo_data_fops = {
static const struct file_operations salinfo_data_fops = {
.open = salinfo_log_open,
.release = salinfo_log_release,
.read = salinfo_log_read,
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/sn/kernel/sn2/sn2_smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ static int sn2_ptc_proc_open(struct inode *inode, struct file *file)
return seq_open(file, &sn2_ptc_seq_ops);
}

static struct file_operations proc_sn2_ptc_operations = {
static const struct file_operations proc_sn2_ptc_operations = {
.open = sn2_ptc_proc_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/sn/kernel/sn2/sn_hwperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ sn_hwperf_ioctl(struct inode *in, struct file *fp, u32 op, u64 arg)
return r;
}

static struct file_operations sn_hwperf_fops = {
static const struct file_operations sn_hwperf_fops = {
.ioctl = sn_hwperf_ioctl,
};

Expand Down
2 changes: 1 addition & 1 deletion arch/m68k/bvme6000/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static int rtc_release(struct inode *inode, struct file *file)
* The various file operations we support.
*/

static struct file_operations rtc_fops = {
static const struct file_operations rtc_fops = {
.ioctl = rtc_ioctl,
.open = rtc_open,
.release = rtc_release,
Expand Down
2 changes: 1 addition & 1 deletion arch/m68k/mvme16x/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static int rtc_release(struct inode *inode, struct file *file)
* The various file operations we support.
*/

static struct file_operations rtc_fops = {
static const struct file_operations rtc_fops = {
.ioctl = rtc_ioctl,
.open = rtc_open,
.release = rtc_release,
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/kernel/rtlx.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ static ssize_t file_write(struct file *file, const char __user * buffer,
return rtlx_write(minor, (void *)buffer, count, 1);
}

static struct file_operations rtlx_fops = {
static const struct file_operations rtlx_fops = {
.owner = THIS_MODULE,
.open = file_open,
.release = file_release,
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/kernel/vpe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ static ssize_t vpe_write(struct file *file, const char __user * buffer,
return ret;
}

static struct file_operations vpe_fops = {
static const struct file_operations vpe_fops = {
.owner = THIS_MODULE,
.open = vpe_open,
.release = vpe_release,
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/sibyte/sb1250/bcm1250_tbprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ static long sbprof_tb_ioctl(struct file *filp,
return error;
}

static struct file_operations sbprof_tb_fops = {
static const struct file_operations sbprof_tb_fops = {
.owner = THIS_MODULE,
.open = sbprof_tb_open,
.release = sbprof_tb_release,
Expand Down
2 changes: 1 addition & 1 deletion arch/parisc/kernel/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return error;
}

static struct file_operations perf_fops = {
static const struct file_operations perf_fops = {
.llseek = no_llseek,
.read = perf_read,
.write = perf_write,
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/lparcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ static int lparcfg_open(struct inode *inode, struct file *file)
return single_open(file, lparcfg_data, NULL);
}

struct file_operations lparcfg_fops = {
const struct file_operations lparcfg_fops = {
.owner = THIS_MODULE,
.read = seq_read,
.write = lparcfg_write,
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/nvram_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static int dev_nvram_ioctl(struct inode *inode, struct file *file,
}
}

struct file_operations nvram_fops = {
const struct file_operations nvram_fops = {
.owner = THIS_MODULE,
.llseek = dev_nvram_llseek,
.read = dev_nvram_read,
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/proc_ppc64.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes
loff_t *ppos);
static int page_map_mmap( struct file *file, struct vm_area_struct *vma );

static struct file_operations page_map_fops = {
static const struct file_operations page_map_fops = {
.llseek = page_map_seek,
.read = page_map_read,
.mmap = page_map_mmap
Expand Down
14 changes: 7 additions & 7 deletions arch/powerpc/kernel/rtas-proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static int sensors_open(struct inode *inode, struct file *file)
return single_open(file, ppc_rtas_sensors_show, NULL);
}

struct file_operations ppc_rtas_sensors_operations = {
const struct file_operations ppc_rtas_sensors_operations = {
.open = sensors_open,
.read = seq_read,
.llseek = seq_lseek,
Expand All @@ -172,7 +172,7 @@ static int poweron_open(struct inode *inode, struct file *file)
return single_open(file, ppc_rtas_poweron_show, NULL);
}

struct file_operations ppc_rtas_poweron_operations = {
const struct file_operations ppc_rtas_poweron_operations = {
.open = poweron_open,
.read = seq_read,
.llseek = seq_lseek,
Expand All @@ -185,7 +185,7 @@ static int progress_open(struct inode *inode, struct file *file)
return single_open(file, ppc_rtas_progress_show, NULL);
}

struct file_operations ppc_rtas_progress_operations = {
const struct file_operations ppc_rtas_progress_operations = {
.open = progress_open,
.read = seq_read,
.llseek = seq_lseek,
Expand All @@ -198,7 +198,7 @@ static int clock_open(struct inode *inode, struct file *file)
return single_open(file, ppc_rtas_clock_show, NULL);
}

struct file_operations ppc_rtas_clock_operations = {
const struct file_operations ppc_rtas_clock_operations = {
.open = clock_open,
.read = seq_read,
.llseek = seq_lseek,
Expand All @@ -211,7 +211,7 @@ static int tone_freq_open(struct inode *inode, struct file *file)
return single_open(file, ppc_rtas_tone_freq_show, NULL);
}

struct file_operations ppc_rtas_tone_freq_operations = {
const struct file_operations ppc_rtas_tone_freq_operations = {
.open = tone_freq_open,
.read = seq_read,
.llseek = seq_lseek,
Expand All @@ -224,7 +224,7 @@ static int tone_volume_open(struct inode *inode, struct file *file)
return single_open(file, ppc_rtas_tone_volume_show, NULL);
}

struct file_operations ppc_rtas_tone_volume_operations = {
const struct file_operations ppc_rtas_tone_volume_operations = {
.open = tone_volume_open,
.read = seq_read,
.llseek = seq_lseek,
Expand All @@ -237,7 +237,7 @@ static int rmo_buf_open(struct inode *inode, struct file *file)
return single_open(file, ppc_rtas_rmo_buf_show, NULL);
}

struct file_operations ppc_rtas_rmo_buf_ops = {
const struct file_operations ppc_rtas_rmo_buf_ops = {
.open = rmo_buf_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
Loading

0 comments on commit 5dfe4c9

Please sign in to comment.