Constify struct file_operations for 2.6.32-git-053fe57ac v2
Subsystems (11)
PATCH 6/9 Constify struct file_operations for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- drivers/net/wireless/b43/debugfs.c | 2 +- drivers/net/wireless/b43legacy/debugfs.c | 2 +- drivers/net/wireless/libertas/debugfs.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/b43/debugfs.c +1 -1
@@ -43,7 +43,7 @@ static struct dentry *rootdir;struct b43_debugfs_fops {ssize_t (*read)(struct b43_wldev *dev,char *buf,size_t bufsize);int (*write)(struct b43_wldev *dev,const char *buf,size_t count); -struct file_operations fops; +const struct file_operations fops;/* Offset of struct b43_dfs_file in struct b43_dfsentry */ size_t file_struct_offset; };
drivers/net/wireless/b43legacy/debugfs.c +1 -1
@@ -44,7 +44,7 @@ static struct dentry *rootdir;struct b43legacy_debugfs_fops {ssize_t (*read)(struct b43legacy_wldev *dev,char *buf,size_t bufsize);int (*write)(struct b43legacy_wldev *dev,const char *buf,size_t count); -struct file_operations fops; +const struct file_operations fops;/* Offset of struct b43legacy_dfs_file in struct b43legacy_dfsentry */ size_t file_struct_offset;/* Take wl->irq_lock before calling read/write? */
drivers/net/wireless/libertas/debugfs.c +1 -1
@@ -717,7 +717,7 @@ out_unlock:struct lbs_debugfs_files {const char *name;int perm; -struct file_operations fops; +const struct file_operations fops; };static const struct lbs_debugfs_files debugfs_files[] = {
Signature · 1 line
1.6.5.3
PATCH 5/9 Constify struct file_operations for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- drivers/media/dvb/dvb-core/dvbdev.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/media/dvb/dvb-core/dvbdev.c +1 -0
@@ -191,6 +191,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, const struct dvb_device *template, void *priv, int type) { struct dvb_device *dvbdev; +/* cannot be const, see this function */ struct file_operations *dvbdevfops;struct device *clsdev;int minor;
Signature · 1 line
1.6.5.3
PATCH 3/9 Constify struct file_operations for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- fs/fuse/cuse.c | 19 ++++++++++++------- fs/fuse/dev.c | 8 ++++---- fs/fuse/fuse_i.h | 10 ++++++++++ 3 files changed, 26 insertions(+), 11 deletions(-)
fs/fuse/cuse.c +12 -7
@@ -528,7 +528,18 @@ static int cuse_channel_release(struct inode *inode, struct file *file)return rc; } -static struct file_operations cuse_channel_fops;/* initialized during init */ +static const struct file_operations cuse_channel_fops = {/* initialized during init */ + .owner =THIS_MODULE , + .llseek = no_llseek, + .read = do_sync_read, + .aio_read = fuse_dev_read, + .write = do_sync_write, + .aio_write = fuse_dev_write, + .poll = fuse_dev_poll, + .open = cuse_channel_open, + .release = cuse_channel_release, + .fasync = fuse_dev_fasync, +};/**************************************************************************
@@ -575,12 +586,6 @@ static int __init cuse_init(void)for (i =0 ; i <CUSE_CONNTBL_LEN ; i++)INIT_LIST_HEAD (&cuse_conntbl[i]); -/* inherit and extend fuse_dev_operations */ - cuse_channel_fops = fuse_dev_operations; - cuse_channel_fops.owner =THIS_MODULE ; - cuse_channel_fops.open = cuse_channel_open; - cuse_channel_fops.release = cuse_channel_release; - cuse_class =class_create (THIS_MODULE ,"cuse" );if (IS_ERR (cuse_class))return PTR_ERR (cuse_class);
fs/fuse/dev.c +4 -4
@@ -745,7 +745,7 @@ __releases(&fc->lock)* request_end(). Otherwise add it to the processing list, and set * the 'sent' flag. */ -static ssize_t fuse_dev_read (struct kiocb *iocb,const struct iovec *iov, +ssize_t fuse_dev_read (struct kiocb *iocb,const struct iovec *iov,unsigned long nr_segs,loff_t pos) {int err;
@@ -987,7 +987,7 @@ static int copy_out_args(struct fuse_copy_state *cs, struct fuse_out *out,* it from the list and copy the rest of the buffer to the request. * The request is finished by calling request_end() */ -static ssize_t fuse_dev_write (struct kiocb *iocb,const struct iovec *iov, +ssize_t fuse_dev_write (struct kiocb *iocb,const struct iovec *iov,unsigned long nr_segs,loff_t pos) {int err;
@@ -1084,7 +1084,7 @@ static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,return err; } -static unsigned fuse_dev_poll (struct file *file,poll_table *wait) +unsigned fuse_dev_poll (struct file *file,poll_table *wait) {unsigned mask =POLLOUT |POLLWRNORM ;struct fuse_conn *fc =fuse_get_conn (file);
@@ -1210,7 +1210,7 @@ int fuse_dev_release(struct inode *inode, struct file *file) }EXPORT_SYMBOL_GPL (fuse_dev_release); -static int fuse_dev_fasync (int fd,struct file *file,int on) +int fuse_dev_fasync (int fd,struct file *file,int on) {struct fuse_conn *fc =fuse_get_conn (file);if (!fc)
fs/fuse/fuse_i.h +10 -0
@@ -521,6 +521,16 @@ extern const struct file_operations fuse_dev_operations;extern const struct dentry_operations fuse_dentry_operations; +extern ssize_t fuse_dev_read (struct kiocb *iocb,const struct iovec *iov, +unsigned long nr_segs,loff_t pos); + +extern ssize_t fuse_dev_write (struct kiocb *iocb,const struct iovec *iov, +unsigned long nr_segs,loff_t pos); + +extern unsigned fuse_dev_poll (struct file *file,poll_table *wait); + +extern int fuse_dev_fasync (int fd,struct file *file,int on); +/** * Inode to nodeid comparison. */
Signature · 1 line
1.6.5.3
PATCH 7/9 Constify struct file_operations for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- drivers/staging/b3dfg/b3dfg.c | 2 +- drivers/staging/dream/pmem.c | 4 ++-- drivers/staging/dream/qdsp5/adsp_driver.c | 2 +- drivers/staging/dream/qdsp5/audio_aac.c | 2 +- drivers/staging/dream/qdsp5/audio_amrnb.c | 2 +- drivers/staging/dream/qdsp5/audio_evrc.c | 2 +- drivers/staging/dream/qdsp5/audio_in.c | 4 ++-- drivers/staging/dream/qdsp5/audio_mp3.c | 2 +- drivers/staging/dream/qdsp5/audio_out.c | 4 ++-- drivers/staging/dream/qdsp5/audio_qcelp.c | 2 +- drivers/staging/dream/qdsp5/snd.c | 2 +- drivers/staging/dream/smd/smd_qmi.c | 2 +- drivers/staging/dream/smd/smd_rpcrouter_device.c | 4 ++-- drivers/staging/panel/panel.c | 4 ++-- drivers/staging/poch/poch.c | 2 +- drivers/staging/rtl8192u/ieee80211/proc.c | 2 +- drivers/staging/sep/sep_driver.c | 2 +- drivers/staging/vme/devices/vme_user.c | 2 +- 18 files changed, 23 insertions(+), 23 deletions(-)
drivers/staging/b3dfg/b3dfg.c +1 -1
@@ -836,7 +836,7 @@ static int b3dfg_mmap(struct file *filp, struct vm_area_struct *vma)return r; } -static struct file_operations b3dfg_fops = { +static const struct file_operations b3dfg_fops = { .owner =THIS_MODULE , .open = b3dfg_open, .release = b3dfg_release,
drivers/staging/dream/pmem.c +2 -2
@@ -174,7 +174,7 @@ static int pmem_mmap(struct file *, struct vm_area_struct *);static int pmem_open (struct inode *,struct file *);static long pmem_ioctl (struct file *,unsigned int ,unsigned long ); -struct file_operations pmem_fops = { +const struct file_operations pmem_fops = { .release = pmem_release, .mmap = pmem_mmap, .open = pmem_open,
@@ -1202,7 +1202,7 @@ static ssize_t debug_read(struct file *file, char __user *buf, size_t count,return simple_read_from_buffer (buf, count, ppos, buffer, n); } -static struct file_operations debug_fops = { +static const struct file_operations debug_fops = { .read = debug_read, .open = debug_open, };
drivers/staging/dream/qdsp5/adsp_driver.c +1 -1
@@ -576,7 +576,7 @@ static struct adsp_device *inode_to_device(struct inode *inode)static dev_t adsp_devno;static struct class *adsp_class; -static struct file_operations adsp_fops = { +static const struct file_operations adsp_fops = { .owner =THIS_MODULE , .open = adsp_open, .unlocked_ioctl = adsp_ioctl,
drivers/staging/dream/qdsp5/audio_aac.c +1 -1
@@ -1022,7 +1022,7 @@ done:return rc; } -static struct file_operations audio_aac_fops = { +static const struct file_operations audio_aac_fops = { .owner =THIS_MODULE , .open = audio_open, .release = audio_release,
drivers/staging/dream/qdsp5/audio_amrnb.c +1 -1
@@ -833,7 +833,7 @@ done:return rc; } -static struct file_operations audio_amrnb_fops = { +static const struct file_operations audio_amrnb_fops = { .owner =THIS_MODULE , .open = audamrnb_open, .release = audamrnb_release,
drivers/staging/dream/qdsp5/audio_evrc.c +1 -1
@@ -805,7 +805,7 @@ dma_fail:return rc; } -static struct file_operations audio_evrc_fops = { +static const struct file_operations audio_evrc_fops = { .owner =THIS_MODULE , .open = audevrc_open, .release = audevrc_release,
drivers/staging/dream/qdsp5/audio_in.c +2 -2
@@ -913,7 +913,7 @@ static int audpre_open(struct inode *inode, struct file *file)return 0 ; } -static struct file_operations audio_fops = { +static const struct file_operations audio_fops = { .owner =THIS_MODULE , .open = audio_in_open, .release = audio_in_release,
@@ -922,7 +922,7 @@ static struct file_operations audio_fops = { .unlocked_ioctl = audio_in_ioctl, }; -static struct file_operations audpre_fops = { +static const struct file_operations audpre_fops = { .owner =THIS_MODULE , .open = audpre_open, .unlocked_ioctl = audpre_ioctl,
drivers/staging/dream/qdsp5/audio_mp3.c +1 -1
@@ -941,7 +941,7 @@ done:return rc; } -static struct file_operations audio_mp3_fops = { +static const struct file_operations audio_mp3_fops = { .owner =THIS_MODULE , .open = audio_open, .release = audio_release,
drivers/staging/dream/qdsp5/audio_out.c +2 -2
@@ -806,7 +806,7 @@ static int audpp_open(struct inode *inode, struct file *file)return 0 ; } -static struct file_operations audio_fops = { +static const struct file_operations audio_fops = { .owner =THIS_MODULE , .open = audio_open, .release = audio_release,
@@ -815,7 +815,7 @@ static struct file_operations audio_fops = { .unlocked_ioctl = audio_ioctl, }; -static struct file_operations audpp_fops = { +static const struct file_operations audpp_fops = { .owner =THIS_MODULE , .open = audpp_open, .unlocked_ioctl = audpp_ioctl,
drivers/staging/dream/qdsp5/audio_qcelp.c +1 -1
@@ -816,7 +816,7 @@ err:return rc; } -static struct file_operations audio_qcelp_fops = { +static const struct file_operations audio_qcelp_fops = { .owner =THIS_MODULE , .open = audqcelp_open, .release = audqcelp_release,
drivers/staging/dream/qdsp5/snd.c +1 -1
@@ -242,7 +242,7 @@ err:return rc; } -static struct file_operations snd_fops = { +static const struct file_operations snd_fops = { .owner =THIS_MODULE , .open = snd_open, .release = snd_release,
drivers/staging/dream/smd/smd_qmi.c +1 -1
@@ -788,7 +788,7 @@ static int qmi_release(struct inode *ip, struct file *fp)return 0 ; } -static struct file_operations qmi_fops = { +static const struct file_operations qmi_fops = { .owner =THIS_MODULE , .read = qmi_read, .write = qmi_write,
drivers/staging/dream/smd/smd_rpcrouter_device.c +2 -2
@@ -214,7 +214,7 @@ static long rpcrouter_ioctl(struct file *filp, unsigned int cmd,return rc; } -static struct file_operations rpcrouter_server_fops = { +static const struct file_operations rpcrouter_server_fops = { .owner =THIS_MODULE , .open = rpcrouter_open, .release = rpcrouter_release,
@@ -224,7 +224,7 @@ static struct file_operations rpcrouter_server_fops = { .unlocked_ioctl = rpcrouter_ioctl, }; -static struct file_operations rpcrouter_router_fops = { +static const struct file_operations rpcrouter_router_fops = { .owner =THIS_MODULE , .open = rpcrouter_open, .release = rpcrouter_release,
drivers/staging/panel/panel.c +2 -2
@@ -1305,7 +1305,7 @@ static int lcd_release(struct inode *inode, struct file *file)return 0 ; } -static struct file_operations lcd_fops = { +static const struct file_operations lcd_fops = { .write = lcd_write, .open = lcd_open, .release = lcd_release,
@@ -1565,7 +1565,7 @@ static int keypad_release(struct inode *inode, struct file *file)return 0 ; } -static struct file_operations keypad_fops = { +static const struct file_operations keypad_fops = { .read = keypad_read,/* read */ .open = keypad_open,/* open */ .release = keypad_release,/* close */
drivers/staging/poch/poch.c +1 -1
@@ -1032,7 +1032,7 @@ static int poch_ioctl(struct inode *inode, struct file *filp,return 0 ; } -static struct file_operations poch_fops = { +static const struct file_operations poch_fops = { .owner =THIS_MODULE , .open = poch_open, .release = poch_release,
drivers/staging/rtl8192u/ieee80211/proc.c +1 -1
@@ -99,7 +99,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,
drivers/staging/sep/sep_driver.c +1 -1
@@ -2605,7 +2605,7 @@ static struct pci_driver sep_pci_driver = {static dev_t sep_devno;/* the files operations structure of the driver */ -static struct file_operations sep_file_operations = { +static const struct file_operations sep_file_operations = { .owner =THIS_MODULE , .ioctl = sep_ioctl, .poll = sep_poll,
drivers/staging/vme/devices/vme_user.c +1 -1
@@ -135,7 +135,7 @@ static int vme_user_ioctl(struct inode *, struct file *, unsigned int,static int __init vme_user_probe (struct device *,int ,int ); static int __exit vme_user_remove(struct device *, int, int); -static struct file_operations vme_user_fops = { +static const struct file_operations vme_user_fops = { .open = vme_user_open, .release = vme_user_release, .read = vme_user_read,
Signature · 1 line
1.6.5.3
PATCH 4/9 Constify struct file_operations for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- virt/kvm/kvm_main.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
virt/kvm/kvm_main.c +3 -0
@@ -1164,6 +1164,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)return 0 ; } +/* cannot be const, see kvm_init */ static struct file_operations kvm_vcpu_fops = { .release = kvm_vcpu_release, .unlocked_ioctl = kvm_vcpu_ioctl,
@@ -1620,6 +1621,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)return 0 ; } +/* cannot be const, see kvm_init */ static struct file_operations kvm_vm_fops = { .release = kvm_vm_release, .unlocked_ioctl = kvm_vm_ioctl,
@@ -1710,6 +1712,7 @@ out:return r; } +/* cannot be const, see kvm_init */ static struct file_operations kvm_chardev_ops = { .unlocked_ioctl = kvm_dev_ioctl, .compat_ioctl = kvm_dev_ioctl,
Signature · 1 line
1.6.5.3
PATCH 9/9 Constify struct file_operations for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- drivers/char/pty.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/char/pty.c +1 -0
@@ -676,6 +676,7 @@ static int ptmx_open(struct inode *inode, struct file *filp)return ret; } +/* cannot be const, see unix98_pty_init */ static struct file_operations ptmx_fops;static void __init unix98_pty_init (void )
Signature · 1 line
1.6.5.3
cover Constify struct file_operations for 2.6.32-git-053fe57ac v2
From: Emese Revfy <[email protected]>
Hello everyone!
The following patch series attempts to constify several structures that hold function pointers. This is only the initial batch, there are about over 150 candidate structures, some of which can be constified as well, I plan to submit them in the future.
The list of constified structures in this series (* marks this thread):acpi_dock_opsaddress_space_operationsbacklight_opsblock_device_operationsdma_map_opsextent_io_opsfile_lock_operations
* file_operationshv_opsintel_dvo_dev_opsitem_operationsiwl_opskgdb_archkgdb_iokset_uevent_opslock_manager_operationsmicrocode_opsmtrr_opsneigh_opsnlmsvc_bindingpci_raw_opsplatform_hibernation_opsplatform_suspend_opssnd_ac97_build_opssysfs_opsusb_mon_operationswd_ops
There are certain exceptions where a given instance of the structure cannot be const, they are marked with a comment in the patch.
The patches compile fine with an allyesconfig kernel on i386 and x86_64.
Please let me know if any of these structures should not be constified and any other issues you see with them.
Changelog:
----------
v1 -> v2
- updated to linus-git-053fe57
- extended comments with a reference to code that prevents constification
- split up patches by subsystem as suggested by Greg KH, Jiri Slaby
- added all Acked-by's received so far
- removed patch for super_operations for now
- removed patch for ptmx_fops
Thanks,
Emese
drivers/acpi/battery.c | 2 +- drivers/block/drbd/drbd_int.h | 2 +- drivers/block/drbd/drbd_proc.c | 2 +- drivers/char/pty.c | 1 + drivers/char/tty_io.c | 1 + drivers/media/dvb/dvb-core/dvbdev.c | 1 + drivers/net/wireless/b43/debugfs.c | 2 +- drivers/net/wireless/b43legacy/debugfs.c | 2 +- drivers/net/wireless/libertas/debugfs.c | 2 +- drivers/staging/b3dfg/b3dfg.c | 2 +- drivers/staging/dream/pmem.c | 4 ++-- drivers/staging/dream/qdsp5/adsp_driver.c | 2 +- drivers/staging/dream/qdsp5/audio_aac.c | 2 +- drivers/staging/dream/qdsp5/audio_amrnb.c | 2 +- drivers/staging/dream/qdsp5/audio_evrc.c | 2 +- drivers/staging/dream/qdsp5/audio_in.c | 4 ++-- drivers/staging/dream/qdsp5/audio_mp3.c | 2 +- drivers/staging/dream/qdsp5/audio_out.c | 4 ++-- drivers/staging/dream/qdsp5/audio_qcelp.c | 2 +- drivers/staging/dream/qdsp5/snd.c | 2 +- drivers/staging/dream/smd/smd_qmi.c | 2 +- drivers/staging/dream/smd/smd_rpcrouter_device.c | 4 ++-- drivers/staging/panel/panel.c | 4 ++-- drivers/staging/poch/poch.c | 2 +- drivers/staging/rtl8192u/ieee80211/proc.c | 2 +- drivers/staging/sep/sep_driver.c | 2 +- drivers/staging/vme/devices/vme_user.c | 2 +- fs/fuse/cuse.c | 19 ++++++++++++------- fs/fuse/dev.c | 8 ++++---- fs/fuse/fuse_i.h | 10 ++++++++++ virt/kvm/kvm_main.c | 3 +++ 31 files changed, 61 insertions(+), 40 deletions(-)
PATCH 8/9 Constify struct file_operations for 2.6.32-git-053fe57ac v2
From: Emese Revfy <[email protected]>
--- drivers/char/tty_io.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/char/tty_io.c +1 -0
@@ -3067,6 +3067,7 @@ struct tty_struct *get_current_tty(void) }EXPORT_SYMBOL_GPL (get_current_tty); +/* cannot be const, see this function */ void tty_default_fops (struct file_operations *fops) { *fops = tty_fops;
Signature · 1 line
1.6.5.3
PATCH 2/9 Constify struct file_operations for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- drivers/block/drbd/drbd_int.h | 2 +- drivers/block/drbd/drbd_proc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/block/drbd/drbd_int.h +1 -1
@@ -1490,7 +1490,7 @@ void drbd_bump_write_ordering(struct drbd_conf *mdev, enum write_ordering_e wo);/* drbd_proc.c */ extern struct proc_dir_entry *drbd_proc; -extern struct file_operations drbd_proc_fops; +extern const struct file_operations drbd_proc_fops;extern const char *drbd_conn_str (enum drbd_conns s);extern const char *drbd_role_str (enum drbd_role s);
drivers/block/drbd/drbd_proc.c +1 -1
@@ -38,7 +38,7 @@ static int drbd_proc_open(struct inode *inode, struct file *file);struct proc_dir_entry *drbd_proc; -struct file_operations drbd_proc_fops = { +const struct file_operations drbd_proc_fops = { .owner =THIS_MODULE , .open = drbd_proc_open, .read = seq_read,
Signature · 1 line
1.6.5.3
PATCH 1/1 Constify struct file_lock_operations for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- include/linux/fs.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/fs.h +2 -2
@@ -1028,8 +1028,8 @@ static inline int file_check_writeable(struct file *filp)typedef struct files_struct *fl_owner_t ;struct file_lock_operations { -void (*fl_copy_lock)(struct file_lock *,struct file_lock *); -void (*fl_release_private)(struct file_lock *); +void (*const fl_copy_lock)(struct file_lock *,struct file_lock *); +void (*const fl_release_private)(struct file_lock *); };struct lock_manager_operations {
Signature · 1 line
1.6.5.3