aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2005-06-23 03:10:32 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-23 12:45:35 -0400
commitbfb07599da289881d3bcbb601a110e997fc7444b (patch)
tree601c5e683c87e103de37bd68f014ec1f57d09bc7 /drivers
parent790a19cd5711133f40daad7c55bf148de2b1d12c (diff)
[PATCH] Introduce tty_unregister_ldisc()
It's a bit strange to see tty_register_ldisc call in modules' exit functions. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/tty_io.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 31831030f73f..cc4b43bad703 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -251,7 +251,7 @@ static void tty_set_termios_ldisc(struct tty_struct *tty, int num)
251 251
252static DEFINE_SPINLOCK(tty_ldisc_lock); 252static DEFINE_SPINLOCK(tty_ldisc_lock);
253static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait); 253static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait);
254static struct tty_ldisc tty_ldiscs[NR_LDISCS]; /* line disc dispatch table */ 254static struct tty_ldisc tty_ldiscs[NR_LDISCS]; /* line disc dispatch table */
255 255
256int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc) 256int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc)
257{ 257{
@@ -262,24 +262,35 @@ int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc)
262 return -EINVAL; 262 return -EINVAL;
263 263
264 spin_lock_irqsave(&tty_ldisc_lock, flags); 264 spin_lock_irqsave(&tty_ldisc_lock, flags);
265 if (new_ldisc) { 265 tty_ldiscs[disc] = *new_ldisc;
266 tty_ldiscs[disc] = *new_ldisc; 266 tty_ldiscs[disc].num = disc;
267 tty_ldiscs[disc].num = disc; 267 tty_ldiscs[disc].flags |= LDISC_FLAG_DEFINED;
268 tty_ldiscs[disc].flags |= LDISC_FLAG_DEFINED; 268 tty_ldiscs[disc].refcount = 0;
269 tty_ldiscs[disc].refcount = 0;
270 } else {
271 if(tty_ldiscs[disc].refcount)
272 ret = -EBUSY;
273 else
274 tty_ldiscs[disc].flags &= ~LDISC_FLAG_DEFINED;
275 }
276 spin_unlock_irqrestore(&tty_ldisc_lock, flags); 269 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
277 270
278 return ret; 271 return ret;
279} 272}
280
281EXPORT_SYMBOL(tty_register_ldisc); 273EXPORT_SYMBOL(tty_register_ldisc);
282 274
275int tty_unregister_ldisc(int disc)
276{
277 unsigned long flags;
278 int ret = 0;
279
280 if (disc < N_TTY || disc >= NR_LDISCS)
281 return -EINVAL;
282
283 spin_lock_irqsave(&tty_ldisc_lock, flags);
284 if (tty_ldiscs[disc].refcount)
285 ret = -EBUSY;
286 else
287 tty_ldiscs[disc].flags &= ~LDISC_FLAG_DEFINED;
288 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
289
290 return ret;
291}
292EXPORT_SYMBOL(tty_unregister_ldisc);
293
283struct tty_ldisc *tty_ldisc_get(int disc) 294struct tty_ldisc *tty_ldisc_get(int disc)
284{ 295{
285 unsigned long flags; 296 unsigned long flags;