Commit fa027c2a authored by Arjan van de Ven's avatar Arjan van de Ven Committed by Linus Torvalds

[PATCH] mark struct file_operations const 4

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@sdl.org: dvb 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 2b8693c0
......@@ -885,7 +885,7 @@ static ssize_t adb_write(struct file *file, const char __user *buf,
return ret;
}
static struct file_operations adb_fops = {
static const struct file_operations adb_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = adb_read,
......
......@@ -121,7 +121,7 @@ anslcd_open( struct inode * inode, struct file * file )
return 0;
}
struct file_operations anslcd_fops = {
const struct file_operations anslcd_fops = {
.write = anslcd_write,
.ioctl = anslcd_ioctl,
.open = anslcd_open,
......
......@@ -501,7 +501,7 @@ static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length)
return p - buf;
}
static struct file_operations apm_bios_fops = {
static const struct file_operations apm_bios_fops = {
.owner = THIS_MODULE,
.read = do_read,
.poll = do_poll,
......
......@@ -100,7 +100,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,
......
......@@ -1277,7 +1277,7 @@ static int smu_release(struct inode *inode, struct file *file)
}
static struct file_operations smu_device_fops = {
static const struct file_operations smu_device_fops = {
.llseek = no_llseek,
.read = smu_read,
.write = smu_write,
......
......@@ -2672,7 +2672,7 @@ pmu_ioctl(struct inode * inode, struct file *filp,
return error;
}
static struct file_operations pmu_device_fops = {
static const struct file_operations pmu_device_fops = {
.read = pmu_read,
.write = pmu_write,
.poll = pmu_fpoll,
......
......@@ -1040,7 +1040,7 @@ static int pmu_ioctl(struct inode * inode, struct file *filp,
return -EINVAL;
}
static struct file_operations pmu_device_fops = {
static const struct file_operations pmu_device_fops = {
.read = pmu_read,
.write = pmu_write,
.ioctl = pmu_ioctl,
......
......@@ -1473,7 +1473,7 @@ static int ctl_ioctl(struct inode *inode, struct file *file,
return r;
}
static struct file_operations _ctl_fops = {
static const struct file_operations _ctl_fops = {
.ioctl = ctl_ioctl,
.owner = THIS_MODULE,
};
......
......@@ -4920,7 +4920,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
return mask;
}
static struct file_operations md_seq_fops = {
static const struct file_operations md_seq_fops = {
.owner = THIS_MODULE,
.open = md_seq_open,
.read = seq_read,
......
......@@ -416,7 +416,7 @@ static ssize_t fops_write(struct file *file, const char __user *data, size_t cou
}
}
static struct file_operations video_fops =
static const struct file_operations video_fops =
{
.owner = THIS_MODULE,
.open = fops_open,
......
......@@ -144,7 +144,7 @@ struct dsbr100_device {
/* File system interface */
static struct file_operations usb_dsbr100_fops = {
static const struct file_operations usb_dsbr100_fops = {
.owner = THIS_MODULE,
.open = usb_dsbr100_open,
.release = usb_dsbr100_close,
......
......@@ -216,7 +216,7 @@ static struct pcm20_device pcm20_unit = {
.muted = 1,
};
static struct file_operations pcm20_fops = {
static const struct file_operations pcm20_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -105,7 +105,7 @@ static ssize_t rds_f_read(struct file *file, char __user *buffer, size_t length,
}
}
static struct file_operations rds_fops = {
static const struct file_operations rds_fops = {
.owner = THIS_MODULE,
.read = rds_f_read,
.open = rds_f_open,
......
......@@ -358,7 +358,7 @@ static int rt_ioctl(struct inode *inode, struct file *file,
static struct rt_device rtrack_unit;
static struct file_operations rtrack_fops = {
static const struct file_operations rtrack_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -314,7 +314,7 @@ static int az_ioctl(struct inode *inode, struct file *file,
static struct az_device aztech_unit;
static struct file_operations aztech_fops = {
static const struct file_operations aztech_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -507,7 +507,7 @@ cadet_poll(struct file *file, struct poll_table_struct *wait)
}
static struct file_operations cadet_fops = {
static const struct file_operations cadet_fops = {
.owner = THIS_MODULE,
.open = cadet_open,
.release = cadet_release,
......
......@@ -346,7 +346,7 @@ MODULE_DEVICE_TABLE( pci, gemtek_pci_id );
static int mx = 1;
static struct file_operations gemtek_pci_fops = {
static const struct file_operations gemtek_pci_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -296,7 +296,7 @@ static int gemtek_ioctl(struct inode *inode, struct file *file,
static struct gemtek_device gemtek_unit;
static struct file_operations gemtek_fops = {
static const struct file_operations gemtek_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -99,7 +99,7 @@ static struct pci_driver maestro_r_driver = {
.remove = __devexit_p(maestro_remove),
};
static struct file_operations maestro_fops = {
static const struct file_operations maestro_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -91,7 +91,7 @@ module_param(radio_nr, int, 0);
static int radio_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);
static struct file_operations maxiradio_fops = {
static const struct file_operations maxiradio_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -262,7 +262,7 @@ static int rt_ioctl(struct inode *inode, struct file *file,
static struct rt_device rtrack2_unit;
static struct file_operations rtrack2_fops = {
static const struct file_operations rtrack2_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -265,7 +265,7 @@ static int fmi_ioctl(struct inode *inode, struct file *file,
static struct fmi_device fmi_unit;
static struct file_operations fmi_fops = {
static const struct file_operations fmi_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -410,7 +410,7 @@ static int fmr2_ioctl(struct inode *inode, struct file *file,
static struct fmr2_device fmr2_unit;
static struct file_operations fmr2_fops = {
static const struct file_operations fmr2_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -338,7 +338,7 @@ static int tt_ioctl(struct inode *inode, struct file *file,
static struct tt_device terratec_unit;
static struct file_operations terratec_fops = {
static const struct file_operations terratec_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -325,7 +325,7 @@ static int tr_ioctl(struct inode *inode, struct file *file,
return video_usercopy(inode, file, cmd, arg, tr_do_ioctl);
}
static struct file_operations trust_fops = {
static const struct file_operations trust_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -318,7 +318,7 @@ static struct typhoon_device typhoon_unit =
.mutefreq = CONFIG_RADIO_TYPHOON_MUTEFREQ,
};
static struct file_operations typhoon_fops = {
static const struct file_operations typhoon_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -373,7 +373,7 @@ static int zol_ioctl(struct inode *inode, struct file *file,
static struct zol_device zoltrix_unit;
static struct file_operations zoltrix_fops =
static const struct file_operations zoltrix_fops =
{
.owner = THIS_MODULE,
.open = video_exclusive_open,
......
......@@ -742,7 +742,7 @@ void ar_release(struct video_device *vfd)
* Video4Linux Module functions
*
****************************************************************************/
static struct file_operations ar_fops = {
static const struct file_operations ar_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -3174,7 +3174,7 @@ bttv_mmap(struct file *file, struct vm_area_struct *vma)
return videobuf_mmap_mapper(bttv_queue(fh),vma);
}
static struct file_operations bttv_fops =
static const struct file_operations bttv_fops =
{
.owner = THIS_MODULE,
.open = bttv_open,
......@@ -3332,7 +3332,7 @@ static unsigned int radio_poll(struct file *file, poll_table *wait)
return cmd.result;
}
static struct file_operations radio_fops =
static const struct file_operations radio_fops =
{
.owner = THIS_MODULE,
.open = radio_open,
......
......@@ -871,7 +871,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
return len;
}
static struct file_operations qcam_fops = {
static const struct file_operations qcam_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -684,7 +684,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
}
/* video device template */
static struct file_operations qcam_fops = {
static const struct file_operations qcam_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -1715,7 +1715,7 @@ static void cafe_v4l_dev_release(struct video_device *vd)
* clone it for specific real devices.
*/
static struct file_operations cafe_v4l_fops = {
static const struct file_operations cafe_v4l_fops = {
.owner = THIS_MODULE,
.open = cafe_v4l_open,
.release = cafe_v4l_release,
......@@ -1969,7 +1969,7 @@ static ssize_t cafe_dfs_read_regs(struct file *file,
s - cafe_debug_buf);
}
static struct file_operations cafe_dfs_reg_ops = {
static const struct file_operations cafe_dfs_reg_ops = {
.owner = THIS_MODULE,
.read = cafe_dfs_read_regs,
.open = cafe_dfs_open
......@@ -1995,7 +1995,7 @@ static ssize_t cafe_dfs_read_cam(struct file *file,
s - cafe_debug_buf);
}
static struct file_operations cafe_dfs_cam_ops = {
static const struct file_operations cafe_dfs_cam_ops = {
.owner = THIS_MODULE,
.read = cafe_dfs_read_cam,
.open = cafe_dfs_open
......
......@@ -3791,7 +3791,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
return 0;
}
static struct file_operations cpia_fops = {
static const struct file_operations cpia_fops = {
.owner = THIS_MODULE,
.open = cpia_open,
.release = cpia_close,
......
......@@ -1924,7 +1924,7 @@ static void reset_camera_struct_v4l(struct camera_data *cam)
/***
* The v4l video device structure initialized for this device
***/
static struct file_operations fops_template = {
static const struct file_operations fops_template = {
.owner = THIS_MODULE,
.open = cpia2_open,
.release = cpia2_close,
......
......@@ -1051,7 +1051,7 @@ mpeg_mmap(struct file *file, struct vm_area_struct * vma)
return videobuf_mmap_mapper(&fh->mpegq, vma);
}
static struct file_operations mpeg_fops =
static const struct file_operations mpeg_fops =
{
.owner = THIS_MODULE,
.open = mpeg_open,
......
......@@ -1808,7 +1808,7 @@ static irqreturn_t cx8800_irq(int irq, void *dev_id)
/* ----------------------------------------------------------- */
/* exported stuff */
static struct file_operations video_fops =
static const struct file_operations video_fops =
{
.owner = THIS_MODULE,
.open = video_open,
......@@ -1839,7 +1839,7 @@ static struct video_device cx8800_vbi_template =
.minor = -1,
};
static struct file_operations radio_fops =
static const struct file_operations radio_fops =
{
.owner = THIS_MODULE,
.open = video_open,
......
......@@ -696,7 +696,7 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm
return ret;
}
static struct file_operations dabusb_fops =
static const struct file_operations dabusb_fops =
{
.owner = THIS_MODULE,
.llseek = no_llseek,
......
......@@ -1480,7 +1480,7 @@ static int em28xx_v4l2_ioctl(struct inode *inode, struct file *filp,
return ret;
}
static struct file_operations em28xx_v4l_fops = {
static const struct file_operations em28xx_v4l_fops = {
.owner = THIS_MODULE,
.open = em28xx_v4l2_open,
.release = em28xx_v4l2_close,
......
......@@ -2454,7 +2454,7 @@ static int et61x251_ioctl(struct inode* inode, struct file* filp,
}
static struct file_operations et61x251_fops = {
static const struct file_operations et61x251_fops = {
.owner = THIS_MODULE,
.open = et61x251_open,
.release = et61x251_release,
......
......@@ -1748,7 +1748,7 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma)
return 0;
}
static struct file_operations meye_fops = {
static const struct file_operations meye_fops = {
.owner = THIS_MODULE,
.open = meye_open,
.release = meye_release,
......
......@@ -4653,7 +4653,7 @@ ov51x_v4l1_mmap(struct file *file, struct vm_area_struct *vma)
return 0;
}
static struct file_operations ov511_fops = {
static const struct file_operations ov511_fops = {
.owner = THIS_MODULE,
.open = ov51x_v4l1_open,
.release = ov51x_v4l1_close,
......
......@@ -881,7 +881,7 @@ static ssize_t pms_read(struct file *file, char __user *buf,
return len;
}
static struct file_operations pms_fops = {
static const struct file_operations pms_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -986,7 +986,7 @@ static unsigned int pvr2_v4l2_poll(struct file *file, poll_table *wait)
}
static struct file_operations vdev_fops = {
static const struct file_operations vdev_fops = {
.owner = THIS_MODULE,
.open = pvr2_v4l2_open,
.release = pvr2_v4l2_release,
......
......@@ -152,7 +152,7 @@ static int pwc_video_ioctl(struct inode *inode, struct file *file,
unsigned int ioctlnr, unsigned long arg);
static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma);
static struct file_operations pwc_fops = {
static const struct file_operations pwc_fops = {
.owner = THIS_MODULE,
.open = pwc_video_open,
.release = pwc_video_close,
......
......@@ -817,7 +817,7 @@ static void __exit cleanup_saa_5246a (void)
module_init(init_saa_5246a);
module_exit(cleanup_saa_5246a);
static struct file_operations saa_fops = {
static const struct file_operations saa_fops = {
.owner = THIS_MODULE,
.open = saa5246a_open,
.release = saa5246a_release,
......
......@@ -699,7 +699,7 @@ static void __exit cleanup_saa_5249 (void)
module_init(init_saa_5249);
module_exit(cleanup_saa_5249);
static struct file_operations saa_fops = {
static const struct file_operations saa_fops = {
.owner = THIS_MODULE,
.open = saa5249_open,
.release = saa5249_release,
......
......@@ -319,7 +319,7 @@ static int ts_ioctl(struct inode *inode, struct file *file,
return video_usercopy(inode, file, cmd, arg, ts_do_ioctl);
}
static struct file_operations ts_fops =
static const struct file_operations ts_fops =
{
.owner = THIS_MODULE,
.open = ts_open,
......
......@@ -563,7 +563,7 @@ static unsigned int dsp_poll(struct file *file, struct poll_table_struct *wait)
return mask;
}
struct file_operations saa7134_dsp_fops = {
const struct file_operations saa7134_dsp_fops = {
.owner = THIS_MODULE,
.open = dsp_open,
.release = dsp_release,
......@@ -804,7 +804,7 @@ static int mixer_ioctl(struct inode *inode, struct file *file,
}
}
struct file_operations saa7134_mixer_fops = {
const struct file_operations saa7134_mixer_fops = {
.owner = THIS_MODULE,
.open = mixer_open,
.release = mixer_release,
......
......@@ -2336,7 +2336,7 @@ static int radio_ioctl(struct inode *inode, struct file *file,
return video_usercopy(inode, file, cmd, arg, radio_do_ioctl);
}
static struct file_operations video_fops =
static const struct file_operations video_fops =
{
.owner = THIS_MODULE,
.open = video_open,
......@@ -2349,7 +2349,7 @@ static struct file_operations video_fops =
.llseek = no_llseek,
};
static struct file_operations radio_fops =
static const struct file_operations radio_fops =
{
.owner = THIS_MODULE,
.open = video_open,
......
......@@ -683,8 +683,8 @@ int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value);
/* ----------------------------------------------------------- */
/* saa7134-oss.c */
extern struct file_operations saa7134_dsp_fops;
extern struct file_operations saa7134_mixer_fops;
extern const struct file_operations saa7134_dsp_fops;
extern const struct file_operations saa7134_mixer_fops;
int saa7134_oss_init1(struct saa7134_dev *dev);
int saa7134_oss_fini(struct saa7134_dev *dev);
......
......@@ -1185,7 +1185,7 @@ static int se401_mmap(struct file *file, struct vm_area_struct *vma)
return 0;
}
static struct file_operations se401_fops = {
static const struct file_operations se401_fops = {
.owner = THIS_MODULE,
.open = se401_open,
.release = se401_close,
......
......@@ -2736,7 +2736,7 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp,
/*****************************************************************************/
static struct file_operations sn9c102_fops = {
static const struct file_operations sn9c102_fops = {
.owner = THIS_MODULE,
.open = sn9c102_open,
.release = sn9c102_release,
......
......@@ -1901,7 +1901,7 @@ static int saa_release(struct inode *inode, struct file *file)
return 0;
}
static struct file_operations saa_fops = {
static const struct file_operations saa_fops = {
.owner = THIS_MODULE,
.open = saa_open,
.release = saa_release,
......
......@@ -1380,7 +1380,7 @@ static ssize_t stv680_read (struct file *file, char __user *buf,
return realcount;
} /* stv680_read */
static struct file_operations stv680_fops = {
static const struct file_operations stv680_fops = {
.owner = THIS_MODULE,
.open = stv_open,
.release = stv_close,
......
......@@ -228,7 +228,7 @@ static struct i2c_driver driver = {
.detach_client = tvmixer_clients,
};
static struct file_operations tvmixer_fops = {
static const struct file_operations tvmixer_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = tvmixer_ioctl,
......
......@@ -945,7 +945,7 @@ static int usbvideo_find_struct(struct usbvideo *cams)
return rv;
}
static struct file_operations usbvideo_fops = {
static const struct file_operations usbvideo_fops = {
.owner = THIS_MODULE,
.open = usbvideo_v4l_open,
.release =usbvideo_v4l_close,
......
......@@ -1234,7 +1234,7 @@ static inline void vicam_create_proc_entry(struct vicam_camera *cam) { }
static inline void vicam_destroy_proc_entry(void *ptr) { }
#endif
static struct file_operations vicam_fops = {
static const struct file_operations vicam_fops = {
.owner = THIS_MODULE,
.open = vicam_open,
.release = vicam_close,
......
......@@ -1475,7 +1475,7 @@ static int usbvision_vbi_ioctl(struct inode *inode, struct file *file,
//
// Video template
static struct file_operations usbvision_fops = {
static const struct file_operations usbvision_fops = {
.owner = THIS_MODULE,
.open = usbvision_v4l2_open,
.release = usbvision_v4l2_close,
......@@ -1496,7 +1496,7 @@ static struct video_device usbvision_video_template = {
// Radio template
static struct file_operations usbvision_radio_fops = {
static const struct file_operations usbvision_radio_fops = {
.owner = THIS_MODULE,
.open = usbvision_radio_open,
.release = usbvision_radio_close,
......@@ -1517,7 +1517,7 @@ static struct video_device usbvision_radio_template=
// vbi template
static struct file_operations usbvision_vbi_fops = {
static const struct file_operations usbvision_vbi_fops = {
.owner = THIS_MODULE,
.open = usbvision_vbi_open,
.release = usbvision_vbi_close,
......
......@@ -1561,7 +1561,7 @@ int video_ioctl2 (struct inode *inode, struct file *file,
}
static struct file_operations video_fops;
static const struct file_operations video_fops;
/**
* video_register_device - register video4linux devices
......@@ -1709,7 +1709,7 @@ void video_unregister_device(struct video_device *vfd)
/*
* Video fs operations
*/
static struct file_operations video_fops=
static const struct file_operations video_fops=
{
.owner = THIS_MODULE,
.llseek = no_llseek,
......
......@@ -4390,7 +4390,7 @@ static int vino_ioctl(struct inode *inode, struct file *file,
// __initdata
static int vino_init_stage = 0;
static struct file_operations vino_fops = {
static const struct file_operations vino_fops = {
.owner = THIS_MODULE,
.open = vino_open,
.release = vino_close,
......
......@@ -1292,7 +1292,7 @@ vivi_mmap(struct file *file, struct vm_area_struct * vma)
return ret;
}
static struct file_operations vivi_fops = {
static const struct file_operations vivi_fops = {
.owner = THIS_MODULE,
.open = vivi_open,
.release = vivi_release,
......
......@@ -183,7 +183,7 @@ static int w9966_v4l_ioctl(struct inode *inode, struct file *file,
static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos);
static struct file_operations w9966_fops = {
static const struct file_operations w9966_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
......
......@@ -399,7 +399,7 @@ MODULE_PARM_DESC(specific_debug,
****************************************************************************/
/* Video4linux interface */
static struct file_operations w9968cf_fops;
static const struct file_operations w9968cf_fops;
static int w9968cf_open(struct inode*, struct file*);
static int w9968cf_release(struct inode*, struct file*);
static int w9968cf_mmap(struct file*, struct vm_area_struct*);
......@@ -3466,7 +3466,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
}
static struct file_operations w9968cf_fops = {
static const struct file_operations w9968cf_fops = {
.owner = THIS_MODULE,