aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/hvc_rtas.c
diff options
context:
space:
mode:
authorMichael Ellerman <michael@ellerman.id.au>2006-06-07 03:10:09 -0400
committerPaul Mackerras <paulus@samba.org>2006-06-09 07:24:20 -0400
commit6b81e80049a8815dc457fec4dadb6ae535c3b988 (patch)
tree410158801f1ed00ad6011d34da1fd23d9e9edb40 /drivers/char/hvc_rtas.c
parentb53744612f276ad20c5d7ef33ac991ec13101417 (diff)
[PATCH] powerpc: Cleanup hvc_rtas.c a little
A few cleanups in hvc_rtas.c: 1. Remove unused RTASCONS_PUT_ATTEMPTS 2. Remove unused rtascons_put_delay. 3. Use i as a loop counter like everyone else on earth. 4. Remove pointless variables, eg. x = foo; if (x) return something_else; 5. Whitespace cleanups and formatting. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'drivers/char/hvc_rtas.c')
-rw-r--r--drivers/char/hvc_rtas.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/drivers/char/hvc_rtas.c b/drivers/char/hvc_rtas.c
index 83364ea63cba..57106e02fd2e 100644
--- a/drivers/char/hvc_rtas.c
+++ b/drivers/char/hvc_rtas.c
@@ -41,37 +41,28 @@
41#define hvc_rtas_cookie 0x67781e15 41#define hvc_rtas_cookie 0x67781e15
42struct hvc_struct *hvc_rtas_dev; 42struct hvc_struct *hvc_rtas_dev;
43 43
44#define RTASCONS_PUT_ATTEMPTS 16
45
46static int rtascons_put_char_token = RTAS_UNKNOWN_SERVICE; 44static int rtascons_put_char_token = RTAS_UNKNOWN_SERVICE;
47static int rtascons_get_char_token = RTAS_UNKNOWN_SERVICE; 45static int rtascons_get_char_token = RTAS_UNKNOWN_SERVICE;
48static int rtascons_put_delay = 100;
49module_param_named(put_delay, rtascons_put_delay, int, 0644);
50 46
51static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf, int count) 47static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf,
48 int count)
52{ 49{
53 int done; 50 int i;
54 51
55 /* if there is more than one character to be displayed, wait a bit */ 52 for (i = 0; i < count; i++) {
56 for (done = 0; done < count; done++) { 53 if (rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[i]))
57 int result;
58 result = rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[done]);
59 if (result)
60 break; 54 break;
61 } 55 }
62 /* the calling routine expects to receive the number of bytes sent */ 56
63 return done; 57 return i;
64} 58}
65 59
66static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count) 60static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count)
67{ 61{
68 int i; 62 int i, c;
69 63
70 for (i = 0; i < count; i++) { 64 for (i = 0; i < count; i++) {
71 int c, err; 65 if (rtas_call(rtascons_get_char_token, 0, 2, &c))
72
73 err = rtas_call(rtascons_get_char_token, 0, 2, &c);
74 if (err)
75 break; 66 break;
76 67
77 buf[i] = c; 68 buf[i] = c;
@@ -106,7 +97,9 @@ static int hvc_rtas_init(void)
106 hp = hvc_alloc(hvc_rtas_cookie, NO_IRQ, &hvc_rtas_get_put_ops); 97 hp = hvc_alloc(hvc_rtas_cookie, NO_IRQ, &hvc_rtas_get_put_ops);
107 if (IS_ERR(hp)) 98 if (IS_ERR(hp))
108 return PTR_ERR(hp); 99 return PTR_ERR(hp);
100
109 hvc_rtas_dev = hp; 101 hvc_rtas_dev = hp;
102
110 return 0; 103 return 0;
111} 104}
112module_init(hvc_rtas_init); 105module_init(hvc_rtas_init);
@@ -114,8 +107,8 @@ module_init(hvc_rtas_init);
114/* This will tear down the tty portion of the driver */ 107/* This will tear down the tty portion of the driver */
115static void __exit hvc_rtas_exit(void) 108static void __exit hvc_rtas_exit(void)
116{ 109{
117 /* Really the fun isn't over until the worker thread breaks down and the 110 /* Really the fun isn't over until the worker thread breaks down and
118 * tty cleans up */ 111 * the tty cleans up */
119 if (hvc_rtas_dev) 112 if (hvc_rtas_dev)
120 hvc_remove(hvc_rtas_dev); 113 hvc_remove(hvc_rtas_dev);
121} 114}
@@ -127,12 +120,14 @@ static int hvc_rtas_console_init(void)
127 rtascons_put_char_token = rtas_token("put-term-char"); 120 rtascons_put_char_token = rtas_token("put-term-char");
128 if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE) 121 if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
129 return -EIO; 122 return -EIO;
123
130 rtascons_get_char_token = rtas_token("get-term-char"); 124 rtascons_get_char_token = rtas_token("get-term-char");
131 if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE) 125 if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE)
132 return -EIO; 126 return -EIO;
133 127
134 hvc_instantiate(hvc_rtas_cookie, 0, &hvc_rtas_get_put_ops ); 128 hvc_instantiate(hvc_rtas_cookie, 0, &hvc_rtas_get_put_ops);
135 add_preferred_console("hvc", 0, NULL); 129 add_preferred_console("hvc", 0, NULL);
130
136 return 0; 131 return 0;
137} 132}
138console_initcall(hvc_rtas_console_init); 133console_initcall(hvc_rtas_console_init);