Commit 15ad7cdc authored by Helge Deller's avatar Helge Deller Committed by Linus Torvalds

[PATCH] struct seq_operations and struct file_operations constification

 - move some file_operations structs into the .rodata section

 - move static strings from policy_types[] array into the .rodata section

 - fix generic seq_operations usages, so that those structs may be defined
   as "const" as well

[akpm@osdl.org: couple of fixes]
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4a08a9f6
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* ERR_PTR(error). In the end of sequence they return %NULL. ->show() * ERR_PTR(error). In the end of sequence they return %NULL. ->show()
* returns 0 in case of success and negative number in case of error. * returns 0 in case of success and negative number in case of error.
*/ */
int seq_open(struct file *file, struct seq_operations *op) int seq_open(struct file *file, const struct seq_operations *op)
{ {
struct seq_file *p = file->private_data; struct seq_file *p = file->private_data;
...@@ -408,7 +408,7 @@ EXPORT_SYMBOL(single_open); ...@@ -408,7 +408,7 @@ EXPORT_SYMBOL(single_open);
int single_release(struct inode *inode, struct file *file) int single_release(struct inode *inode, struct file *file)
{ {
struct seq_operations *op = ((struct seq_file *)file->private_data)->op; const struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
int res = seq_release(inode, file); int res = seq_release(inode, file);
kfree(op); kfree(op);
return res; return res;
......
...@@ -46,7 +46,7 @@ extern int cpuset_excl_nodes_overlap(const struct task_struct *p); ...@@ -46,7 +46,7 @@ extern int cpuset_excl_nodes_overlap(const struct task_struct *p);
extern int cpuset_memory_pressure_enabled; extern int cpuset_memory_pressure_enabled;
extern void __cpuset_memory_pressure_bump(void); extern void __cpuset_memory_pressure_bump(void);
extern struct file_operations proc_cpuset_operations; extern const struct file_operations proc_cpuset_operations;
extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer); extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
extern void cpuset_lock(void); extern void cpuset_lock(void);
......
...@@ -278,7 +278,7 @@ struct zone { ...@@ -278,7 +278,7 @@ struct zone {
/* /*
* rarely used fields: * rarely used fields:
*/ */
char *name; const char *name;
} ____cacheline_internodealigned_in_smp; } ____cacheline_internodealigned_in_smp;
/* /*
......
...@@ -274,7 +274,7 @@ static inline void subbuf_start_reserve(struct rchan_buf *buf, ...@@ -274,7 +274,7 @@ static inline void subbuf_start_reserve(struct rchan_buf *buf,
/* /*
* exported relay file operations, kernel/relay.c * exported relay file operations, kernel/relay.c
*/ */
extern struct file_operations relay_file_operations; extern const struct file_operations relay_file_operations;
#endif /* _LINUX_RELAY_H */ #endif /* _LINUX_RELAY_H */
...@@ -573,7 +573,7 @@ struct sched_info { ...@@ -573,7 +573,7 @@ struct sched_info {
#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */ #endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
#ifdef CONFIG_SCHEDSTATS #ifdef CONFIG_SCHEDSTATS
extern struct file_operations proc_schedstat_operations; extern const struct file_operations proc_schedstat_operations;
#endif /* CONFIG_SCHEDSTATS */ #endif /* CONFIG_SCHEDSTATS */
#ifdef CONFIG_TASK_DELAY_ACCT #ifdef CONFIG_TASK_DELAY_ACCT
......
...@@ -20,7 +20,7 @@ struct seq_file { ...@@ -20,7 +20,7 @@ struct seq_file {
loff_t index; loff_t index;
loff_t version; loff_t version;
struct mutex lock; struct mutex lock;
struct seq_operations *op; const struct seq_operations *op;
void *private; void *private;
}; };
...@@ -31,7 +31,7 @@ struct seq_operations { ...@@ -31,7 +31,7 @@ struct seq_operations {
int (*show) (struct seq_file *m, void *v); int (*show) (struct seq_file *m, void *v);
}; };
int seq_open(struct file *, struct seq_operations *); int seq_open(struct file *, const struct seq_operations *);
ssize_t seq_read(struct file *, char __user *, size_t, loff_t *); ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
loff_t seq_lseek(struct file *, loff_t, int); loff_t seq_lseek(struct file *, loff_t, int);
int seq_release(struct inode *, struct file *); int seq_release(struct inode *, struct file *);
......
...@@ -75,7 +75,7 @@ ikconfig_read_current(struct file *file, char __user *buf, ...@@ -75,7 +75,7 @@ ikconfig_read_current(struct file *file, char __user *buf,
return count; return count;
} }
static struct file_operations ikconfig_file_ops = { static const struct file_operations ikconfig_file_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.read = ikconfig_read_current, .read = ikconfig_read_current,
}; };
......
...@@ -1531,7 +1531,7 @@ static int cpuset_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1531,7 +1531,7 @@ static int cpuset_rename(struct inode *old_dir, struct dentry *old_dentry,
return simple_rename(old_dir, old_dentry, new_dir, new_dentry); return simple_rename(old_dir, old_dentry, new_dir, new_dentry);
} }
static struct file_operations cpuset_file_operations = { static const struct file_operations cpuset_file_operations = {
.read = cpuset_file_read, .read = cpuset_file_read,
.write = cpuset_file_write, .write = cpuset_file_write,
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
...@@ -2605,7 +2605,7 @@ static int cpuset_open(struct inode *inode, struct file *file) ...@@ -2605,7 +2605,7 @@ static int cpuset_open(struct inode *inode, struct file *file)
return single_open(file, proc_cpuset_show, pid); return single_open(file, proc_cpuset_show, pid);
} }
struct file_operations proc_cpuset_operations = { const struct file_operations proc_cpuset_operations = {
.open = cpuset_open, .open = cpuset_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
......
...@@ -140,7 +140,7 @@ static int proc_dma_open(struct inode *inode, struct file *file) ...@@ -140,7 +140,7 @@ static int proc_dma_open(struct inode *inode, struct file *file)
return single_open(file, proc_dma_show, NULL); return single_open(file, proc_dma_show, NULL);
} }
static struct file_operations proc_dma_operations = { static const struct file_operations proc_dma_operations = {
.open = proc_dma_open, .open = proc_dma_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
......
...@@ -1492,7 +1492,7 @@ static unsigned int futex_poll(struct file *filp, ...@@ -1492,7 +1492,7 @@ static unsigned int futex_poll(struct file *filp,
return ret; return ret;
} }
static struct file_operations futex_fops = { static const struct file_operations futex_fops = {
.release = futex_close, .release = futex_close,
.poll = futex_poll, .poll = futex_poll,
}; };
......
...@@ -398,7 +398,7 @@ static int s_show(struct seq_file *m, void *p) ...@@ -398,7 +398,7 @@ static int s_show(struct seq_file *m, void *p)
return 0; return 0;
} }
static struct seq_operations kallsyms_op = { static const struct seq_operations kallsyms_op = {
.start = s_start, .start = s_start,
.next = s_next, .next = s_next,
.stop = s_stop, .stop = s_stop,
...@@ -433,7 +433,7 @@ static int kallsyms_release(struct inode *inode, struct file *file) ...@@ -433,7 +433,7 @@ static int kallsyms_release(struct inode *inode, struct file *file)
return seq_release(inode, file); return seq_release(inode, file);
} }
static struct file_operations kallsyms_operations = { static const struct file_operations kallsyms_operations = {
.open = kallsyms_open, .open = kallsyms_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
......
...@@ -113,7 +113,7 @@ static int l_show(struct seq_file *m, void *v) ...@@ -113,7 +113,7 @@ static int l_show(struct seq_file *m, void *v)
return 0; return 0;
} }
static struct seq_operations lockdep_ops = { static const struct seq_operations lockdep_ops = {
.start = l_start, .start = l_start,
.next = l_next, .next = l_next,
.stop = l_stop, .stop = l_stop,
...@@ -135,7 +135,7 @@ static int lockdep_open(struct inode *inode, struct file *file) ...@@ -135,7 +135,7 @@ static int lockdep_open(struct inode *inode, struct file *file)
return res; return res;
} }
static struct file_operations proc_lockdep_operations = { static const struct file_operations proc_lockdep_operations = {
.open = lockdep_open, .open = lockdep_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -319,7 +319,7 @@ static int lockdep_stats_open(struct inode *inode, struct file *file) ...@@ -319,7 +319,7 @@ static int lockdep_stats_open(struct inode *inode, struct file *file)
return single_open(file, lockdep_stats_show, NULL); return single_open(file, lockdep_stats_show, NULL);
} }
static struct file_operations proc_lockdep_stats_operations = { static const struct file_operations proc_lockdep_stats_operations = {
.open = lockdep_stats_open, .open = lockdep_stats_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
......
...@@ -2209,7 +2209,7 @@ static int m_show(struct seq_file *m, void *p) ...@@ -2209,7 +2209,7 @@ static int m_show(struct seq_file *m, void *p)
Where refcount is a number or -, and deps is a comma-separated list Where refcount is a number or -, and deps is a comma-separated list
of depends or -. of depends or -.
*/ */
struct seq_operations modules_op = { const struct seq_operations modules_op = {
.start = m_start, .start = m_start,
.next = m_next, .next = m_next,
.stop = m_stop, .stop = m_stop,
......
...@@ -383,7 +383,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, ...@@ -383,7 +383,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
return error; return error;
} }
static struct file_operations snapshot_fops = { static const struct file_operations snapshot_fops = {
.open = snapshot_open, .open = snapshot_open,
.release = snapshot_release, .release = snapshot_release,
.read = snapshot_read, .read = snapshot_read,
......
...@@ -501,7 +501,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf, ...@@ -501,7 +501,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
return count; return count;
} }
static struct file_operations proc_profile_operations = { static const struct file_operations proc_profile_operations = {
.read = read_profile, .read = read_profile,
.write = write_profile, .write = write_profile,
}; };
......
...@@ -1013,7 +1013,7 @@ static ssize_t relay_file_sendfile(struct file *filp, ...@@ -1013,7 +1013,7 @@ static ssize_t relay_file_sendfile(struct file *filp,
actor, &desc); actor, &desc);
} }
struct file_operations relay_file_operations = { const struct file_operations relay_file_operations = {
.open = relay_file_open, .open = relay_file_open,
.poll = relay_file_poll, .poll = relay_file_poll,
.mmap = relay_file_mmap, .mmap = relay_file_mmap,
......
...@@ -88,7 +88,7 @@ static int r_show(struct seq_file *m, void *v) ...@@ -88,7 +88,7 @@ static int r_show(struct seq_file *m, void *v)
return 0; return 0;
} }
static struct seq_operations resource_op = { static const struct seq_operations resource_op = {
.start = r_start, .start = r_start,
.next = r_next, .next = r_next,
.stop = r_stop, .stop = r_stop,
...@@ -115,14 +115,14 @@ static int iomem_open(struct inode *inode, struct file *file) ...@@ -115,14 +115,14 @@ static int iomem_open(struct inode *inode, struct file *file)
return res; return res;
} }
static struct file_operations proc_ioports_operations = { static const struct file_operations proc_ioports_operations = {
.open = ioports_open, .open = ioports_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = seq_release, .release = seq_release,
}; };
static struct file_operations proc_iomem_operations = { static const struct file_operations proc_iomem_operations = {
.open = iomem_open, .open = iomem_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
......
...@@ -505,7 +505,7 @@ static int schedstat_open(struct inode *inode, struct file *file) ...@@ -505,7 +505,7 @@ static int schedstat_open(struct inode *inode, struct file *file)
return res; return res;
} }
struct file_operations proc_schedstat_operations = { const struct file_operations proc_schedstat_operations = {
.open = schedstat_open, .open = schedstat_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
......
...@@ -170,7 +170,7 @@ static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *); ...@@ -170,7 +170,7 @@ static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *); static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
static int proc_opensys(struct inode *, struct file *); static int proc_opensys(struct inode *, struct file *);
struct file_operations proc_sys_file_operations = { const struct file_operations proc_sys_file_operations = {
.open = proc_opensys, .open = proc_opensys,
.read = proc_readsys, .read = proc_readsys,
.write = proc_writesys, .write = proc_writesys,
......
...@@ -1707,8 +1707,8 @@ void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new) ...@@ -1707,8 +1707,8 @@ void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new)
* Display pages allocated per node and memory policy via /proc. * Display pages allocated per node and memory policy via /proc.
*/ */
static const char *policy_types[] = { "default", "prefer", "bind", static const char * const policy_types[] =
"interleave" }; { "default", "prefer", "bind", "interleave" };
/* /*
* Convert a mempolicy into a string. * Convert a mempolicy into a string.
......
...@@ -83,7 +83,7 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = { ...@@ -83,7 +83,7 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = {
EXPORT_SYMBOL(totalram_pages); EXPORT_SYMBOL(totalram_pages);
static char *zone_names[MAX_NR_ZONES] = { static char * const zone_names[MAX_NR_ZONES] = {
"DMA", "DMA",
#ifdef CONFIG_ZONE_DMA32 #ifdef CONFIG_ZONE_DMA32
"DMA32", "DMA32",
......
...@@ -177,7 +177,7 @@ static inline void shmem_unacct_blocks(unsigned long flags, long pages) ...@@ -177,7 +177,7 @@ static inline void shmem_unacct_blocks(unsigned long flags, long pages)
static struct super_operations shmem_ops; static struct super_operations shmem_ops;
static const struct address_space_operations shmem_aops; static const struct address_space_operations shmem_aops;
static struct file_operations shmem_file_operations; static const struct file_operations shmem_file_operations;
static struct inode_operations shmem_inode_operations; static struct inode_operations shmem_inode_operations;
static struct inode_operations shmem_dir_inode_operations; static struct inode_operations shmem_dir_inode_operations;
static struct inode_operations shmem_special_inode_operations; static struct inode_operations shmem_special_inode_operations;
...@@ -2319,7 +2319,7 @@ static const struct address_space_operations shmem_aops = { ...@@ -2319,7 +2319,7 @@ static const struct address_space_operations shmem_aops = {
.migratepage = migrate_page, .migratepage = migrate_page,
}; };
static struct file_operations shmem_file_operations = { static const struct file_operations shmem_file_operations = {
.mmap = shmem_mmap, .mmap = shmem_mmap,
#ifdef CONFIG_TMPFS #ifdef CONFIG_TMPFS
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
......
...@@ -4142,7 +4142,7 @@ static int s_show(struct seq_file *m, void *p) ...@@ -4142,7 +4142,7 @@ static int s_show(struct seq_file *m, void *p)
* + further values on SMP and with statistics enabled * + further values on SMP and with statistics enabled
*/ */
struct seq_operations slabinfo_op = { const struct seq_operations slabinfo_op = {
.start = s_start, .start = s_start,
.next = s_next, .next = s_next,
.stop = s_stop, .stop = s_stop,
...@@ -4340,7 +4340,7 @@ static int leaks_show(struct seq_file *m, void *p) ...@@ -4340,7 +4340,7 @@ static int leaks_show(struct seq_file *m, void *p)
return 0; return 0;
} }
struct seq_operations slabstats_op = { const struct seq_operations slabstats_op = {
.start = leaks_start, .start = leaks_start,
.next = s_next, .next = s_next,
.stop = s_stop, .stop = s_stop,
......
...@@ -1368,7 +1368,7 @@ static int swap_show(struct seq_file *swap, void *v) ...@@ -1368,7 +1368,7 @@ static int swap_show(struct seq_file *swap, void *v)
return 0; return 0;
} }
static struct seq_operations swaps_op = { static const struct seq_operations swaps_op = {
.start = swap_start, .start = swap_start,
.next = swap_next, .next = swap_next,
.stop = swap_stop, .stop = swap_stop,
...@@ -1380,7 +1380,7 @@ static int swaps_open(struct inode *inode, struct file *file) ...@@ -1380,7 +1380,7 @@ static int swaps_open(struct inode *inode, struct file *file)
return seq_open(file, &swaps_op); return seq_open(file, &swaps_op);
} }
static struct file_operations proc_swaps_operations = { static const struct file_operations proc_swaps_operations = {
.open = swaps_open, .open = swaps_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
......
...@@ -430,7 +430,7 @@ static int frag_show(struct seq_file *m, void *arg) ...@@ -430,7 +430,7 @@ static int frag_show(struct seq_file *m, void *arg)
return 0; return 0;
} }
struct seq_operations fragmentation_op = { const struct seq_operations fragmentation_op = {
.start = frag_start, .start = frag_start,
.next = frag_next, .next = frag_next,
.stop = frag_stop, .stop = frag_stop,
...@@ -452,7 +452,7 @@ struct seq_operations fragmentation_op = { ...@@ -452,7 +452,7 @@ struct seq_operations fragmentation_op = {
#define TEXTS_FOR_ZONES(xx) xx "_dma", TEXT_FOR_DMA32(xx) xx "_normal", \ #define TEXTS_FOR_ZONES(xx) xx "_dma", TEXT_FOR_DMA32(xx) xx "_normal", \
TEXT_FOR_HIGHMEM(xx) TEXT_FOR_HIGHMEM(xx)
static char *vmstat_text[] = { static const char * const vmstat_text[] = {
/* Zoned VM counters */ /* Zoned VM counters */
"nr_anon_pages", "nr_anon_pages",
"nr_mapped", "nr_mapped",
...@@ -597,7 +597,7 @@ static int zoneinfo_show(struct seq_file *m, void *arg) ...@@ -597,7 +597,7 @@ static int zoneinfo_show(struct seq_file *m, void *arg)
return 0; return 0;
} }
struct seq_operations zoneinfo_op = { const struct seq_operations zoneinfo_op = {
.start = frag_start, /* iterate over all zones. The same as in .start = frag_start, /* iterate over all zones. The same as in
* fragmentation. */ * fragmentation. */
.next = frag_next, .next = frag_next,
...@@ -660,7 +660,7 @@ static void vmstat_stop(struct seq_file *m, void *arg) ...@@ -660,7 +660,7 @@ static void vmstat_stop(struct seq_file *m, void *arg)
m->private = NULL; m->private = NULL;
} }
struct seq_operations vmstat_op = { const struct seq_operations vmstat_op = {
.start = vmstat_start, .start = vmstat_start,
.next = vmstat_next, .next = vmstat_next,
.stop = vmstat_stop, .stop = vmstat_stop,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment