diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-03-05 08:51:59 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-03-08 14:42:21 -0500 |
commit | 54089d4cdc89732e65f968209d10aae542482c0c (patch) | |
tree | 4794ce3d78e77af45f91995182536b4bd7cfd320 /arch/alpha | |
parent | ee024d494ab75426bc77e0c053700915f0a1a16d (diff) |
TTY: srmcons, convert to use tty_port
This is needed because the tty buffer will become a tty_port member
later. That will help us to wipe out most of the races and checks for
the tty pointer in hot paths.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/alpha')
-rw-r--r-- | arch/alpha/kernel/srmcons.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c index 2c89ce5c9ab6..3ea809430eda 100644 --- a/arch/alpha/kernel/srmcons.c +++ b/arch/alpha/kernel/srmcons.c | |||
@@ -30,9 +30,8 @@ static int srm_is_registered_console = 0; | |||
30 | #define MAX_SRM_CONSOLE_DEVICES 1 /* only support 1 console device */ | 30 | #define MAX_SRM_CONSOLE_DEVICES 1 /* only support 1 console device */ |
31 | 31 | ||
32 | struct srmcons_private { | 32 | struct srmcons_private { |
33 | struct tty_struct *tty; | 33 | struct tty_port port; |
34 | struct timer_list timer; | 34 | struct timer_list timer; |
35 | spinlock_t lock; | ||
36 | } srmcons_singleton; | 35 | } srmcons_singleton; |
37 | 36 | ||
38 | typedef union _srmcons_result { | 37 | typedef union _srmcons_result { |
@@ -68,20 +67,21 @@ static void | |||
68 | srmcons_receive_chars(unsigned long data) | 67 | srmcons_receive_chars(unsigned long data) |
69 | { | 68 | { |
70 | struct srmcons_private *srmconsp = (struct srmcons_private *)data; | 69 | struct srmcons_private *srmconsp = (struct srmcons_private *)data; |
70 | struct tty_port *port = &srmconsp->port; | ||
71 | unsigned long flags; | 71 | unsigned long flags; |
72 | int incr = 10; | 72 | int incr = 10; |
73 | 73 | ||
74 | local_irq_save(flags); | 74 | local_irq_save(flags); |
75 | if (spin_trylock(&srmcons_callback_lock)) { | 75 | if (spin_trylock(&srmcons_callback_lock)) { |
76 | if (!srmcons_do_receive_chars(srmconsp->tty)) | 76 | if (!srmcons_do_receive_chars(port->tty)) |
77 | incr = 100; | 77 | incr = 100; |
78 | spin_unlock(&srmcons_callback_lock); | 78 | spin_unlock(&srmcons_callback_lock); |
79 | } | 79 | } |
80 | 80 | ||
81 | spin_lock(&srmconsp->lock); | 81 | spin_lock(&port->lock); |
82 | if (srmconsp->tty) | 82 | if (port->tty) |
83 | mod_timer(&srmconsp->timer, jiffies + incr); | 83 | mod_timer(&srmconsp->timer, jiffies + incr); |
84 | spin_unlock(&srmconsp->lock); | 84 | spin_unlock(&port->lock); |
85 | 85 | ||
86 | local_irq_restore(flags); | 86 | local_irq_restore(flags); |
87 | } | 87 | } |
@@ -157,18 +157,19 @@ static int | |||
157 | srmcons_open(struct tty_struct *tty, struct file *filp) | 157 | srmcons_open(struct tty_struct *tty, struct file *filp) |
158 | { | 158 | { |
159 | struct srmcons_private *srmconsp = &srmcons_singleton; | 159 | struct srmcons_private *srmconsp = &srmcons_singleton; |
160 | struct tty_port *port = &srmconsp->port; | ||
160 | unsigned long flags; | 161 | unsigned long flags; |
161 | 162 | ||
162 | spin_lock_irqsave(&srmconsp->lock, flags); | 163 | spin_lock_irqsave(&port->lock, flags); |
163 | 164 | ||
164 | if (!srmconsp->tty) { | 165 | if (!port->tty) { |
165 | tty->driver_data = srmconsp; | 166 | tty->driver_data = srmconsp; |
166 | 167 | tty->port = port; | |
167 | srmconsp->tty = tty; | 168 | port->tty = tty; /* XXX proper refcounting */ |
168 | mod_timer(&srmconsp->timer, jiffies + 10); | 169 | mod_timer(&srmconsp->timer, jiffies + 10); |
169 | } | 170 | } |
170 | 171 | ||
171 | spin_unlock_irqrestore(&srmconsp->lock, flags); | 172 | spin_unlock_irqrestore(&port->lock, flags); |
172 | 173 | ||
173 | return 0; | 174 | return 0; |
174 | } | 175 | } |
@@ -177,16 +178,17 @@ static void | |||
177 | srmcons_close(struct tty_struct *tty, struct file *filp) | 178 | srmcons_close(struct tty_struct *tty, struct file *filp) |
178 | { | 179 | { |
179 | struct srmcons_private *srmconsp = tty->driver_data; | 180 | struct srmcons_private *srmconsp = tty->driver_data; |
181 | struct tty_port *port = &srmconsp->port; | ||
180 | unsigned long flags; | 182 | unsigned long flags; |
181 | 183 | ||
182 | spin_lock_irqsave(&srmconsp->lock, flags); | 184 | spin_lock_irqsave(&port->lock, flags); |
183 | 185 | ||
184 | if (tty->count == 1) { | 186 | if (tty->count == 1) { |
185 | srmconsp->tty = NULL; | 187 | port->tty = NULL; |
186 | del_timer(&srmconsp->timer); | 188 | del_timer(&srmconsp->timer); |
187 | } | 189 | } |
188 | 190 | ||
189 | spin_unlock_irqrestore(&srmconsp->lock, flags); | 191 | spin_unlock_irqrestore(&port->lock, flags); |
190 | } | 192 | } |
191 | 193 | ||
192 | 194 | ||
@@ -203,7 +205,7 @@ static const struct tty_operations srmcons_ops = { | |||
203 | static int __init | 205 | static int __init |
204 | srmcons_init(void) | 206 | srmcons_init(void) |
205 | { | 207 | { |
206 | spin_lock_init(&srmcons_singleton.lock); | 208 | tty_port_init(&srmcons_singleton.port); |
207 | setup_timer(&srmcons_singleton.timer, srmcons_receive_chars, | 209 | setup_timer(&srmcons_singleton.timer, srmcons_receive_chars, |
208 | (unsigned long)&srmcons_singleton); | 210 | (unsigned long)&srmcons_singleton); |
209 | if (srm_is_registered_console) { | 211 | if (srm_is_registered_console) { |