Skip to content

Commit

Permalink
[PATCH] mark struct file_operations const 6
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 <[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 d54b1fd commit 00977a5
Show file tree
Hide file tree
Showing 45 changed files with 91 additions and 91 deletions.
2 changes: 1 addition & 1 deletion drivers/sbus/char/bpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ static int bpp_ioctl(struct inode *inode, struct file *f, unsigned int cmd,
return errno;
}

static struct file_operations bpp_fops = {
static const struct file_operations bpp_fops = {
.owner = THIS_MODULE,
.read = bpp_read,
.write = bpp_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/sbus/char/cpwatchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ static irqreturn_t wd_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}

static struct file_operations wd_fops = {
static const struct file_operations wd_fops = {
.owner = THIS_MODULE,
.ioctl = wd_ioctl,
.compat_ioctl = wd_compat_ioctl,
Expand Down
2 changes: 1 addition & 1 deletion drivers/sbus/char/display7seg.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static long d7s_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return error;
}

static struct file_operations d7s_fops = {
static const struct file_operations d7s_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = d7s_ioctl,
.compat_ioctl = d7s_ioctl,
Expand Down
2 changes: 1 addition & 1 deletion drivers/sbus/char/envctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ envctrl_release(struct inode *inode, struct file *file)
return 0;
}

static struct file_operations envctrl_fops = {
static const struct file_operations envctrl_fops = {
.owner = THIS_MODULE,
.read = envctrl_read,
.unlocked_ioctl = envctrl_ioctl,
Expand Down
2 changes: 1 addition & 1 deletion drivers/sbus/char/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ flash_release(struct inode *inode, struct file *file)
return 0;
}

static struct file_operations flash_fops = {
static const struct file_operations flash_fops = {
/* no write to the Flash, use mmap
* and play flash dependent tricks.
*/
Expand Down
2 changes: 1 addition & 1 deletion drivers/sbus/char/jsflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ static int jsf_release(struct inode *inode, struct file *file)
return 0;
}

static struct file_operations jsf_fops = {
static const struct file_operations jsf_fops = {
.owner = THIS_MODULE,
.llseek = jsf_lseek,
.read = jsf_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/sbus/char/openprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ static int openprom_release(struct inode * inode, struct file * file)
return 0;
}

static struct file_operations openprom_fops = {
static const struct file_operations openprom_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = openprom_ioctl,
Expand Down
2 changes: 1 addition & 1 deletion drivers/sbus/char/riowatchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static ssize_t riowd_write(struct file *file, const char __user *buf, size_t cou
return 0;
}

static struct file_operations riowd_fops = {
static const struct file_operations riowd_fops = {
.owner = THIS_MODULE,
.ioctl = riowd_ioctl,
.open = riowd_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/sbus/char/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static int rtc_release(struct inode *inode, struct file *file)
return 0;
}

static struct file_operations rtc_fops = {
static const struct file_operations rtc_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = rtc_ioctl,
Expand Down
2 changes: 1 addition & 1 deletion drivers/sbus/char/uctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static irqreturn_t uctrl_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}

static struct file_operations uctrl_fops = {
static const struct file_operations uctrl_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = uctrl_ioctl,
Expand Down
4 changes: 2 additions & 2 deletions drivers/sbus/char/vfc_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include "vfc.h"
#include <asm/vfc_ioctls.h>

static struct file_operations vfc_fops;
static const struct file_operations vfc_fops;
struct vfc_dev **vfc_dev_lst;
static char vfcstr[]="vfc";
static unsigned char saa9051_init_array[VFC_SAA9051_NR] = {
Expand Down Expand Up @@ -633,7 +633,7 @@ static int vfc_mmap(struct file *file, struct vm_area_struct *vma)
}


static struct file_operations vfc_fops = {
static const struct file_operations vfc_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = vfc_ioctl,
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/3w-9xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static struct class_device_attribute *twa_host_attrs[] = {
};

/* File operations struct for character device */
static struct file_operations twa_fops = {
static const struct file_operations twa_fops = {
.owner = THIS_MODULE,
.ioctl = twa_chrdev_ioctl,
.open = twa_chrdev_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/3w-xxxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ static int tw_chrdev_open(struct inode *inode, struct file *file)
} /* End tw_chrdev_open() */

/* File operations struct for character device */
static struct file_operations tw_fops = {
static const struct file_operations tw_fops = {
.owner = THIS_MODULE,
.ioctl = tw_chrdev_ioctl,
.open = tw_chrdev_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/aacraid/linit.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ static struct class_device_attribute *aac_attrs[] = {
};


static struct file_operations aac_cfg_fops = {
static const struct file_operations aac_cfg_fops = {
.owner = THIS_MODULE,
.ioctl = aac_cfg_ioctl,
#ifdef CONFIG_COMPAT
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/ch.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static struct scsi_driver ch_template =
},
};

static struct file_operations changer_fops =
static const struct file_operations changer_fops =
{
.owner = THIS_MODULE,
.open = ch_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/dpt_i2o.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static int sys_tbl_len = 0;
static adpt_hba* hba_chain = NULL;
static int hba_count = 0;

static struct file_operations adpt_fops = {
static const struct file_operations adpt_fops = {
.ioctl = adpt_ioctl,
.open = adpt_open,
.release = adpt_close
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/gdth.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ MODULE_AUTHOR("Achim Leubner");
MODULE_LICENSE("GPL");

/* ioctl interface */
static struct file_operations gdth_fops = {
static const struct file_operations gdth_fops = {
.ioctl = gdth_ioctl,
.open = gdth_open,
.release = gdth_close,
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/megaraid.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static struct mega_hbas mega_hbas[MAX_CONTROLLERS];
/*
* The File Operations structure for the serial/ioctl interface of the driver
*/
static struct file_operations megadev_fops = {
static const struct file_operations megadev_fops = {
.owner = THIS_MODULE,
.ioctl = megadev_ioctl,
.open = megadev_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/megaraid/megaraid_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static struct list_head adapters_list_g;

static wait_queue_head_t wait_q;

static struct file_operations lsi_fops = {
static const struct file_operations lsi_fops = {
.open = mraid_mm_open,
.ioctl = mraid_mm_ioctl,
#ifdef CONFIG_COMPAT
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/megaraid/megaraid_sas.c
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,7 @@ megasas_mgmt_compat_ioctl(struct file *file, unsigned int cmd,
/*
* File operations structure for management interface
*/
static struct file_operations megasas_mgmt_fops = {
static const struct file_operations megasas_mgmt_fops = {
.owner = THIS_MODULE,
.open = megasas_mgmt_open,
.release = megasas_mgmt_release,
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/osst.c
Original file line number Diff line number Diff line change
Expand Up @@ -5522,7 +5522,7 @@ __setup("osst=", osst_setup);

#endif

static struct file_operations osst_fops = {
static const struct file_operations osst_fops = {
.owner = THIS_MODULE,
.read = osst_read,
.write = osst_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/scsi_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static int proc_scsi_open(struct inode *inode, struct file *file)
return single_open(file, proc_scsi_show, NULL);
}

static struct file_operations proc_scsi_operations = {
static const struct file_operations proc_scsi_operations = {
.open = proc_scsi_open,
.read = seq_read,
.write = proc_scsi_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/scsi_tgt_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static int tgt_open(struct inode *inode, struct file *file)
return 0;
}

static struct file_operations tgt_fops = {
static const struct file_operations tgt_fops = {
.owner = THIS_MODULE,
.open = tgt_open,
.poll = tgt_poll,
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/st.c
Original file line number Diff line number Diff line change
Expand Up @@ -3864,7 +3864,7 @@ __setup("st=", st_setup);

#endif

static struct file_operations st_fops =
static const struct file_operations st_fops =
{
.owner = THIS_MODULE,
.read = st_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/telephony/ixj.c
Original file line number Diff line number Diff line change
Expand Up @@ -6663,7 +6663,7 @@ static int ixj_fasync(int fd, struct file *file_p, int mode)
return fasync_helper(fd, file_p, mode, &j->async_queue);
}

static struct file_operations ixj_fops =
static const struct file_operations ixj_fops =
{
.owner = THIS_MODULE,
.read = ixj_enhanced_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/telephony/phonedev.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void phone_unregister_device(struct phone_device *pfd)
}


static struct file_operations phone_fops =
static const struct file_operations phone_fops =
{
.owner = THIS_MODULE,
.open = phone_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/misc/adutux.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
}

/* file operations needed when we register this driver */
static struct file_operations adu_fops = {
static const struct file_operations adu_fops = {
.owner = THIS_MODULE,
.read = adu_read,
.write = adu_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/misc/ftdi-elan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ static ssize_t ftdi_elan_write(struct file *file,
return retval;
}

static struct file_operations ftdi_elan_fops = {
static const struct file_operations ftdi_elan_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = ftdi_elan_ioctl,
Expand Down
12 changes: 6 additions & 6 deletions drivers/video/mbx/mbxdebugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,37 +170,37 @@ static ssize_t misc_read_file(struct file *file, char __user *userbuf,
}


static struct file_operations sysconf_fops = {
static const struct file_operations sysconf_fops = {
.read = sysconf_read_file,
.write = write_file_dummy,
.open = open_file_generic,
};

static struct file_operations clock_fops = {
static const struct file_operations clock_fops = {
.read = clock_read_file,
.write = write_file_dummy,
.open = open_file_generic,
};

static struct file_operations display_fops = {
static const struct file_operations display_fops = {
.read = display_read_file,
.write = write_file_dummy,
.open = open_file_generic,
};

static struct file_operations gsctl_fops = {
static const struct file_operations gsctl_fops = {
.read = gsctl_read_file,
.write = write_file_dummy,
.open = open_file_generic,
};

static struct file_operations sdram_fops = {
static const struct file_operations sdram_fops = {
.read = sdram_read_file,
.write = write_file_dummy,
.open = open_file_generic,
};

static struct file_operations misc_fops = {
static const struct file_operations misc_fops = {
.read = misc_read_file,
.write = write_file_dummy,
.open = open_file_generic,
Expand Down
2 changes: 1 addition & 1 deletion drivers/zorro/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ proc_bus_zorro_read(struct file *file, char __user *buf, size_t nbytes, loff_t *
return nbytes;
}

static struct file_operations proc_bus_zorro_operations = {
static const struct file_operations proc_bus_zorro_operations = {
.llseek = proc_bus_zorro_lseek,
.read = proc_bus_zorro_read,
};
Expand Down
2 changes: 1 addition & 1 deletion fs/debugfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static ssize_t read_file_blob(struct file *file, char __user *user_buf,
blob->size);
}

static struct file_operations fops_blob = {
static const struct file_operations fops_blob = {
.read = read_file_blob,
.open = default_open,
};
Expand Down
4 changes: 2 additions & 2 deletions fs/dlm/debug_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static int rsb_open(struct inode *inode, struct file *file)
return 0;
}

static struct file_operations rsb_fops = {
static const struct file_operations rsb_fops = {
.owner = THIS_MODULE,
.open = rsb_open,
.read = seq_read,
Expand Down Expand Up @@ -331,7 +331,7 @@ static ssize_t waiters_read(struct file *file, char __user *userbuf,
return rv;
}

static struct file_operations waiters_fops = {
static const struct file_operations waiters_fops = {
.owner = THIS_MODULE,
.open = waiters_open,
.read = waiters_read
Expand Down
6 changes: 3 additions & 3 deletions fs/dlm/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

static const char *name_prefix="dlm";
static struct miscdevice ctl_device;
static struct file_operations device_fops;
static const struct file_operations device_fops;

#ifdef CONFIG_COMPAT

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

static struct file_operations device_fops = {
static const struct file_operations device_fops = {
.open = device_open,
.release = device_close,
.read = device_read,
Expand All @@ -768,7 +768,7 @@ static struct file_operations device_fops = {
.owner = THIS_MODULE,
};

static struct file_operations ctl_device_fops = {
static const struct file_operations ctl_device_fops = {
.open = ctl_device_open,
.release = ctl_device_close,
.write = device_write,
Expand Down
2 changes: 1 addition & 1 deletion fs/gfs2/locking/dlm/plock.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ static unsigned int dev_poll(struct file *file, poll_table *wait)
return 0;
}

static struct file_operations dev_fops = {
static const struct file_operations dev_fops = {
.read = dev_read,
.write = dev_write,
.poll = dev_poll,
Expand Down
4 changes: 2 additions & 2 deletions fs/nfs/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ static struct seq_operations nfs_server_list_ops = {
.show = nfs_server_list_show,
};

static struct file_operations nfs_server_list_fops = {
static const struct file_operations nfs_server_list_fops = {
.open = nfs_server_list_open,
.read = seq_read,
.llseek = seq_lseek,
Expand All @@ -1193,7 +1193,7 @@ static struct seq_operations nfs_volume_list_ops = {
.show = nfs_volume_list_show,
};

static struct file_operations nfs_volume_list_fops = {
static const struct file_operations nfs_volume_list_fops = {
.open = nfs_volume_list_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
Loading

0 comments on commit 00977a5

Please sign in to comment.