2009-12-14 00:16:26

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 0/9] 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_ops
address_space_operations
backlight_ops
block_device_operations
dma_map_ops
extent_io_ops
file_lock_operations
* file_operations
hv_ops
intel_dvo_dev_ops
item_operations
iwl_ops
kgdb_arch
kgdb_io
kset_uevent_ops
lock_manager_operations
microcode_ops
mtrr_ops
neigh_ops
nlmsvc_binding
pci_raw_ops
platform_hibernation_ops
platform_suspend_ops
snd_ac97_build_ops
sysfs_ops
usb_mon_operations
wd_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(-)


2009-12-14 00:17:54

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 2/9] Constify struct file_operations for 2.6.32-git-053fe57ac v2

From: Emese Revfy <[email protected]>


Signed-off-by: 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(-)

diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 2312d78..c975587 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -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);

diff --git a/drivers/block/drbd/drbd_proc.c b/drivers/block/drbd/drbd_proc.c
index bdd0b49..df8ad96 100644
--- a/drivers/block/drbd/drbd_proc.c
+++ b/drivers/block/drbd/drbd_proc.c
@@ -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,
--
1.6.5.3

2009-12-13 23:58:06

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 3/9] Constify struct file_operations for 2.6.32-git-053fe57ac v2

From: Emese Revfy <[email protected]>


Signed-off-by: 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(-)

diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
index de792dc..2115e7f 100644
--- a/fs/fuse/cuse.c
+++ b/fs/fuse/cuse.c
@@ -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);
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 51d9e33..03c8f95 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -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)
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 01cc462..b11fe78 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -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.
*/
--
1.6.5.3

2009-12-14 00:14:44

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 4/9] Constify struct file_operations for 2.6.32-git-053fe57ac v2

From: Emese Revfy <[email protected]>


Signed-off-by: Emese Revfy <[email protected]>
---
virt/kvm/kvm_main.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index f92ba13..f7a2269 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -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,
--
1.6.5.3

2009-12-13 23:57:52

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 5/9] Constify struct file_operations for 2.6.32-git-053fe57ac v2

From: Emese Revfy <[email protected]>


Signed-off-by: Emese Revfy <[email protected]>
---
drivers/media/dvb/dvb-core/dvbdev.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 94159b9..9684961 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -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;
--
1.6.5.3

2009-12-14 00:17:51

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 6/9] Constify struct file_operations for 2.6.32-git-053fe57ac v2

From: Emese Revfy <[email protected]>


Signed-off-by: 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(-)

diff --git a/drivers/net/wireless/b43/debugfs.c b/drivers/net/wireless/b43/debugfs.c
index 80b19a4..dab3a45 100644
--- a/drivers/net/wireless/b43/debugfs.c
+++ b/drivers/net/wireless/b43/debugfs.c
@@ -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;
};
diff --git a/drivers/net/wireless/b43legacy/debugfs.c b/drivers/net/wireless/b43legacy/debugfs.c
index 1f85ac5..c99b4b4 100644
--- a/drivers/net/wireless/b43legacy/debugfs.c
+++ b/drivers/net/wireless/b43legacy/debugfs.c
@@ -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? */
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 587b0cb..27547b0 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -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[] = {
--
1.6.5.3

2009-12-14 00:21:12

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 1/1] Constify struct file_lock_operations for 2.6.32-git-053fe57ac v2

From: Emese Revfy <[email protected]>


Signed-off-by: Emese Revfy <[email protected]>
---
include/linux/fs.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index a057f48..c88cb4b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -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 {
--
1.6.5.3

2009-12-14 00:13:37

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 7/9] Constify struct file_operations for 2.6.32-git-053fe57ac v2

From: Emese Revfy <[email protected]>


Signed-off-by: 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(-)

