aboutsummaryrefslogtreecommitdiffstats
path: root/arch/alpha
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-03-31 21:45:09 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-04-09 14:13:33 -0400
commit1c1ec6c6255cce0fa48391e36b419cf951800b50 (patch)
tree0c79f477b49e06dbaac9c98d7d0626d8fbf3a717 /arch/alpha
parentc35f2e49f88e72ffcb0cc6af2f93fe153fa88dd8 (diff)
srm_env: don't bother with pointer to srm_env_t
Since the only thing in it the methods actually care about is variable id, just store that directly. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/alpha')
-rw-r--r--arch/alpha/kernel/srm_env.c33
1 files changed, 9 insertions, 24 deletions
diff --git a/arch/alpha/kernel/srm_env.c b/arch/alpha/kernel/srm_env.c
index 97b4f3fee497..ffe996a54fad 100644
--- a/arch/alpha/kernel/srm_env.c
+++ b/arch/alpha/kernel/srm_env.c
@@ -56,7 +56,6 @@ typedef struct _srm_env {
56static struct proc_dir_entry *base_dir; 56static struct proc_dir_entry *base_dir;
57static struct proc_dir_entry *named_dir; 57static struct proc_dir_entry *named_dir;
58static struct proc_dir_entry *numbered_dir; 58static struct proc_dir_entry *numbered_dir;
59static char number[256][4];
60 59
61static srm_env_t srm_named_entries[] = { 60static srm_env_t srm_named_entries[] = {
62 { "auto_action", ENV_AUTO_ACTION }, 61 { "auto_action", ENV_AUTO_ACTION },
@@ -76,21 +75,18 @@ static srm_env_t srm_named_entries[] = {
76 { "tty_dev", ENV_TTY_DEV }, 75 { "tty_dev", ENV_TTY_DEV },
77 { NULL, 0 }, 76 { NULL, 0 },
78}; 77};
79static srm_env_t srm_numbered_entries[256];
80
81 78
82static int srm_env_proc_show(struct seq_file *m, void *v) 79static int srm_env_proc_show(struct seq_file *m, void *v)
83{ 80{
84 unsigned long ret; 81 unsigned long ret;
85 srm_env_t *entry; 82 unsigned long id = (unsigned long)m->private;
86 char *page; 83 char *page;
87 84
88 entry = m->private;
89 page = (char *)__get_free_page(GFP_USER); 85 page = (char *)__get_free_page(GFP_USER);
90 if (!page) 86 if (!page)
91 return -ENOMEM; 87 return -ENOMEM;
92 88
93 ret = callback_getenv(entry->id, page, PAGE_SIZE); 89 ret = callback_getenv(id, page, PAGE_SIZE);
94 90
95 if ((ret >> 61) == 0) { 91 if ((ret >> 61) == 0) {
96 seq_write(m, page, ret); 92 seq_write(m, page, ret);
@@ -110,7 +106,7 @@ static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer,
110 size_t count, loff_t *pos) 106 size_t count, loff_t *pos)
111{ 107{
112 int res; 108 int res;
113 srm_env_t *entry = PDE_DATA(file_inode(file)); 109 unsigned long id = (unsigned long)PDE_DATA(file_inode(file));
114 char *buf = (char *) __get_free_page(GFP_USER); 110 char *buf = (char *) __get_free_page(GFP_USER);
115 unsigned long ret1, ret2; 111 unsigned long ret1, ret2;
116 112
@@ -126,7 +122,7 @@ static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer,
126 goto out; 122 goto out;
127 buf[count] = '\0'; 123 buf[count] = '\0';
128 124
129 ret1 = callback_setenv(entry->id, buf, count); 125 ret1 = callback_setenv(id, buf, count);
130 if ((ret1 >> 61) == 0) { 126 if ((ret1 >> 61) == 0) {
131 do 127 do
132 ret2 = callback_save_env(); 128 ret2 = callback_save_env();
@@ -166,12 +162,6 @@ srm_env_init(void)
166 } 162 }
167 163
168 /* 164 /*
169 * Init numbers
170 */
171 for (var_num = 0; var_num <= 255; var_num++)
172 sprintf(number[var_num], "%ld", var_num);
173
174 /*
175 * Create base directory 165 * Create base directory
176 */ 166 */
177 base_dir = proc_mkdir(BASE_DIR, NULL); 167 base_dir = proc_mkdir(BASE_DIR, NULL);
@@ -208,7 +198,7 @@ srm_env_init(void)
208 entry = srm_named_entries; 198 entry = srm_named_entries;
209 while (entry->name && entry->id) { 199 while (entry->name && entry->id) {
210 if (!proc_create_data(entry->name, 0644, named_dir, 200 if (!proc_create_data(entry->name, 0644, named_dir,
211 &srm_env_proc_fops, entry)) 201 &srm_env_proc_fops, (void *)entry->id))
212 goto cleanup; 202 goto cleanup;
213 entry++; 203 entry++;
214 } 204 }
@@ -217,14 +207,11 @@ srm_env_init(void)
217 * Create all numbered nodes 207 * Create all numbered nodes
218 */ 208 */
219 for (var_num = 0; var_num <= 255; var_num++) { 209 for (var_num = 0; var_num <= 255; var_num++) {
220 entry = &srm_numbered_entries[var_num]; 210 char name[4];
221 entry->name = number[var_num]; 211 sprintf(name, "%ld", var_num);
222 212 if (!proc_create_data(name, 0644, numbered_dir,
223 if (!proc_create_data(entry->name, 0644, numbered_dir, 213 &srm_env_proc_fops, (void *)var_num))
224 &srm_env_proc_fops, entry))
225 goto cleanup; 214 goto cleanup;
226
227 entry->id = var_num;
228 } 215 }
229 216
230 printk(KERN_INFO "%s: version %s loaded successfully\n", NAME, 217 printk(KERN_INFO "%s: version %s loaded successfully\n", NAME,
@@ -242,8 +229,6 @@ srm_env_exit(void)
242{ 229{
243 remove_proc_subtree(BASE_DIR, NULL); 230 remove_proc_subtree(BASE_DIR, NULL);
244 printk(KERN_INFO "%s: unloaded successfully\n", NAME); 231 printk(KERN_INFO "%s: unloaded successfully\n", NAME);
245
246 return;
247} 232}
248 233
249module_init(srm_env_init); 234module_init(srm_env_init);