Commit bb6b9b28d6847bc71f910e2e82c9040ff4b97ec0

Authored by Benjamin Herrenschmidt
Committed by Paul Mackerras
1 parent 54b9a9aedc

[PATCH] powerpc: udbg updates

The udbg low level io layer has an issue with udbg_getc() returning a
char (unsigned on ppc) instead of an int, thus the -1 if you had no
available input device could end up turned into 0xff, filling your
display with bogus characters. This fixes it, along with adding a little
blob to xmon to do a delay before exiting when getting an EOF and fixing
the detection of ADB keyboards in udbg_adb.c

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>

Showing 9 changed files with 24 additions and 19 deletions Side-by-side Diff

arch/powerpc/kernel/prom_parse.c
... ... @@ -276,7 +276,7 @@
276 276  
277 277 finish:
278 278 of_dump_addr("OF: parent translation for:", addr, pna);
279   - DBG("OF: with offset: %lx\n", offset);
  279 + DBG("OF: with offset: "PRu64"\n", offset);
280 280  
281 281 /* Translate it into parent bus space */
282 282 return pbus->translate(addr, offset, pna);
arch/powerpc/kernel/udbg.c
... ... @@ -17,7 +17,7 @@
17 17 #include <asm/processor.h>
18 18  
19 19 void (*udbg_putc)(char c);
20   -char (*udbg_getc)(void);
  20 +int (*udbg_getc)(void);
21 21 int (*udbg_getc_poll)(void);
22 22  
23 23 /* udbg library, used by xmon et al */
... ... @@ -57,8 +57,8 @@
57 57  
58 58 int udbg_read(char *buf, int buflen)
59 59 {
60   - char c, *p = buf;
61   - int i;
  60 + char *p = buf;
  61 + int i, c;
62 62  
63 63 if (!udbg_getc)
64 64 return 0;
65 65  
... ... @@ -66,8 +66,11 @@
66 66 for (i = 0; i < buflen; ++i) {
67 67 do {
68 68 c = udbg_getc();
  69 + if (c == -1 && i == 0)
  70 + return -1;
  71 +
69 72 } while (c == 0x11 || c == 0x13);
70   - if (c == 0)
  73 + if (c == 0 || c == -1)
71 74 break;
72 75 *p++ = c;
73 76 }
arch/powerpc/kernel/udbg_16550.c
... ... @@ -69,14 +69,14 @@
69 69 return -1;
70 70 }
71 71  
72   -static char udbg_550_getc(void)
  72 +static int udbg_550_getc(void)
73 73 {
74 74 if (udbg_comport) {
75 75 while ((in_8(&udbg_comport->lsr) & LSR_DR) == 0)
76 76 /* wait for char */;
77 77 return in_8(&udbg_comport->rbr);
78 78 }
79   - return 0;
  79 + return -1;
80 80 }
81 81  
82 82 void udbg_init_uart(void __iomem *comport, unsigned int speed,
arch/powerpc/platforms/powermac/udbg_adb.c
... ... @@ -29,7 +29,7 @@
29 29 */
30 30  
31 31 static void (*udbg_adb_old_putc)(char c);
32   -static char (*udbg_adb_old_getc)(void);
  32 +static int (*udbg_adb_old_getc)(void);
33 33 static int (*udbg_adb_old_getc_poll)(void);
34 34  
35 35 static enum {
... ... @@ -73,7 +73,7 @@
73 73 "\0.\0*\0+\0\0\0\0\0/\r\0-\0" /* 0x40 - 0x4f */
74 74 "\0\0000123456789\0\0\0"; /* 0x50 - 0x5f */
75 75  
76   -static char udbg_adb_local_getc(void)
  76 +static int udbg_adb_local_getc(void)
77 77 {
78 78 int k, t, on;
79 79  
... ... @@ -116,7 +116,7 @@
116 116 }
117 117 #endif /* CONFIG_BOOTX_TEXT */
118 118  
119   -static char udbg_adb_getc(void)
  119 +static int udbg_adb_getc(void)
120 120 {
121 121 #ifdef CONFIG_BOOTX_TEXT
122 122 if (udbg_adb_use_btext && input_type != input_adb_none)
... ... @@ -195,7 +195,7 @@
195 195 */
196 196 for (np = NULL; (np = of_find_node_by_name(np, "keyboard")) != NULL;) {
197 197 struct device_node *parent = of_get_parent(np);
198   - int found = (parent && !strcmp(parent->type, "adb") == 0);
  198 + int found = (parent && strcmp(parent->type, "adb") == 0);
199 199 of_node_put(parent);
200 200 if (found)
201 201 break;
arch/powerpc/platforms/powermac/udbg_scc.c
... ... @@ -47,14 +47,14 @@
47 47 return -1;
48 48 }
49 49  
50   -static char udbg_scc_getc(void)
  50 +static int udbg_scc_getc(void)
51 51 {
52 52 if (sccc) {
53 53 while ((in_8(sccc) & SCC_RXRDY) == 0)
54 54 ;
55 55 return in_8(sccd);
56 56 }
57   - return 0;
  57 + return -1;
58 58 }
59 59  
60 60 static unsigned char scc_inittab[] = {
arch/powerpc/platforms/pseries/lpar.c
... ... @@ -112,7 +112,7 @@
112 112 return ch;
113 113 }
114 114  
115   -static char udbg_hvsi_getc(void)
  115 +static int udbg_hvsi_getc(void)
116 116 {
117 117 int ch;
118 118 for (;;) {
... ... @@ -173,7 +173,7 @@
173 173 return ch;
174 174 }
175 175  
176   -static char udbg_getcLP(void)
  176 +static int udbg_getcLP(void)
177 177 {
178 178 int ch;
179 179 for (;;) {
arch/powerpc/xmon/xmon.c
... ... @@ -450,7 +450,6 @@
450 450 leave:
451 451 cpu_clear(cpu, cpus_in_xmon);
452 452 xmon_fault_jmp[cpu] = NULL;
453   -
454 453 #else
455 454 /* UP is simple... */
456 455 if (in_xmon) {
457 456  
... ... @@ -805,7 +804,10 @@
805 804 break;
806 805 case 'x':
807 806 case 'X':
  807 + return cmd;
808 808 case EOF:
  809 + printf(" <no input ...>\n");
  810 + mdelay(2000);
809 811 return cmd;
810 812 case '?':
811 813 printf(help_string);
drivers/macintosh/via-pmu.c
... ... @@ -313,7 +313,7 @@
313 313 goto fail;
314 314 }
315 315 taddr = of_translate_address(vias, reg);
316   - if (taddr == 0) {
  316 + if (taddr == OF_BAD_ADDR) {
317 317 printk(KERN_ERR "via-pmu: Can't translate address !\n");
318 318 goto fail;
319 319 }
... ... @@ -376,7 +376,7 @@
376 376 return 0;
377 377 }
378 378  
379   - printk(KERN_INFO "PMU driver %d initialized for %s, firmware: %02x\n",
  379 + printk(KERN_INFO "PMU driver v%d initialized for %s, firmware: %02x\n",
380 380 PMU_DRIVER_VERSION, pbook_type[pmu_kind], pmu_version);
381 381  
382 382 sys_ctrler = SYS_CTRLER_PMU;
include/asm-powerpc/udbg.h
... ... @@ -14,7 +14,7 @@
14 14 #include <linux/init.h>
15 15  
16 16 extern void (*udbg_putc)(char c);
17   -extern char (*udbg_getc)(void);
  17 +extern int (*udbg_getc)(void);
18 18 extern int (*udbg_getc_poll)(void);
19 19  
20 20 extern void udbg_puts(const char *s);