diff --git a/drivers/staging/b3dfg/b3dfg.c b/drivers/staging/b3dfg/b3dfg.c
index 4a43c51..0047afd 100644
--- a/drivers/staging/b3dfg/b3dfg.c
+++ b/drivers/staging/b3dfg/b3dfg.c
@@ -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,
diff --git a/drivers/staging/dream/pmem.c b/drivers/staging/dream/pmem.c
index def6468..1660a58 100644
--- a/drivers/staging/dream/pmem.c
+++ b/drivers/staging/dream/pmem.c
@@ -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,
};
diff --git a/drivers/staging/dream/qdsp5/adsp_driver.c b/drivers/staging/dream/qdsp5/adsp_driver.c
index e55a0db..577b776 100644
--- a/drivers/staging/dream/qdsp5/adsp_driver.c
+++ b/drivers/staging/dream/qdsp5/adsp_driver.c
@@ -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,
diff --git a/drivers/staging/dream/qdsp5/audio_aac.c b/drivers/staging/dream/qdsp5/audio_aac.c
index ad2390f..4116ee8 100644
--- a/drivers/staging/dream/qdsp5/audio_aac.c
+++ b/drivers/staging/dream/qdsp5/audio_aac.c
@@ -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,
diff --git a/drivers/staging/dream/qdsp5/audio_amrnb.c b/drivers/staging/dream/qdsp5/audio_amrnb.c
index cd818a5..870b37b 100644
--- a/drivers/staging/dream/qdsp5/audio_amrnb.c
+++ b/drivers/staging/dream/qdsp5/audio_amrnb.c
@@ -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,
diff --git a/drivers/staging/dream/qdsp5/audio_evrc.c b/drivers/staging/dream/qdsp5/audio_evrc.c
index 4b43e18..cedafda 100644
--- a/drivers/staging/dream/qdsp5/audio_evrc.c
+++ b/drivers/staging/dream/qdsp5/audio_evrc.c
@@ -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,
diff --git a/drivers/staging/dream/qdsp5/audio_in.c b/drivers/staging/dream/qdsp5/audio_in.c
index 3d950a2..9431118 100644
--- a/drivers/staging/dream/qdsp5/audio_in.c
+++ b/drivers/staging/dream/qdsp5/audio_in.c
@@ -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,
diff --git a/drivers/staging/dream/qdsp5/audio_mp3.c b/drivers/staging/dream/qdsp5/audio_mp3.c
index b95574f..286c2f4 100644
--- a/drivers/staging/dream/qdsp5/audio_mp3.c
+++ b/drivers/staging/dream/qdsp5/audio_mp3.c
@@ -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,
diff --git a/drivers/staging/dream/qdsp5/audio_out.c b/drivers/staging/dream/qdsp5/audio_out.c
index df87ca3..44b7799 100644
--- a/drivers/staging/dream/qdsp5/audio_out.c
+++ b/drivers/staging/dream/qdsp5/audio_out.c
@@ -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,
diff --git a/drivers/staging/dream/qdsp5/audio_qcelp.c b/drivers/staging/dream/qdsp5/audio_qcelp.c
index f0f50e3..f6b9dbc 100644
--- a/drivers/staging/dream/qdsp5/audio_qcelp.c
+++ b/drivers/staging/dream/qdsp5/audio_qcelp.c
@@ -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,
diff --git a/drivers/staging/dream/qdsp5/snd.c b/drivers/staging/dream/qdsp5/snd.c
index 037d7ff..5469ec3 100644
--- a/drivers/staging/dream/qdsp5/snd.c
+++ b/drivers/staging/dream/qdsp5/snd.c
@@ -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,
diff --git a/drivers/staging/dream/smd/smd_qmi.c b/drivers/staging/dream/smd/smd_qmi.c
index 687db14..688623e 100644
--- a/drivers/staging/dream/smd/smd_qmi.c
+++ b/drivers/staging/dream/smd/smd_qmi.c
@@ -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,
diff --git a/drivers/staging/dream/smd/smd_rpcrouter_device.c b/drivers/staging/dream/smd/smd_rpcrouter_device.c
index cd3910b..ff053d3 100644
--- a/drivers/staging/dream/smd/smd_rpcrouter_device.c
+++ b/drivers/staging/dream/smd/smd_rpcrouter_device.c
@@ -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,
diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 4ce399b..225f9bc 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -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 */
diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c
index 9095158..0fc63e7 100644
--- a/drivers/staging/poch/poch.c
+++ b/drivers/staging/poch/poch.c
@@ -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,
diff --git a/drivers/staging/rtl8192u/ieee80211/proc.c b/drivers/staging/rtl8192u/ieee80211/proc.c
index 6eda928..7e60f0e 100644
--- a/drivers/staging/rtl8192u/ieee80211/proc.c
+++ b/drivers/staging/rtl8192u/ieee80211/proc.c
@@ -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,
diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index e7bc9ec..63d35a3 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -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,
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index e228942..ebf63a5 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -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,
--
1.6.5.3

2009-12-14 00:17:33

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 8/9] Constify struct file_operations for 2.6.32-git-053fe57ac v2

From: Emese Revfy <[email protected]>


Signed-off-by: Emese Revfy <[email protected]>
---
drivers/char/tty_io.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 684f0e0..e685ecc 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -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;
--
1.6.5.3

2009-12-14 00:15:46

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 9/9] Constify struct file_operations for 2.6.32-git-053fe57ac v2

From: Emese Revfy <[email protected]>


Signed-off-by: Emese Revfy <[email protected]>
---
drivers/char/pty.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 385c44b..9fa352e 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -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)
--
1.6.5.3