Skip to content

Commit

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

[akpm@sdl.org: dvb fix]
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
Arjan van de Ven authored and Linus Torvalds committed Feb 12, 2007
1 parent 2b8693c commit fa027c2
Show file tree
Hide file tree
Showing 67 changed files with 78 additions and 78 deletions.
2 changes: 1 addition & 1 deletion drivers/macintosh/adb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/ans-lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/apm_emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/smu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/via-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/via-pmu68k.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/common/saa7146_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/dsbr100.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/miropcm20-radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/miropcm20-rds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-aimslab.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-aztech.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-cadet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-gemtek-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-gemtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-maestro.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-maxiradio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-rtrack2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-sf16fmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-sf16fmr2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-terratec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-trust.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-typhoon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-zoltrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/arv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/bt8xx/bttv-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/bw-qcam.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/c-qcam.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/video/cafe_ccic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/cpia.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/cpia2/cpia2_v4l.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/cx88/cx88-blackbird.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/cx88/cx88-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/dabusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/em28xx/em28xx-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/et61x251/et61x251_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/meye.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit fa027c2

Please sign in to comment.