floppy: make controller const
[linux/fpc-iii.git] / drivers / char / hvc_udbg.c
blobb0957e61a7befc015fb05adf587e32d48626edea
1 /*
2 * udbg interface to hvc_console.c
4 * (C) Copyright David Gibson, IBM Corporation 2008.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <linux/console.h>
22 #include <linux/delay.h>
23 #include <linux/err.h>
24 #include <linux/init.h>
25 #include <linux/moduleparam.h>
26 #include <linux/types.h>
27 #include <linux/irq.h>
29 #include <asm/udbg.h>
31 #include "hvc_console.h"
33 struct hvc_struct *hvc_udbg_dev;
35 static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count)
37 int i;
39 for (i = 0; i < count; i++)
40 udbg_putc(buf[i]);
42 return i;
45 static int hvc_udbg_get(uint32_t vtermno, char *buf, int count)
47 int i, c;
49 if (!udbg_getc_poll)
50 return 0;
52 for (i = 0; i < count; i++) {
53 if ((c = udbg_getc_poll()) == -1)
54 break;
55 buf[i] = c;
58 return i;
61 static const struct hv_ops hvc_udbg_ops = {
62 .get_chars = hvc_udbg_get,
63 .put_chars = hvc_udbg_put,
66 static int __init hvc_udbg_init(void)
68 struct hvc_struct *hp;
70 BUG_ON(hvc_udbg_dev);
72 hp = hvc_alloc(0, NO_IRQ, &hvc_udbg_ops, 16);
73 if (IS_ERR(hp))
74 return PTR_ERR(hp);
76 hvc_udbg_dev = hp;
78 return 0;
80 module_init(hvc_udbg_init);
82 static void __exit hvc_udbg_exit(void)
84 if (hvc_udbg_dev)
85 hvc_remove(hvc_udbg_dev);
87 module_exit(hvc_udbg_exit);
89 static int __init hvc_udbg_console_init(void)
91 hvc_instantiate(0, 0, &hvc_udbg_ops);
92 add_preferred_console("hvc", 0, NULL);
94 return 0;
96 console_initcall(hvc_udbg_console_init);