diff options
Diffstat (limited to 'arch/um/drivers/line.c')
-rw-r--r-- | arch/um/drivers/line.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index f1b38571f94e..be541cf69fd2 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c | |||
@@ -305,7 +305,7 @@ static int line_activate(struct tty_port *port, struct tty_struct *tty) | |||
305 | return ret; | 305 | return ret; |
306 | 306 | ||
307 | if (!line->sigio) { | 307 | if (!line->sigio) { |
308 | chan_enable_winch(line->chan_out, tty); | 308 | chan_enable_winch(line->chan_out, port); |
309 | line->sigio = 1; | 309 | line->sigio = 1; |
310 | } | 310 | } |
311 | 311 | ||
@@ -315,8 +315,22 @@ static int line_activate(struct tty_port *port, struct tty_struct *tty) | |||
315 | return 0; | 315 | return 0; |
316 | } | 316 | } |
317 | 317 | ||
318 | static void unregister_winch(struct tty_struct *tty); | ||
319 | |||
320 | static void line_destruct(struct tty_port *port) | ||
321 | { | ||
322 | struct tty_struct *tty = tty_port_tty_get(port); | ||
323 | struct line *line = tty->driver_data; | ||
324 | |||
325 | if (line->sigio) { | ||
326 | unregister_winch(tty); | ||
327 | line->sigio = 0; | ||
328 | } | ||
329 | } | ||
330 | |||
318 | static const struct tty_port_operations line_port_ops = { | 331 | static const struct tty_port_operations line_port_ops = { |
319 | .activate = line_activate, | 332 | .activate = line_activate, |
333 | .destruct = line_destruct, | ||
320 | }; | 334 | }; |
321 | 335 | ||
322 | int line_open(struct tty_struct *tty, struct file *filp) | 336 | int line_open(struct tty_struct *tty, struct file *filp) |
@@ -340,18 +354,6 @@ int line_install(struct tty_driver *driver, struct tty_struct *tty, | |||
340 | return 0; | 354 | return 0; |
341 | } | 355 | } |
342 | 356 | ||
343 | static void unregister_winch(struct tty_struct *tty); | ||
344 | |||
345 | void line_cleanup(struct tty_struct *tty) | ||
346 | { | ||
347 | struct line *line = tty->driver_data; | ||
348 | |||
349 | if (line->sigio) { | ||
350 | unregister_winch(tty); | ||
351 | line->sigio = 0; | ||
352 | } | ||
353 | } | ||
354 | |||
355 | void line_close(struct tty_struct *tty, struct file * filp) | 357 | void line_close(struct tty_struct *tty, struct file * filp) |
356 | { | 358 | { |
357 | struct line *line = tty->driver_data; | 359 | struct line *line = tty->driver_data; |
@@ -601,7 +603,7 @@ struct winch { | |||
601 | int fd; | 603 | int fd; |
602 | int tty_fd; | 604 | int tty_fd; |
603 | int pid; | 605 | int pid; |
604 | struct tty_struct *tty; | 606 | struct tty_port *port; |
605 | unsigned long stack; | 607 | unsigned long stack; |
606 | struct work_struct work; | 608 | struct work_struct work; |
607 | }; | 609 | }; |
@@ -655,7 +657,7 @@ static irqreturn_t winch_interrupt(int irq, void *data) | |||
655 | goto out; | 657 | goto out; |
656 | } | 658 | } |
657 | } | 659 | } |
658 | tty = winch->tty; | 660 | tty = tty_port_tty_get(winch->port); |
659 | if (tty != NULL) { | 661 | if (tty != NULL) { |
660 | line = tty->driver_data; | 662 | line = tty->driver_data; |
661 | if (line != NULL) { | 663 | if (line != NULL) { |
@@ -663,6 +665,7 @@ static irqreturn_t winch_interrupt(int irq, void *data) | |||
663 | &tty->winsize.ws_col); | 665 | &tty->winsize.ws_col); |
664 | kill_pgrp(tty->pgrp, SIGWINCH, 1); | 666 | kill_pgrp(tty->pgrp, SIGWINCH, 1); |
665 | } | 667 | } |
668 | tty_kref_put(tty); | ||
666 | } | 669 | } |
667 | out: | 670 | out: |
668 | if (winch->fd != -1) | 671 | if (winch->fd != -1) |
@@ -670,7 +673,7 @@ static irqreturn_t winch_interrupt(int irq, void *data) | |||
670 | return IRQ_HANDLED; | 673 | return IRQ_HANDLED; |
671 | } | 674 | } |
672 | 675 | ||
673 | void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty, | 676 | void register_winch_irq(int fd, int tty_fd, int pid, struct tty_port *port, |
674 | unsigned long stack) | 677 | unsigned long stack) |
675 | { | 678 | { |
676 | struct winch *winch; | 679 | struct winch *winch; |
@@ -685,7 +688,7 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty, | |||
685 | .fd = fd, | 688 | .fd = fd, |
686 | .tty_fd = tty_fd, | 689 | .tty_fd = tty_fd, |
687 | .pid = pid, | 690 | .pid = pid, |
688 | .tty = tty, | 691 | .port = port, |
689 | .stack = stack }); | 692 | .stack = stack }); |
690 | 693 | ||
691 | if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt, | 694 | if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt, |
@@ -714,15 +717,18 @@ static void unregister_winch(struct tty_struct *tty) | |||
714 | { | 717 | { |
715 | struct list_head *ele, *next; | 718 | struct list_head *ele, *next; |
716 | struct winch *winch; | 719 | struct winch *winch; |
720 | struct tty_struct *wtty; | ||
717 | 721 | ||
718 | spin_lock(&winch_handler_lock); | 722 | spin_lock(&winch_handler_lock); |
719 | 723 | ||
720 | list_for_each_safe(ele, next, &winch_handlers) { | 724 | list_for_each_safe(ele, next, &winch_handlers) { |
721 | winch = list_entry(ele, struct winch, list); | 725 | winch = list_entry(ele, struct winch, list); |
722 | if (winch->tty == tty) { | 726 | wtty = tty_port_tty_get(winch->port); |
727 | if (wtty == tty) { | ||
723 | free_winch(winch); | 728 | free_winch(winch); |
724 | break; | 729 | break; |
725 | } | 730 | } |
731 | tty_kref_put(wtty); | ||
726 | } | 732 | } |
727 | spin_unlock(&winch_handler_lock); | 733 | spin_unlock(&winch_handler_lock); |
728 | } | 734 | } |