aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/hvc_console.c
diff options
context:
space:
mode:
authorMilton Miller <miltonm@bga.com>2005-07-07 20:56:25 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-07 21:23:39 -0400
commit030ffad23fb28fc29608a3bc21f0c3b88bf28592 (patch)
tree8fe8a2e8615e25e985c5658687d38c5c0ce7a971 /drivers/char/hvc_console.c
parentacad9559f1054487292eb10d7bb81f256e9d8f2d (diff)
[PATCH] hvc_console: Register ops when setting up hvc_console
When registering the hvc console port, register a list of ops (read and write) to go with it, instead of calling fixed function names. This allows different ports to encode the data differently. Signed-off-by: Milton Miller <miltonm@bga.com> Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/hvc_console.c')
-rw-r--r--drivers/char/hvc_console.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index df282cc9a7ab..cddb789902db 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -85,6 +85,7 @@ struct hvc_struct {
85 char outbuf[N_OUTBUF] __ALIGNED__; 85 char outbuf[N_OUTBUF] __ALIGNED__;
86 int n_outbuf; 86 int n_outbuf;
87 uint32_t vtermno; 87 uint32_t vtermno;
88 struct hv_ops *ops;
88 int irq_requested; 89 int irq_requested;
89 int irq; 90 int irq;
90 struct list_head next; 91 struct list_head next;
@@ -142,6 +143,7 @@ struct hvc_struct *hvc_get_by_index(int index)
142 * console interfaces but can still be used as a tty device. This has to be 143 * console interfaces but can still be used as a tty device. This has to be
143 * static because kmalloc will not work during early console init. 144 * static because kmalloc will not work during early console init.
144 */ 145 */
146static struct hv_ops *cons_ops[MAX_NR_HVC_CONSOLES];
145static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] = 147static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] =
146 {[0 ... MAX_NR_HVC_CONSOLES - 1] = -1}; 148 {[0 ... MAX_NR_HVC_CONSOLES - 1] = -1};
147 149
@@ -154,14 +156,14 @@ void hvc_console_print(struct console *co, const char *b, unsigned count)
154{ 156{
155 char c[16] __ALIGNED__; 157 char c[16] __ALIGNED__;
156 unsigned i = 0, n = 0; 158 unsigned i = 0, n = 0;
157 int r, donecr = 0; 159 int r, donecr = 0, index = co->index;
158 160
159 /* Console access attempt outside of acceptable console range. */ 161 /* Console access attempt outside of acceptable console range. */
160 if (co->index >= MAX_NR_HVC_CONSOLES) 162 if (index >= MAX_NR_HVC_CONSOLES)
161 return; 163 return;
162 164
163 /* This console adapter was removed so it is not useable. */ 165 /* This console adapter was removed so it is not useable. */
164 if (vtermnos[co->index] < 0) 166 if (vtermnos[index] < 0)
165 return; 167 return;
166 168
167 while (count > 0 || i > 0) { 169 while (count > 0 || i > 0) {
@@ -175,7 +177,7 @@ void hvc_console_print(struct console *co, const char *b, unsigned count)
175 --count; 177 --count;
176 } 178 }
177 } else { 179 } else {
178 r = hvc_put_chars(vtermnos[co->index], c, i); 180 r = cons_ops[index]->put_chars(vtermnos[index], c, i);
179 if (r < 0) { 181 if (r < 0) {
180 /* throw away chars on error */ 182 /* throw away chars on error */
181 i = 0; 183 i = 0;
@@ -245,7 +247,7 @@ console_initcall(hvc_console_init);
245 * vty adapters do NOT get an hvc_instantiate() callback since they 247 * vty adapters do NOT get an hvc_instantiate() callback since they
246 * appear after early console init. 248 * appear after early console init.
247 */ 249 */
248int hvc_instantiate(uint32_t vtermno, int index) 250int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops)
249{ 251{
250 struct hvc_struct *hp; 252 struct hvc_struct *hp;
251 253
@@ -263,6 +265,7 @@ int hvc_instantiate(uint32_t vtermno, int index)
263 } 265 }
264 266
265 vtermnos[index] = vtermno; 267 vtermnos[index] = vtermno;
268 cons_ops[index] = ops;
266 269
267 /* reserve all indices upto and including this index */ 270 /* reserve all indices upto and including this index */
268 if (last_hvc < index) 271 if (last_hvc < index)
@@ -466,7 +469,7 @@ static void hvc_push(struct hvc_struct *hp)
466{ 469{
467 int n; 470 int n;
468 471
469 n = hvc_put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf); 472 n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf);
470 if (n <= 0) { 473 if (n <= 0) {
471 if (n == 0) 474 if (n == 0)
472 return; 475 return;
@@ -604,7 +607,7 @@ static int hvc_poll(struct hvc_struct *hp)
604 break; 607 break;
605 } 608 }
606 609
607 n = hvc_get_chars(hp->vtermno, buf, count); 610 n = hp->ops->get_chars(hp->vtermno, buf, count);
608 if (n <= 0) { 611 if (n <= 0) {
609 /* Hangup the tty when disconnected from host */ 612 /* Hangup the tty when disconnected from host */
610 if (n == -EPIPE) { 613 if (n == -EPIPE) {
@@ -737,7 +740,8 @@ static struct kobj_type hvc_kobj_type = {
737 .release = destroy_hvc_struct, 740 .release = destroy_hvc_struct,
738}; 741};
739 742
740struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq) 743struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq,
744 struct hv_ops *ops)
741{ 745{
742 struct hvc_struct *hp; 746 struct hvc_struct *hp;
743 int i; 747 int i;
@@ -750,6 +754,7 @@ struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq)
750 754
751 hp->vtermno = vtermno; 755 hp->vtermno = vtermno;
752 hp->irq = irq; 756 hp->irq = irq;
757 hp->ops = ops;
753 758
754 kobject_init(&hp->kobj); 759 kobject_init(&hp->kobj);
755 hp->kobj.ktype = &hvc_kobj_type; 760 hp->kobj.ktype = &hvc_kobj_type;