aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-12-28 18:12:35 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-12-28 18:12:35 -0500
commit2926328554fa740518e2a6585b2cefb01e5f65f3 (patch)
tree618858b51e4229480c4aaef80d166626429f0f19
parent541ef5cbb8e68189d47272cea52a69abc30259bc (diff)
parent8587b33f4adee4e7614ea7f443346c3b6bb5427a (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-nvram
* git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-nvram: [PATCH] nvram - convert PRINT_PROC to seq_file [PATCH] nvram - CodingStyle
-rw-r--r--drivers/char/nvram.c264
1 files changed, 123 insertions, 141 deletions
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 8054ee839b3c..88cee4099be9 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -32,9 +32,10 @@
32 * added changelog 32 * added changelog
33 * 1.2 Erik Gilling: Cobalt Networks support 33 * 1.2 Erik Gilling: Cobalt Networks support
34 * Tim Hockin: general cleanup, Cobalt support 34 * Tim Hockin: general cleanup, Cobalt support
35 * 1.3 Wim Van Sebroeck: convert PRINT_PROC to seq_file
35 */ 36 */
36 37
37#define NVRAM_VERSION "1.2" 38#define NVRAM_VERSION "1.3"
38 39
39#include <linux/module.h> 40#include <linux/module.h>
40#include <linux/smp_lock.h> 41#include <linux/smp_lock.h>
@@ -46,7 +47,7 @@
46/* select machine configuration */ 47/* select machine configuration */
47#if defined(CONFIG_ATARI) 48#if defined(CONFIG_ATARI)
48# define MACH ATARI 49# define MACH ATARI
49#elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) /* and others?? */ 50#elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) /* and ?? */
50# define MACH PC 51# define MACH PC
51#else 52#else
52# error Cannot build nvram driver for this machine configuration. 53# error Cannot build nvram driver for this machine configuration.
@@ -106,10 +107,11 @@
106#include <linux/mc146818rtc.h> 107#include <linux/mc146818rtc.h>
107#include <linux/init.h> 108#include <linux/init.h>
108#include <linux/proc_fs.h> 109#include <linux/proc_fs.h>
110#include <linux/seq_file.h>
109#include <linux/spinlock.h> 111#include <linux/spinlock.h>
112#include <linux/io.h>
113#include <linux/uaccess.h>
110 114
111#include <asm/io.h>
112#include <asm/uaccess.h>
113#include <asm/system.h> 115#include <asm/system.h>
114 116
115static DEFINE_SPINLOCK(nvram_state_lock); 117static DEFINE_SPINLOCK(nvram_state_lock);
@@ -122,8 +124,8 @@ static int mach_check_checksum(void);
122static void mach_set_checksum(void); 124static void mach_set_checksum(void);
123 125
124#ifdef CONFIG_PROC_FS 126#ifdef CONFIG_PROC_FS
125static int mach_proc_infos(unsigned char *contents, char *buffer, int *len, 127static void mach_proc_infos(unsigned char *contents, struct seq_file *seq,
126 off_t *begin, off_t offset, int size); 128 void *offset);
127#endif 129#endif
128 130
129/* 131/*
@@ -133,18 +135,17 @@ static int mach_proc_infos(unsigned char *contents, char *buffer, int *len,
133 * 135 *
134 * It is worth noting that these functions all access bytes of general 136 * It is worth noting that these functions all access bytes of general
135 * purpose memory in the NVRAM - that is to say, they all add the 137 * purpose memory in the NVRAM - that is to say, they all add the
136 * NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not 138 * NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not
137 * know about the RTC cruft. 139 * know about the RTC cruft.
138 */ 140 */
139 141
140unsigned char 142unsigned char __nvram_read_byte(int i)
141__nvram_read_byte(int i)
142{ 143{
143 return CMOS_READ(NVRAM_FIRST_BYTE + i); 144 return CMOS_READ(NVRAM_FIRST_BYTE + i);
144} 145}
146EXPORT_SYMBOL(__nvram_read_byte);
145 147
146unsigned char 148unsigned char nvram_read_byte(int i)
147nvram_read_byte(int i)
148{ 149{
149 unsigned long flags; 150 unsigned long flags;
150 unsigned char c; 151 unsigned char c;
@@ -154,16 +155,16 @@ nvram_read_byte(int i)
154 spin_unlock_irqrestore(&rtc_lock, flags); 155 spin_unlock_irqrestore(&rtc_lock, flags);
155 return c; 156 return c;
156} 157}
158EXPORT_SYMBOL(nvram_read_byte);
157 159
158/* This races nicely with trying to read with checksum checking (nvram_read) */ 160/* This races nicely with trying to read with checksum checking (nvram_read) */
159void 161void __nvram_write_byte(unsigned char c, int i)
160__nvram_write_byte(unsigned char c, int i)
161{ 162{
162 CMOS_WRITE(c, NVRAM_FIRST_BYTE + i); 163 CMOS_WRITE(c, NVRAM_FIRST_BYTE + i);
163} 164}
165EXPORT_SYMBOL(__nvram_write_byte);
164 166
165void 167void nvram_write_byte(unsigned char c, int i)
166nvram_write_byte(unsigned char c, int i)
167{ 168{
168 unsigned long flags; 169 unsigned long flags;
169 170
@@ -171,15 +172,15 @@ nvram_write_byte(unsigned char c, int i)
171 __nvram_write_byte(c, i); 172 __nvram_write_byte(c, i);
172 spin_unlock_irqrestore(&rtc_lock, flags); 173 spin_unlock_irqrestore(&rtc_lock, flags);
173} 174}
175EXPORT_SYMBOL(nvram_write_byte);
174 176
175int 177int __nvram_check_checksum(void)
176__nvram_check_checksum(void)
177{ 178{
178 return mach_check_checksum(); 179 return mach_check_checksum();
179} 180}
181EXPORT_SYMBOL(__nvram_check_checksum);
180 182
181int 183int nvram_check_checksum(void)
182nvram_check_checksum(void)
183{ 184{
184 unsigned long flags; 185 unsigned long flags;
185 int rv; 186 int rv;
@@ -189,16 +190,15 @@ nvram_check_checksum(void)
189 spin_unlock_irqrestore(&rtc_lock, flags); 190 spin_unlock_irqrestore(&rtc_lock, flags);
190 return rv; 191 return rv;
191} 192}
193EXPORT_SYMBOL(nvram_check_checksum);
192 194
193static void 195static void __nvram_set_checksum(void)
194__nvram_set_checksum(void)
195{ 196{
196 mach_set_checksum(); 197 mach_set_checksum();
197} 198}
198 199
199#if 0 200#if 0
200void 201void nvram_set_checksum(void)
201nvram_set_checksum(void)
202{ 202{
203 unsigned long flags; 203 unsigned long flags;
204 204
@@ -212,7 +212,7 @@ nvram_set_checksum(void)
212 * The are the file operation function for user access to /dev/nvram 212 * The are the file operation function for user access to /dev/nvram
213 */ 213 */
214 214
215static loff_t nvram_llseek(struct file *file,loff_t offset, int origin ) 215static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
216{ 216{
217 lock_kernel(); 217 lock_kernel();
218 switch (origin) { 218 switch (origin) {
@@ -230,8 +230,8 @@ static loff_t nvram_llseek(struct file *file,loff_t offset, int origin )
230 return (offset >= 0) ? (file->f_pos = offset) : -EINVAL; 230 return (offset >= 0) ? (file->f_pos = offset) : -EINVAL;
231} 231}
232 232
233static ssize_t 233static ssize_t nvram_read(struct file *file, char __user *buf,
234nvram_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) 234 size_t count, loff_t *ppos)
235{ 235{
236 unsigned char contents[NVRAM_BYTES]; 236 unsigned char contents[NVRAM_BYTES];
237 unsigned i = *ppos; 237 unsigned i = *ppos;
@@ -254,13 +254,13 @@ nvram_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
254 254
255 return tmp - contents; 255 return tmp - contents;
256 256
257 checksum_err: 257checksum_err:
258 spin_unlock_irq(&rtc_lock); 258 spin_unlock_irq(&rtc_lock);
259 return -EIO; 259 return -EIO;
260} 260}
261 261
262static ssize_t 262static ssize_t nvram_write(struct file *file, const char __user *buf,
263nvram_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 263 size_t count, loff_t *ppos)
264{ 264{
265 unsigned char contents[NVRAM_BYTES]; 265 unsigned char contents[NVRAM_BYTES];
266 unsigned i = *ppos; 266 unsigned i = *ppos;
@@ -287,14 +287,13 @@ nvram_write(struct file *file, const char __user *buf, size_t count, loff_t *ppo
287 287
288 return tmp - contents; 288 return tmp - contents;
289 289
290 checksum_err: 290checksum_err:
291 spin_unlock_irq(&rtc_lock); 291 spin_unlock_irq(&rtc_lock);
292 return -EIO; 292 return -EIO;
293} 293}
294 294
295static int 295static int nvram_ioctl(struct inode *inode, struct file *file,
296nvram_ioctl(struct inode *inode, struct file *file, 296 unsigned int cmd, unsigned long arg)
297 unsigned int cmd, unsigned long arg)
298{ 297{
299 int i; 298 int i;
300 299
@@ -315,7 +314,7 @@ nvram_ioctl(struct inode *inode, struct file *file,
315 return 0; 314 return 0;
316 315
317 case NVRAM_SETCKS: 316 case NVRAM_SETCKS:
318 /* just set checksum, contents unchanged (maybe useful after 317 /* just set checksum, contents unchanged (maybe useful after
319 * checksum garbaged somehow...) */ 318 * checksum garbaged somehow...) */
320 if (!capable(CAP_SYS_ADMIN)) 319 if (!capable(CAP_SYS_ADMIN))
321 return -EACCES; 320 return -EACCES;
@@ -330,8 +329,7 @@ nvram_ioctl(struct inode *inode, struct file *file,
330 } 329 }
331} 330}
332 331
333static int 332static int nvram_open(struct inode *inode, struct file *file)
334nvram_open(struct inode *inode, struct file *file)
335{ 333{
336 lock_kernel(); 334 lock_kernel();
337 spin_lock(&nvram_state_lock); 335 spin_lock(&nvram_state_lock);
@@ -356,8 +354,7 @@ nvram_open(struct inode *inode, struct file *file)
356 return 0; 354 return 0;
357} 355}
358 356
359static int 357static int nvram_release(struct inode *inode, struct file *file)
360nvram_release(struct inode *inode, struct file *file)
361{ 358{
362 spin_lock(&nvram_state_lock); 359 spin_lock(&nvram_state_lock);
363 360
@@ -375,48 +372,47 @@ nvram_release(struct inode *inode, struct file *file)
375} 372}
376 373
377#ifndef CONFIG_PROC_FS 374#ifndef CONFIG_PROC_FS
378static int 375static int nvram_add_proc_fs(void)
379nvram_read_proc(char *buffer, char **start, off_t offset,
380 int size, int *eof, void *data)
381{ 376{
382 return 0; 377 return 0;
383} 378}
379
384#else 380#else
385 381
386static int 382static int nvram_proc_read(struct seq_file *seq, void *offset)
387nvram_read_proc(char *buffer, char **start, off_t offset,
388 int size, int *eof, void *data)
389{ 383{
390 unsigned char contents[NVRAM_BYTES]; 384 unsigned char contents[NVRAM_BYTES];
391 int i, len = 0; 385 int i = 0;
392 off_t begin = 0;
393 386
394 spin_lock_irq(&rtc_lock); 387 spin_lock_irq(&rtc_lock);
395 for (i = 0; i < NVRAM_BYTES; ++i) 388 for (i = 0; i < NVRAM_BYTES; ++i)
396 contents[i] = __nvram_read_byte(i); 389 contents[i] = __nvram_read_byte(i);
397 spin_unlock_irq(&rtc_lock); 390 spin_unlock_irq(&rtc_lock);
398 391
399 *eof = mach_proc_infos(contents, buffer, &len, &begin, offset, size); 392 mach_proc_infos(contents, seq, offset);
400 393
401 if (offset >= begin + len) 394 return 0;
402 return 0; 395}
403 *start = buffer + (offset - begin);
404 return (size < begin + len - offset) ? size : begin + len - offset;
405 396
397static int nvram_proc_open(struct inode *inode, struct file *file)
398{
399 return single_open(file, nvram_proc_read, NULL);
406} 400}
407 401
408/* This macro frees the machine specific function from bounds checking and 402static const struct file_operations nvram_proc_fops = {
409 * this like that... */ 403 .owner = THIS_MODULE,
410#define PRINT_PROC(fmt,args...) \ 404 .open = nvram_proc_open,
411 do { \ 405 .read = seq_read,
412 *len += sprintf(buffer+*len, fmt, ##args); \ 406 .llseek = seq_lseek,
413 if (*begin + *len > offset + size) \ 407 .release = single_release,
414 return 0; \ 408};
415 if (*begin + *len < offset) { \ 409
416 *begin += *len; \ 410static int nvram_add_proc_fs(void)
417 *len = 0; \ 411{
418 } \ 412 if (!proc_create("driver/nvram", 0, NULL, &nvram_proc_fops))
419 } while(0) 413 return -ENOMEM;
414 return 0;
415}
420 416
421#endif /* CONFIG_PROC_FS */ 417#endif /* CONFIG_PROC_FS */
422 418
@@ -436,8 +432,7 @@ static struct miscdevice nvram_dev = {
436 &nvram_fops 432 &nvram_fops
437}; 433};
438 434
439static int __init 435static int __init nvram_init(void)
440nvram_init(void)
441{ 436{
442 int ret; 437 int ret;
443 438
@@ -451,23 +446,21 @@ nvram_init(void)
451 NVRAM_MINOR); 446 NVRAM_MINOR);
452 goto out; 447 goto out;
453 } 448 }
454 if (!create_proc_read_entry("driver/nvram", 0, NULL, nvram_read_proc, 449 ret = nvram_add_proc_fs();
455 NULL)) { 450 if (ret) {
456 printk(KERN_ERR "nvram: can't create /proc/driver/nvram\n"); 451 printk(KERN_ERR "nvram: can't create /proc/driver/nvram\n");
457 ret = -ENOMEM;
458 goto outmisc; 452 goto outmisc;
459 } 453 }
460 ret = 0; 454 ret = 0;
461 printk(KERN_INFO "Non-volatile memory driver v" NVRAM_VERSION "\n"); 455 printk(KERN_INFO "Non-volatile memory driver v" NVRAM_VERSION "\n");
462 out: 456out:
463 return ret; 457 return ret;
464 outmisc: 458outmisc:
465 misc_deregister(&nvram_dev); 459 misc_deregister(&nvram_dev);
466 goto out; 460 goto out;
467} 461}
468 462
469static void __exit 463static void __exit nvram_cleanup_module(void)
470nvram_cleanup_module(void)
471{ 464{
472 remove_proc_entry("driver/nvram", NULL); 465 remove_proc_entry("driver/nvram", NULL);
473 misc_deregister(&nvram_dev); 466 misc_deregister(&nvram_dev);
@@ -482,8 +475,7 @@ module_exit(nvram_cleanup_module);
482 475
483#if MACH == PC 476#if MACH == PC
484 477
485static int 478static int pc_check_checksum(void)
486pc_check_checksum(void)
487{ 479{
488 int i; 480 int i;
489 unsigned short sum = 0; 481 unsigned short sum = 0;
@@ -493,11 +485,10 @@ pc_check_checksum(void)
493 sum += __nvram_read_byte(i); 485 sum += __nvram_read_byte(i);
494 expect = __nvram_read_byte(PC_CKS_LOC)<<8 | 486 expect = __nvram_read_byte(PC_CKS_LOC)<<8 |
495 __nvram_read_byte(PC_CKS_LOC+1); 487 __nvram_read_byte(PC_CKS_LOC+1);
496 return ((sum & 0xffff) == expect); 488 return (sum & 0xffff) == expect;
497} 489}
498 490
499static void 491static void pc_set_checksum(void)
500pc_set_checksum(void)
501{ 492{
502 int i; 493 int i;
503 unsigned short sum = 0; 494 unsigned short sum = 0;
@@ -522,9 +513,8 @@ static char *gfx_types[] = {
522 "monochrome", 513 "monochrome",
523}; 514};
524 515
525static int 516static void pc_proc_infos(unsigned char *nvram, struct seq_file *seq,
526pc_proc_infos(unsigned char *nvram, char *buffer, int *len, 517 void *offset)
527 off_t *begin, off_t offset, int size)
528{ 518{
529 int checksum; 519 int checksum;
530 int type; 520 int type;
@@ -533,56 +523,57 @@ pc_proc_infos(unsigned char *nvram, char *buffer, int *len,
533 checksum = __nvram_check_checksum(); 523 checksum = __nvram_check_checksum();
534 spin_unlock_irq(&rtc_lock); 524 spin_unlock_irq(&rtc_lock);
535 525
536 PRINT_PROC("Checksum status: %svalid\n", checksum ? "" : "not "); 526 seq_printf(seq, "Checksum status: %svalid\n", checksum ? "" : "not ");
537 527
538 PRINT_PROC("# floppies : %d\n", 528 seq_printf(seq, "# floppies : %d\n",
539 (nvram[6] & 1) ? (nvram[6] >> 6) + 1 : 0); 529 (nvram[6] & 1) ? (nvram[6] >> 6) + 1 : 0);
540 PRINT_PROC("Floppy 0 type : "); 530 seq_printf(seq, "Floppy 0 type : ");
541 type = nvram[2] >> 4; 531 type = nvram[2] >> 4;
542 if (type < ARRAY_SIZE(floppy_types)) 532 if (type < ARRAY_SIZE(floppy_types))
543 PRINT_PROC("%s\n", floppy_types[type]); 533 seq_printf(seq, "%s\n", floppy_types[type]);
544 else 534 else
545 PRINT_PROC("%d (unknown)\n", type); 535 seq_printf(seq, "%d (unknown)\n", type);
546 PRINT_PROC("Floppy 1 type : "); 536 seq_printf(seq, "Floppy 1 type : ");
547 type = nvram[2] & 0x0f; 537 type = nvram[2] & 0x0f;
548 if (type < ARRAY_SIZE(floppy_types)) 538 if (type < ARRAY_SIZE(floppy_types))
549 PRINT_PROC("%s\n", floppy_types[type]); 539 seq_printf(seq, "%s\n", floppy_types[type]);
550 else 540 else
551 PRINT_PROC("%d (unknown)\n", type); 541 seq_printf(seq, "%d (unknown)\n", type);
552 542
553 PRINT_PROC("HD 0 type : "); 543 seq_printf(seq, "HD 0 type : ");
554 type = nvram[4] >> 4; 544 type = nvram[4] >> 4;
555 if (type) 545 if (type)
556 PRINT_PROC("%02x\n", type == 0x0f ? nvram[11] : type); 546 seq_printf(seq, "%02x\n", type == 0x0f ? nvram[11] : type);
557 else 547 else
558 PRINT_PROC("none\n"); 548 seq_printf(seq, "none\n");
559 549
560 PRINT_PROC("HD 1 type : "); 550 seq_printf(seq, "HD 1 type : ");
561 type = nvram[4] & 0x0f; 551 type = nvram[4] & 0x0f;
562 if (type) 552 if (type)
563 PRINT_PROC("%02x\n", type == 0x0f ? nvram[12] : type); 553 seq_printf(seq, "%02x\n", type == 0x0f ? nvram[12] : type);
564 else 554 else
565 PRINT_PROC("none\n"); 555 seq_printf(seq, "none\n");
566 556
567 PRINT_PROC("HD type 48 data: %d/%d/%d C/H/S, precomp %d, lz %d\n", 557 seq_printf(seq, "HD type 48 data: %d/%d/%d C/H/S, precomp %d, lz %d\n",
568 nvram[18] | (nvram[19] << 8), 558 nvram[18] | (nvram[19] << 8),
569 nvram[20], nvram[25], 559 nvram[20], nvram[25],
570 nvram[21] | (nvram[22] << 8), nvram[23] | (nvram[24] << 8)); 560 nvram[21] | (nvram[22] << 8), nvram[23] | (nvram[24] << 8));
571 PRINT_PROC("HD type 49 data: %d/%d/%d C/H/S, precomp %d, lz %d\n", 561 seq_printf(seq, "HD type 49 data: %d/%d/%d C/H/S, precomp %d, lz %d\n",
572 nvram[39] | (nvram[40] << 8), 562 nvram[39] | (nvram[40] << 8),
573 nvram[41], nvram[46], 563 nvram[41], nvram[46],
574 nvram[42] | (nvram[43] << 8), nvram[44] | (nvram[45] << 8)); 564 nvram[42] | (nvram[43] << 8), nvram[44] | (nvram[45] << 8));
575 565
576 PRINT_PROC("DOS base memory: %d kB\n", nvram[7] | (nvram[8] << 8)); 566 seq_printf(seq, "DOS base memory: %d kB\n", nvram[7] | (nvram[8] << 8));
577 PRINT_PROC("Extended memory: %d kB (configured), %d kB (tested)\n", 567 seq_printf(seq, "Extended memory: %d kB (configured), %d kB (tested)\n",
578 nvram[9] | (nvram[10] << 8), nvram[34] | (nvram[35] << 8)); 568 nvram[9] | (nvram[10] << 8), nvram[34] | (nvram[35] << 8));
579 569
580 PRINT_PROC("Gfx adapter : %s\n", gfx_types[(nvram[6] >> 4) & 3]); 570 seq_printf(seq, "Gfx adapter : %s\n",
571 gfx_types[(nvram[6] >> 4) & 3]);
581 572
582 PRINT_PROC("FPU : %sinstalled\n", 573 seq_printf(seq, "FPU : %sinstalled\n",
583 (nvram[6] & 2) ? "" : "not "); 574 (nvram[6] & 2) ? "" : "not ");
584 575
585 return 1; 576 return;
586} 577}
587#endif 578#endif
588 579
@@ -590,20 +581,18 @@ pc_proc_infos(unsigned char *nvram, char *buffer, int *len,
590 581
591#if MACH == ATARI 582#if MACH == ATARI
592 583
593static int 584static int atari_check_checksum(void)
594atari_check_checksum(void)
595{ 585{
596 int i; 586 int i;
597 unsigned char sum = 0; 587 unsigned char sum = 0;
598 588
599 for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i) 589 for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i)
600 sum += __nvram_read_byte(i); 590 sum += __nvram_read_byte(i);
601 return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum & 0xff) && 591 return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum & 0xff)) &&
602 __nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff)); 592 (__nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff));
603} 593}
604 594
605static void 595static void atari_set_checksum(void)
606atari_set_checksum(void)
607{ 596{
608 int i; 597 int i;
609 unsigned char sum = 0; 598 unsigned char sum = 0;
@@ -654,82 +643,75 @@ static char *colors[] = {
654 "2", "4", "16", "256", "65536", "??", "??", "??" 643 "2", "4", "16", "256", "65536", "??", "??", "??"
655}; 644};
656 645
657static int 646static void atari_proc_infos(unsigned char *nvram, struct seq_file *seq,
658atari_proc_infos(unsigned char *nvram, char *buffer, int *len, 647 void *offset)
659 off_t *begin, off_t offset, int size)
660{ 648{
661 int checksum = nvram_check_checksum(); 649 int checksum = nvram_check_checksum();
662 int i; 650 int i;
663 unsigned vmode; 651 unsigned vmode;
664 652
665 PRINT_PROC("Checksum status : %svalid\n", checksum ? "" : "not "); 653 seq_printf(seq, "Checksum status : %svalid\n", checksum ? "" : "not ");
666 654
667 PRINT_PROC("Boot preference : "); 655 seq_printf(seq, "Boot preference : ");
668 for (i = ARRAY_SIZE(boot_prefs) - 1; i >= 0; --i) { 656 for (i = ARRAY_SIZE(boot_prefs) - 1; i >= 0; --i) {
669 if (nvram[1] == boot_prefs[i].val) { 657 if (nvram[1] == boot_prefs[i].val) {
670 PRINT_PROC("%s\n", boot_prefs[i].name); 658 seq_printf(seq, "%s\n", boot_prefs[i].name);
671 break; 659 break;
672 } 660 }
673 } 661 }
674 if (i < 0) 662 if (i < 0)
675 PRINT_PROC("0x%02x (undefined)\n", nvram[1]); 663 seq_printf(seq, "0x%02x (undefined)\n", nvram[1]);
676 664
677 PRINT_PROC("SCSI arbitration : %s\n", 665 seq_printf(seq, "SCSI arbitration : %s\n",
678 (nvram[16] & 0x80) ? "on" : "off"); 666 (nvram[16] & 0x80) ? "on" : "off");
679 PRINT_PROC("SCSI host ID : "); 667 seq_printf(seq, "SCSI host ID : ");
680 if (nvram[16] & 0x80) 668 if (nvram[16] & 0x80)
681 PRINT_PROC("%d\n", nvram[16] & 7); 669 seq_printf(seq, "%d\n", nvram[16] & 7);
682 else 670 else
683 PRINT_PROC("n/a\n"); 671 seq_printf(seq, "n/a\n");
684 672
685 /* the following entries are defined only for the Falcon */ 673 /* the following entries are defined only for the Falcon */
686 if ((atari_mch_cookie >> 16) != ATARI_MCH_FALCON) 674 if ((atari_mch_cookie >> 16) != ATARI_MCH_FALCON)
687 return 1; 675 return;
688 676
689 PRINT_PROC("OS language : "); 677 seq_printf(seq, "OS language : ");
690 if (nvram[6] < ARRAY_SIZE(languages)) 678 if (nvram[6] < ARRAY_SIZE(languages))
691 PRINT_PROC("%s\n", languages[nvram[6]]); 679 seq_printf(seq, "%s\n", languages[nvram[6]]);
692 else 680 else
693 PRINT_PROC("%u (undefined)\n", nvram[6]); 681 seq_printf(seq, "%u (undefined)\n", nvram[6]);
694 PRINT_PROC("Keyboard language: "); 682 seq_printf(seq, "Keyboard language: ");
695 if (nvram[7] < ARRAY_SIZE(languages)) 683 if (nvram[7] < ARRAY_SIZE(languages))
696 PRINT_PROC("%s\n", languages[nvram[7]]); 684 seq_printf(seq, "%s\n", languages[nvram[7]]);
697 else 685 else
698 PRINT_PROC("%u (undefined)\n", nvram[7]); 686 seq_printf(seq, "%u (undefined)\n", nvram[7]);
699 PRINT_PROC("Date format : "); 687 seq_printf(seq, "Date format : ");
700 PRINT_PROC(dateformat[nvram[8] & 7], 688 seq_printf(seq, dateformat[nvram[8] & 7],
701 nvram[9] ? nvram[9] : '/', nvram[9] ? nvram[9] : '/'); 689 nvram[9] ? nvram[9] : '/', nvram[9] ? nvram[9] : '/');
702 PRINT_PROC(", %dh clock\n", nvram[8] & 16 ? 24 : 12); 690 seq_printf(seq, ", %dh clock\n", nvram[8] & 16 ? 24 : 12);
703 PRINT_PROC("Boot delay : "); 691 seq_printf(seq, "Boot delay : ");
704 if (nvram[10] == 0) 692 if (nvram[10] == 0)
705 PRINT_PROC("default"); 693 seq_printf(seq, "default");
706 else 694 else
707 PRINT_PROC("%ds%s\n", nvram[10], 695 seq_printf(seq, "%ds%s\n", nvram[10],
708 nvram[10] < 8 ? ", no memory test" : ""); 696 nvram[10] < 8 ? ", no memory test" : "");
709 697
710 vmode = (nvram[14] << 8) || nvram[15]; 698 vmode = (nvram[14] << 8) || nvram[15];
711 PRINT_PROC("Video mode : %s colors, %d columns, %s %s monitor\n", 699 seq_printf(seq,
700 "Video mode : %s colors, %d columns, %s %s monitor\n",
712 colors[vmode & 7], 701 colors[vmode & 7],
713 vmode & 8 ? 80 : 40, 702 vmode & 8 ? 80 : 40,
714 vmode & 16 ? "VGA" : "TV", vmode & 32 ? "PAL" : "NTSC"); 703 vmode & 16 ? "VGA" : "TV", vmode & 32 ? "PAL" : "NTSC");
715 PRINT_PROC(" %soverscan, compat. mode %s%s\n", 704 seq_printf(seq, " %soverscan, compat. mode %s%s\n",
716 vmode & 64 ? "" : "no ", 705 vmode & 64 ? "" : "no ",
717 vmode & 128 ? "on" : "off", 706 vmode & 128 ? "on" : "off",
718 vmode & 256 ? 707 vmode & 256 ?
719 (vmode & 16 ? ", line doubling" : ", half screen") : ""); 708 (vmode & 16 ? ", line doubling" : ", half screen") : "");
720 709
721 return 1; 710 return;
722} 711}
723#endif 712#endif
724 713
725#endif /* MACH == ATARI */ 714#endif /* MACH == ATARI */
726 715
727MODULE_LICENSE("GPL"); 716MODULE_LICENSE("GPL");
728
729EXPORT_SYMBOL(__nvram_read_byte);
730EXPORT_SYMBOL(nvram_read_byte);
731EXPORT_SYMBOL(__nvram_write_byte);
732EXPORT_SYMBOL(nvram_write_byte);
733EXPORT_SYMBOL(__nvram_check_checksum);
734EXPORT_SYMBOL(nvram_check_checksum);
735MODULE_ALIAS_MISCDEV(NVRAM_MINOR); 717MODULE_ALIAS_MISCDEV(NVRAM_MINOR);