aboutsummaryrefslogtreecommitdiffstats
path: root/arch/parisc/kernel/pdc_cons.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-03-05 08:52:53 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 15:51:13 -0500
commit5dd5bc40f3b6e0ccdaad948dbadc94ad0906cb25 (patch)
tree8e2075f2da22a80ab39219e15c59769d5d8b5202 /arch/parisc/kernel/pdc_cons.c
parent0b479d54ae7b79f62f09ef977c2228e579924d38 (diff)
TTY: pdc_cons, use tty_port
Instead of digging a tty out of the tty_driver struct, which is not defined to work, use tty_port properly. This includes proper tty refcounting even though there is no possible race currently. But we will need tty_port for tty buffers in the future anyway. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Kyle McMartin <kyle@mcmartin.ca> Cc: Helge Deller <deller@gmx.de> Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/parisc/kernel/pdc_cons.c')
-rw-r--r--arch/parisc/kernel/pdc_cons.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index d14e20fc60df..4f004596a6e7 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -92,10 +92,11 @@ static int pdc_console_setup(struct console *co, char *options)
92 92
93static void pdc_console_poll(unsigned long unused); 93static void pdc_console_poll(unsigned long unused);
94static DEFINE_TIMER(pdc_console_timer, pdc_console_poll, 0, 0); 94static DEFINE_TIMER(pdc_console_timer, pdc_console_poll, 0, 0);
95static struct tty_port tty_port;
95 96
96static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp) 97static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
97{ 98{
98 99 tty_port_tty_set(&tty_port, tty);
99 mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY); 100 mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
100 101
101 return 0; 102 return 0;
@@ -103,8 +104,10 @@ static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
103 104
104static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp) 105static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp)
105{ 106{
106 if (!tty->count) 107 if (!tty->count) {
107 del_timer_sync(&pdc_console_timer); 108 del_timer_sync(&pdc_console_timer);
109 tty_port_tty_set(&tty_port, NULL);
110 }
108} 111}
109 112
110static int pdc_console_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) 113static int pdc_console_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
@@ -123,8 +126,6 @@ static int pdc_console_tty_chars_in_buffer(struct tty_struct *tty)
123 return 0; /* no buffer */ 126 return 0; /* no buffer */
124} 127}
125 128
126static struct tty_driver *pdc_console_tty_driver;
127
128static const struct tty_operations pdc_console_tty_ops = { 129static const struct tty_operations pdc_console_tty_ops = {
129 .open = pdc_console_tty_open, 130 .open = pdc_console_tty_open,
130 .close = pdc_console_tty_close, 131 .close = pdc_console_tty_close,
@@ -135,10 +136,8 @@ static const struct tty_operations pdc_console_tty_ops = {
135 136
136static void pdc_console_poll(unsigned long unused) 137static void pdc_console_poll(unsigned long unused)
137{ 138{
138
139 int data, count = 0; 139 int data, count = 0;
140 140 struct tty_struct *tty = tty_port_tty_get(&tty_port);
141 struct tty_struct *tty = pdc_console_tty_driver->ttys[0];
142 141
143 if (!tty) 142 if (!tty)
144 return; 143 return;
@@ -154,10 +153,14 @@ static void pdc_console_poll(unsigned long unused)
154 if (count) 153 if (count)
155 tty_flip_buffer_push(tty); 154 tty_flip_buffer_push(tty);
156 155
156 tty_kref_put(tty);
157
157 if (pdc_cons.flags & CON_ENABLED) 158 if (pdc_cons.flags & CON_ENABLED)
158 mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY); 159 mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
159} 160}
160 161
162static struct tty_driver *pdc_console_tty_driver;
163
161static int __init pdc_console_tty_driver_init(void) 164static int __init pdc_console_tty_driver_init(void)
162{ 165{
163 int err; 166 int err;
@@ -182,6 +185,8 @@ static int __init pdc_console_tty_driver_init(void)
182 printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n"); 185 printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n");
183 pdc_cons.flags &= ~CON_BOOT; 186 pdc_cons.flags &= ~CON_BOOT;
184 187
188 tty_port_init(&tty_port);
189
185 pdc_console_tty_driver = alloc_tty_driver(1); 190 pdc_console_tty_driver = alloc_tty_driver(1);
186 191
187 if (!pdc_console_tty_driver) 192 if (!pdc_console_tty_driver)