Skip to content

Commit

Permalink
[PATCH] make more file_operation structs static
Browse files Browse the repository at this point in the history
Mark the static struct file_operations in drivers/char as const.  Making
them const prevents accidental bugs, and moves them to the .rodata section
so that they no longer do any false sharing; in addition with the proper
debug option they are then protected against corruption..

[akpm@osdl.org: build fix]
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Arjan van de Ven authored and Linus Torvalds committed Jul 3, 2006
1 parent d459ec0 commit 62322d2
Show file tree
Hide file tree
Showing 97 changed files with 118 additions and 118 deletions.
2 changes: 1 addition & 1 deletion drivers/char/agp/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ static int agp_ioctl(struct inode *inode, struct file *file,
return ret_val;
}

static struct file_operations agp_fops =
static const struct file_operations agp_fops =
{
.owner = THIS_MODULE,
.llseek = no_llseek,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/applicom.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static int ac_ioctl(struct inode *, struct file *, unsigned int,
unsigned long);
static irqreturn_t ac_interrupt(int, void *, struct pt_regs *);

static struct file_operations ac_fops = {
static const struct file_operations ac_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = ac_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/cs5535_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static int cs5535_gpio_open(struct inode *inode, struct file *file)
return nonseekable_open(inode, file);
}

static struct file_operations cs5535_gpio_fops = {
static const struct file_operations cs5535_gpio_fops = {
.owner = THIS_MODULE,
.write = cs5535_gpio_write,
.read = cs5535_gpio_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ds1286.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static unsigned int ds1286_poll(struct file *file, poll_table *wait)
* The various file operations we support.
*/

static struct file_operations ds1286_fops = {
static const struct file_operations ds1286_fops = {
.llseek = no_llseek,
.read = ds1286_read,
.poll = ds1286_poll,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ds1302.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ get_rtc_status(char *buf)

/* 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 drivers/char/ds1620.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ proc_therm_ds1620_read(char *buf, char **start, off_t offset,
static struct proc_dir_entry *proc_therm_ds1620;
#endif

static struct file_operations ds1620_fops = {
static const struct file_operations ds1620_fops = {
.owner = THIS_MODULE,
.open = nonseekable_open,
.read = ds1620_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/dsp56k.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ static int dsp56k_release(struct inode *inode, struct file *file)
return 0;
}

static struct file_operations dsp56k_fops = {
static const struct file_operations dsp56k_fops = {
.owner = THIS_MODULE,
.read = dsp56k_read,
.write = dsp56k_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/dtlk.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static int dtlk_release(struct inode *, struct file *);
static int dtlk_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);

static struct file_operations dtlk_fops =
static const struct file_operations dtlk_fops =
{
.owner = THIS_MODULE,
.read = dtlk_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/efirtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ efi_rtc_close(struct inode *inode, struct file *file)
* The various file operations we support.
*/

static struct file_operations efi_rtc_fops = {
static const struct file_operations efi_rtc_fops = {
.owner = THIS_MODULE,
.ioctl = efi_rtc_ioctl,
.open = efi_rtc_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ftape/zftape/zftape-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static ssize_t zft_read (struct file *fp, char __user *buff,
static ssize_t zft_write(struct file *fp, const char __user *buff,
size_t req_len, loff_t *ppos);

static struct file_operations zft_cdev =
static const struct file_operations zft_cdev =
{
.owner = THIS_MODULE,
.read = zft_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/genrtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ static inline int gen_rtc_proc_init(void) { return 0; }
* The various file operations we support.
*/

static struct file_operations gen_rtc_fops = {
static const struct file_operations gen_rtc_fops = {
.owner = THIS_MODULE,
#ifdef CONFIG_GEN_RTC_X
.read = gen_rtc_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/hpet.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
return err;
}

static struct file_operations hpet_fops = {
static const struct file_operations hpet_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = hpet_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/hw_random/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf,
}


static struct file_operations rng_chrdev_ops = {
static const struct file_operations rng_chrdev_ops = {
.owner = THIS_MODULE,
.open = rng_dev_open,
.read = rng_dev_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/i8k.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static int i8k_open_fs(struct inode *inode, struct file *file);
static int i8k_ioctl(struct inode *, struct file *, unsigned int,
unsigned long);

static struct file_operations i8k_fops = {
static const struct file_operations i8k_fops = {
.open = i8k_open_fs,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ip2/ip2main.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static void *DevTableMem[IP2_MAX_BOARDS];
/* This is the driver descriptor for the ip2ipl device, which is used to
* download the loadware to the boards.
*/
static struct file_operations ip2_ipl = {
static const struct file_operations ip2_ipl = {
.owner = THIS_MODULE,
.read = ip2_ipl_read,
.write = ip2_ipl_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ip27-rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,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 = {
.owner = THIS_MODULE,
.ioctl = rtc_ioctl,
.open = rtc_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ipmi/ipmi_devintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
}
#endif

static struct file_operations ipmi_fops = {
static const struct file_operations ipmi_fops = {
.owner = THIS_MODULE,
.ioctl = ipmi_ioctl,
#ifdef CONFIG_COMPAT
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ipmi/ipmi_watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ static int ipmi_close(struct inode *ino, struct file *filep)
return 0;
}

static struct file_operations ipmi_wdog_fops = {
static const struct file_operations ipmi_wdog_fops = {
.owner = THIS_MODULE,
.read = ipmi_read,
.poll = ipmi_poll,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/istallion.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp);
* will give access to the shared memory on the Stallion intelligent
* board. This is also a very useful debugging tool.
*/
static struct file_operations stli_fsiomem = {
static const struct file_operations stli_fsiomem = {
.owner = THIS_MODULE,
.read = stli_memread,
.write = stli_memwrite,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ite_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ DEB(printk("interrupt 0x%x %d\n",ITE_GPAISR, i));
}
}

static struct file_operations ite_gpio_fops = {
static const struct file_operations ite_gpio_fops = {
.owner = THIS_MODULE,
.ioctl = ite_gpio_ioctl,
.open = ite_gpio_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ static ssize_t lcd_read(struct file *file, char *buf,
* The various file operations we support.
*/

static struct file_operations lcd_fops = {
static const struct file_operations lcd_fops = {
.read = lcd_read,
.ioctl = lcd_ioctl,
.open = lcd_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/lp.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ static int lp_ioctl(struct inode *inode, struct file *file,
return retval;
}

static struct file_operations lp_fops = {
static const struct file_operations lp_fops = {
.owner = THIS_MODULE,
.write = lp_write,
.ioctl = lp_ioctl,
Expand Down
18 changes: 9 additions & 9 deletions drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,39 +776,39 @@ static int open_port(struct inode * inode, struct file * filp)
#define open_kmem open_mem
#define open_oldmem open_mem

static struct file_operations mem_fops = {
static const struct file_operations mem_fops = {
.llseek = memory_lseek,
.read = read_mem,
.write = write_mem,
.mmap = mmap_mem,
.open = open_mem,
};

static struct file_operations kmem_fops = {
static const struct file_operations kmem_fops = {
.llseek = memory_lseek,
.read = read_kmem,
.write = write_kmem,
.mmap = mmap_kmem,
.open = open_kmem,
};

static struct file_operations null_fops = {
static const struct file_operations null_fops = {
.llseek = null_lseek,
.read = read_null,
.write = write_null,
.splice_write = splice_write_null,
};

#if defined(CONFIG_ISA) || !defined(__mc68000__)
static struct file_operations port_fops = {
static const struct file_operations port_fops = {
.llseek = memory_lseek,
.read = read_port,
.write = write_port,
.open = open_port,
};
#endif

static struct file_operations zero_fops = {
static const struct file_operations zero_fops = {
.llseek = zero_lseek,
.read = read_zero,
.write = write_zero,
Expand All @@ -819,14 +819,14 @@ static struct backing_dev_info zero_bdi = {
.capabilities = BDI_CAP_MAP_COPY,
};

static struct file_operations full_fops = {
static const struct file_operations full_fops = {
.llseek = full_lseek,
.read = read_full,
.write = write_full,
};

#ifdef CONFIG_CRASH_DUMP
static struct file_operations oldmem_fops = {
static const struct file_operations oldmem_fops = {
.read = read_oldmem,
.open = open_oldmem,
};
Expand All @@ -853,7 +853,7 @@ static ssize_t kmsg_write(struct file * file, const char __user * buf,
return ret;
}

static struct file_operations kmsg_fops = {
static const struct file_operations kmsg_fops = {
.write = kmsg_write,
};

Expand Down Expand Up @@ -903,7 +903,7 @@ static int memory_open(struct inode * inode, struct file * filp)
return 0;
}

static struct file_operations memory_fops = {
static const struct file_operations memory_fops = {
.open = memory_open, /* just a selector for the real open */
};

Expand Down
4 changes: 2 additions & 2 deletions drivers/char/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static int misc_seq_open(struct inode *inode, struct file *file)
return seq_open(file, &misc_seq_ops);
}

static struct file_operations misc_proc_fops = {
static const struct file_operations misc_proc_fops = {
.owner = THIS_MODULE,
.open = misc_seq_open,
.read = seq_read,
Expand Down Expand Up @@ -176,7 +176,7 @@ static int misc_open(struct inode * inode, struct file * file)
*/
static struct class *misc_class;

static struct file_operations misc_fops = {
static const struct file_operations misc_fops = {
.owner = THIS_MODULE,
.open = misc_open,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/mmtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma);
*/
static unsigned long mmtimer_femtoperiod = 0;

static struct file_operations mmtimer_fops = {
static const struct file_operations mmtimer_fops = {
.owner = THIS_MODULE,
.mmap = mmtimer_mmap,
.ioctl = mmtimer_ioctl,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/mwave/mwavedd.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ static int register_serial_portandirq(unsigned int port, int irq)
}


static struct file_operations mwave_fops = {
static const struct file_operations mwave_fops = {
.owner = THIS_MODULE,
.read = mwave_read,
.write = mwave_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ nvram_read_proc(char *buffer, char **start, off_t offset,

#endif /* CONFIG_PROC_FS */

static struct file_operations nvram_fops = {
static const struct file_operations nvram_fops = {
.owner = THIS_MODULE,
.llseek = nvram_llseek,
.read = nvram_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/nwbutton.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static int button_read (struct file *filp, char __user *buffer,
* attempts to perform these operations on the device.
*/

static struct file_operations button_fops = {
static const struct file_operations button_fops = {
.owner = THIS_MODULE,
.read = button_read,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/nwflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ static void kick_open(void)
udelay(25);
}

static struct file_operations flash_fops =
static const struct file_operations flash_fops =
{
.owner = THIS_MODULE,
.llseek = flash_llseek,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/pc8736x_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static int pc8736x_gpio_open(struct inode *inode, struct file *file)
return nonseekable_open(inode, file);
}

static struct file_operations pc8736x_gpio_fops = {
static const struct file_operations pc8736x_gpio_fops = {
.owner = THIS_MODULE,
.open = pc8736x_gpio_open,
.write = nsc_gpio_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/pcmcia/cm4000_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ static void cm4000_detach(struct pcmcia_device *link)
return;
}

static struct file_operations cm4000_fops = {
static const struct file_operations cm4000_fops = {
.owner = THIS_MODULE,
.read = cmm_read,
.write = cmm_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/pcmcia/cm4040_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ static void reader_detach(struct pcmcia_device *link)
return;
}

static struct file_operations reader_fops = {
static const struct file_operations reader_fops = {
.owner = THIS_MODULE,
.read = cm4040_read,
.write = cm4040_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ppdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ static unsigned int pp_poll (struct file * file, poll_table * wait)

static struct class *ppdev_class;

static struct file_operations pp_fops = {
static const struct file_operations pp_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = pp_read,
Expand Down
Loading

0 comments on commit 62322d2

Please sign in to comment.