Skip to content

Commit

Permalink
[PATCH] mark struct file_operations const 3
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.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
fenrus75 authored and Linus Torvalds committed Feb 12, 2007
1 parent 5dfe4c9 commit 2b8693c
Show file tree
Hide file tree
Showing 58 changed files with 83 additions and 83 deletions.
2 changes: 1 addition & 1 deletion block/blktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crypto/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/acorn/char/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/block/DAC960.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/acsi_slm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/aoe/aoechr.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off)
}
}

static struct file_operations aoe_fops = {
static const struct file_operations aoe_fops = {
.write = aoechr_write,
.read = aoechr_read,
.open = aoechr_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/paride/pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/paride/pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/bluetooth/hci_vhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/cdrom/viocd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/briq_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/drm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/i810_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/i830_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/generic_nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/mbcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions drivers/char/mspec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -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
};
Expand All @@ -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
};
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/tpm/tpm_bios.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/viotape.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ static int viotap_release(struct inode *inode, struct file *file)
return ret;
}

struct file_operations viotap_fops = {
const struct file_operations viotap_fops = {
owner: THIS_MODULE,
read: viotap_read,
write: viotap_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/watchdog/iTCO_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file,
* Kernel Interfaces
*/

static struct file_operations iTCO_wdt_fops = {
static const struct file_operations iTCO_wdt_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.write = iTCO_wdt_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/watchdog/omap_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ omap_wdt_ioctl(struct inode *inode, struct file *file,
}
}

static struct file_operations omap_wdt_fops = {
static const struct file_operations omap_wdt_fops = {
.owner = THIS_MODULE,
.write = omap_wdt_write,
.ioctl = omap_wdt_ioctl,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/watchdog/pc87413_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ static int pc87413_notify_sys(struct notifier_block *this,

/* -- Module's structures ---------------------------------------*/

static struct file_operations pc87413_fops = {
static const struct file_operations pc87413_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.write = pc87413_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/watchdog/pnx4008_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ static int pnx4008_wdt_release(struct inode *inode, struct file *file)
return 0;
}

static struct file_operations pnx4008_wdt_fops = {
static const struct file_operations pnx4008_wdt_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.write = pnx4008_wdt_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/watchdog/rm9k_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be disabled once started");


/* Kernel interfaces */
static struct file_operations fops = {
static const struct file_operations fops = {
.owner = THIS_MODULE,
.open = wdt_gpi_open,
.release = wdt_gpi_release,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/watchdog/smsc37b787_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ static int wb_smsc_wdt_notify_sys(struct notifier_block *this, unsigned long cod

/* -- Module's structures ---------------------------------------*/

static struct file_operations wb_smsc_wdt_fops =
static const struct file_operations wb_smsc_wdt_fops =
{
.owner = THIS_MODULE,
.llseek = no_llseek,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/watchdog/w83697hf_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ wdt_notify_sys(struct notifier_block *this, unsigned long code,
* Kernel Interfaces
*/

static struct file_operations wdt_fops = {
static const struct file_operations wdt_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.write = wdt_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/chips/tps65010.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static int dbg_tps_open(struct inode *inode, struct file *file)
return single_open(file, dbg_show, inode->i_private);
}

static struct file_operations debug_fops = {
static const struct file_operations debug_fops = {
.open = dbg_tps_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/i2c-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static int i2cdev_release(struct inode *inode, struct file *file)
return 0;
}

static struct file_operations i2cdev_fops = {
static const struct file_operations i2cdev_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = i2cdev_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/ide-proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ static int ide_drivers_open(struct inode *inode, struct file *file)
return single_open(file, &ide_drivers_show, NULL);
}

static struct file_operations ide_drivers_operations = {
static const struct file_operations ide_drivers_operations = {
.open = ide_drivers_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/ide-tape.c
Original file line number Diff line number Diff line change
Expand Up @@ -4779,7 +4779,7 @@ static ide_driver_t idetape_driver = {
/*
* Our character device supporting functions, passed to register_chrdev.
*/
static struct file_operations idetape_fops = {
static const struct file_operations idetape_fops = {
.owner = THIS_MODULE,
.read = idetape_chrdev_read,
.write = idetape_chrdev_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/ieee1394/dv1394.c
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ static void ir_tasklet_func(unsigned long data)
}

static struct cdev dv1394_cdev;
static struct file_operations dv1394_fops=
static const struct file_operations dv1394_fops=
{
.owner = THIS_MODULE,
.poll = dv1394_poll,
Expand Down
2 changes: 1 addition & 1 deletion drivers/ieee1394/raw1394.c
Original file line number Diff line number Diff line change
Expand Up @@ -3013,7 +3013,7 @@ static struct hpsb_highlevel raw1394_highlevel = {
};

static struct cdev raw1394_cdev;
static struct file_operations raw1394_fops = {
static const struct file_operations raw1394_fops = {
.owner = THIS_MODULE,
.read = raw1394_read,
.write = raw1394_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/ieee1394/video1394.c
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ static long video1394_compat_ioctl(struct file *f, unsigned cmd, unsigned long a
#endif

static struct cdev video1394_cdev;
static struct file_operations video1394_fops=
static const struct file_operations video1394_fops=
{
.owner = THIS_MODULE,
.unlocked_ioctl = video1394_ioctl,
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/core/ucm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ static void ib_ucm_release_class_dev(struct class_device *class_dev)
kfree(dev);
}

static struct file_operations ucm_fops = {
static const struct file_operations ucm_fops = {
.owner = THIS_MODULE,
.open = ib_ucm_open,
.release = ib_ucm_close,
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/core/ucma.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ static int ucma_close(struct inode *inode, struct file *filp)
return 0;
}

static struct file_operations ucma_fops = {
static const struct file_operations ucma_fops = {
.owner = THIS_MODULE,
.open = ucma_open,
.release = ucma_close,
Expand Down
Loading

0 comments on commit 2b8693c

Please sign in to comment.