aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-11-07 21:22:31 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-11-07 21:22:31 -0500
commit5b064423d66159a1b33ff9d5bcb42040a03e7dfe (patch)
tree2eb42eb50d75ca6e4ec773e81db6136adb5c0d7a
parent3d4248885b9fca818e7fe6b66328e714876d36ad (diff)
parent16b7f4dcd340875625714438a812ea06400f9666 (diff)
Merge branch 'fixes_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbglaw/vax-linux
* 'fixes_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbglaw/vax-linux: Update for the srm_env driver.
-rw-r--r--arch/alpha/kernel/srm_env.c84
1 files changed, 27 insertions, 57 deletions
diff --git a/arch/alpha/kernel/srm_env.c b/arch/alpha/kernel/srm_env.c
index 990ac61028f8..f7dd081d57ff 100644
--- a/arch/alpha/kernel/srm_env.c
+++ b/arch/alpha/kernel/srm_env.c
@@ -2,7 +2,7 @@
2 * srm_env.c - Access to SRM environment 2 * srm_env.c - Access to SRM environment
3 * variables through linux' procfs 3 * variables through linux' procfs
4 * 4 *
5 * Copyright (C) 2001-2002 Jan-Benedict Glaw <jbglaw@lug-owl.de> 5 * (C) 2001,2002,2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de>
6 * 6 *
7 * This driver is at all a modified version of Erik Mouw's 7 * This driver is at all a modified version of Erik Mouw's
8 * Documentation/DocBook/procfs_example.c, so: thank 8 * Documentation/DocBook/procfs_example.c, so: thank
@@ -21,7 +21,7 @@
21 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 21 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
22 * PURPOSE. See the GNU General Public License for more 22 * PURPOSE. See the GNU General Public License for more
23 * details. 23 * details.
24 * 24 *
25 * You should have received a copy of the GNU General Public 25 * You should have received a copy of the GNU General Public
26 * License along with this program; if not, write to the 26 * License along with this program; if not, write to the
27 * Free Software Foundation, Inc., 59 Temple Place, 27 * Free Software Foundation, Inc., 59 Temple Place,
@@ -29,33 +29,6 @@
29 * 29 *
30 */ 30 */
31 31
32/*
33 * Changelog
34 * ~~~~~~~~~
35 *
36 * Thu, 22 Aug 2002 15:10:43 +0200
37 * - Update Config.help entry. I got a number of emails asking
38 * me to tell their senders if they could make use of this
39 * piece of code... So: "SRM is something like BIOS for your
40 * Alpha"
41 * - Update code formatting a bit to better conform CodingStyle
42 * rules.
43 * - So this is v0.0.5, with no changes (except formatting)
44 *
45 * Wed, 22 May 2002 00:11:21 +0200
46 * - Fix typo on comment (SRC -> SRM)
47 * - Call this "Version 0.0.4"
48 *
49 * Tue, 9 Apr 2002 18:44:40 +0200
50 * - Implement access by variable name and additionally
51 * by number. This is done by creating two subdirectories
52 * where one holds all names (like the old directory
53 * did) and the other holding 256 files named like "0",
54 * "1" and so on.
55 * - Call this "Version 0.0.3"
56 *
57 */
58
59#include <linux/kernel.h> 32#include <linux/kernel.h>
60#include <linux/module.h> 33#include <linux/module.h>
61#include <linux/init.h> 34#include <linux/init.h>
@@ -67,7 +40,7 @@
67#define BASE_DIR "srm_environment" /* Subdir in /proc/ */ 40#define BASE_DIR "srm_environment" /* Subdir in /proc/ */
68#define NAMED_DIR "named_variables" /* Subdir for known variables */ 41#define NAMED_DIR "named_variables" /* Subdir for known variables */
69#define NUMBERED_DIR "numbered_variables" /* Subdir for all variables */ 42#define NUMBERED_DIR "numbered_variables" /* Subdir for all variables */
70#define VERSION "0.0.5" /* Module version */ 43#define VERSION "0.0.6" /* Module version */
71#define NAME "srm_env" /* Module name */ 44#define NAME "srm_env" /* Module name */
72 45
73MODULE_AUTHOR("Jan-Benedict Glaw <jbglaw@lug-owl.de>"); 46MODULE_AUTHOR("Jan-Benedict Glaw <jbglaw@lug-owl.de>");
@@ -106,7 +79,6 @@ static srm_env_t srm_named_entries[] = {
106static srm_env_t srm_numbered_entries[256]; 79static srm_env_t srm_numbered_entries[256];
107 80
108 81
109
110static int 82static int
111srm_env_read(char *page, char **start, off_t off, int count, int *eof, 83srm_env_read(char *page, char **start, off_t off, int count, int *eof,
112 void *data) 84 void *data)
@@ -115,21 +87,23 @@ srm_env_read(char *page, char **start, off_t off, int count, int *eof,
115 unsigned long ret; 87 unsigned long ret;
116 srm_env_t *entry; 88 srm_env_t *entry;
117 89
118 if(off != 0) 90 if (off != 0) {
119 return -EFAULT; 91 *eof = 1;
92 return 0;
93 }
120 94
121 entry = (srm_env_t *) data; 95 entry = (srm_env_t *) data;
122 ret = callback_getenv(entry->id, page, count); 96 ret = callback_getenv(entry->id, page, count);
123 97
124 if((ret >> 61) == 0) 98 if ((ret >> 61) == 0) {
125 nbytes = (int) ret; 99 nbytes = (int) ret;
126 else 100 *eof = 1;
101 } else
127 nbytes = -EFAULT; 102 nbytes = -EFAULT;
128 103
129 return nbytes; 104 return nbytes;
130} 105}
131 106
132
133static int 107static int
134srm_env_write(struct file *file, const char __user *buffer, unsigned long count, 108srm_env_write(struct file *file, const char __user *buffer, unsigned long count,
135 void *data) 109 void *data)
@@ -155,7 +129,7 @@ srm_env_write(struct file *file, const char __user *buffer, unsigned long count,
155 129
156 ret1 = callback_setenv(entry->id, buf, count); 130 ret1 = callback_setenv(entry->id, buf, count);
157 if ((ret1 >> 61) == 0) { 131 if ((ret1 >> 61) == 0) {
158 do 132 do
159 ret2 = callback_save_env(); 133 ret2 = callback_save_env();
160 while((ret2 >> 61) == 1); 134 while((ret2 >> 61) == 1);
161 res = (int) ret1; 135 res = (int) ret1;
@@ -172,14 +146,14 @@ srm_env_cleanup(void)
172 srm_env_t *entry; 146 srm_env_t *entry;
173 unsigned long var_num; 147 unsigned long var_num;
174 148
175 if(base_dir) { 149 if (base_dir) {
176 /* 150 /*
177 * Remove named entries 151 * Remove named entries
178 */ 152 */
179 if(named_dir) { 153 if (named_dir) {
180 entry = srm_named_entries; 154 entry = srm_named_entries;
181 while(entry->name != NULL && entry->id != 0) { 155 while (entry->name != NULL && entry->id != 0) {
182 if(entry->proc_entry) { 156 if (entry->proc_entry) {
183 remove_proc_entry(entry->name, 157 remove_proc_entry(entry->name,
184 named_dir); 158 named_dir);
185 entry->proc_entry = NULL; 159 entry->proc_entry = NULL;
@@ -192,11 +166,11 @@ srm_env_cleanup(void)
192 /* 166 /*
193 * Remove numbered entries 167 * Remove numbered entries
194 */ 168 */
195 if(numbered_dir) { 169 if (numbered_dir) {
196 for(var_num = 0; var_num <= 255; var_num++) { 170 for (var_num = 0; var_num <= 255; var_num++) {
197 entry = &srm_numbered_entries[var_num]; 171 entry = &srm_numbered_entries[var_num];
198 172
199 if(entry->proc_entry) { 173 if (entry->proc_entry) {
200 remove_proc_entry(entry->name, 174 remove_proc_entry(entry->name,
201 numbered_dir); 175 numbered_dir);
202 entry->proc_entry = NULL; 176 entry->proc_entry = NULL;
@@ -212,7 +186,6 @@ srm_env_cleanup(void)
212 return; 186 return;
213} 187}
214 188
215
216static int __init 189static int __init
217srm_env_init(void) 190srm_env_init(void)
218{ 191{
@@ -222,7 +195,7 @@ srm_env_init(void)
222 /* 195 /*
223 * Check system 196 * Check system
224 */ 197 */
225 if(!alpha_using_srm) { 198 if (!alpha_using_srm) {
226 printk(KERN_INFO "%s: This Alpha system doesn't " 199 printk(KERN_INFO "%s: This Alpha system doesn't "
227 "know about SRM (or you've booted " 200 "know about SRM (or you've booted "
228 "SRM->MILO->Linux, which gets " 201 "SRM->MILO->Linux, which gets "
@@ -233,14 +206,14 @@ srm_env_init(void)
233 /* 206 /*
234 * Init numbers 207 * Init numbers
235 */ 208 */
236 for(var_num = 0; var_num <= 255; var_num++) 209 for (var_num = 0; var_num <= 255; var_num++)
237 sprintf(number[var_num], "%ld", var_num); 210 sprintf(number[var_num], "%ld", var_num);
238 211
239 /* 212 /*
240 * Create base directory 213 * Create base directory
241 */ 214 */
242 base_dir = proc_mkdir(BASE_DIR, NULL); 215 base_dir = proc_mkdir(BASE_DIR, NULL);
243 if(base_dir == NULL) { 216 if (!base_dir) {
244 printk(KERN_ERR "Couldn't create base dir /proc/%s\n", 217 printk(KERN_ERR "Couldn't create base dir /proc/%s\n",
245 BASE_DIR); 218 BASE_DIR);
246 goto cleanup; 219 goto cleanup;
@@ -251,7 +224,7 @@ srm_env_init(void)
251 * Create per-name subdirectory 224 * Create per-name subdirectory
252 */ 225 */
253 named_dir = proc_mkdir(NAMED_DIR, base_dir); 226 named_dir = proc_mkdir(NAMED_DIR, base_dir);
254 if(named_dir == NULL) { 227 if (!named_dir) {
255 printk(KERN_ERR "Couldn't create dir /proc/%s/%s\n", 228 printk(KERN_ERR "Couldn't create dir /proc/%s/%s\n",
256 BASE_DIR, NAMED_DIR); 229 BASE_DIR, NAMED_DIR);
257 goto cleanup; 230 goto cleanup;
@@ -262,7 +235,7 @@ srm_env_init(void)
262 * Create per-number subdirectory 235 * Create per-number subdirectory
263 */ 236 */
264 numbered_dir = proc_mkdir(NUMBERED_DIR, base_dir); 237 numbered_dir = proc_mkdir(NUMBERED_DIR, base_dir);
265 if(numbered_dir == NULL) { 238 if (!numbered_dir) {
266 printk(KERN_ERR "Couldn't create dir /proc/%s/%s\n", 239 printk(KERN_ERR "Couldn't create dir /proc/%s/%s\n",
267 BASE_DIR, NUMBERED_DIR); 240 BASE_DIR, NUMBERED_DIR);
268 goto cleanup; 241 goto cleanup;
@@ -274,10 +247,10 @@ srm_env_init(void)
274 * Create all named nodes 247 * Create all named nodes
275 */ 248 */
276 entry = srm_named_entries; 249 entry = srm_named_entries;
277 while(entry->name != NULL && entry->id != 0) { 250 while (entry->name && entry->id) {
278 entry->proc_entry = create_proc_entry(entry->name, 251 entry->proc_entry = create_proc_entry(entry->name,
279 0644, named_dir); 252 0644, named_dir);
280 if(entry->proc_entry == NULL) 253 if (!entry->proc_entry)
281 goto cleanup; 254 goto cleanup;
282 255
283 entry->proc_entry->data = (void *) entry; 256 entry->proc_entry->data = (void *) entry;
@@ -291,13 +264,13 @@ srm_env_init(void)
291 /* 264 /*
292 * Create all numbered nodes 265 * Create all numbered nodes
293 */ 266 */
294 for(var_num = 0; var_num <= 255; var_num++) { 267 for (var_num = 0; var_num <= 255; var_num++) {
295 entry = &srm_numbered_entries[var_num]; 268 entry = &srm_numbered_entries[var_num];
296 entry->name = number[var_num]; 269 entry->name = number[var_num];
297 270
298 entry->proc_entry = create_proc_entry(entry->name, 271 entry->proc_entry = create_proc_entry(entry->name,
299 0644, numbered_dir); 272 0644, numbered_dir);
300 if(entry->proc_entry == NULL) 273 if (!entry->proc_entry)
301 goto cleanup; 274 goto cleanup;
302 275
303 entry->id = var_num; 276 entry->id = var_num;
@@ -318,7 +291,6 @@ cleanup:
318 return -ENOMEM; 291 return -ENOMEM;
319} 292}
320 293
321
322static void __exit 294static void __exit
323srm_env_exit(void) 295srm_env_exit(void)
324{ 296{
@@ -328,7 +300,5 @@ srm_env_exit(void)
328 return; 300 return;
329} 301}
330 302
331
332module_init(srm_env_init); 303module_init(srm_env_init);
333module_exit(srm_env_exit); 304module_exit(srm_env_exit);
334