diff options
author | Alan Cox <alan@linux.intel.com> | 2009-11-30 08:17:30 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-11 18:18:07 -0500 |
commit | 6ed847d8efd08658ece10c9129cd511c8d7452cd (patch) | |
tree | 9c32476496a46fa6671ac212324a11b177578a67 /drivers/char/isicom.c | |
parent | baaa08acb0ca2df47830b58b5df8b9059cf9ddd2 (diff) |
tty: isicom: sort out the board init logic
Split this into two flags - INIT meaning the board is set up and ACTIVE
meaning the board has ports open. Remove the broken HUPCL casing and push
the counts somewhere sensible.
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char/isicom.c')
-rw-r--r-- | drivers/char/isicom.c | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c index e7be3ec6d21c..1e91c302ee42 100644 --- a/drivers/char/isicom.c +++ b/drivers/char/isicom.c | |||
@@ -793,21 +793,19 @@ static inline void isicom_setup_board(struct isi_board *bp) | |||
793 | { | 793 | { |
794 | int channel; | 794 | int channel; |
795 | struct isi_port *port; | 795 | struct isi_port *port; |
796 | unsigned long flags; | ||
797 | 796 | ||
798 | spin_lock_irqsave(&bp->card_lock, flags); | ||
799 | if (bp->status & BOARD_ACTIVE) { | ||
800 | spin_unlock_irqrestore(&bp->card_lock, flags); | ||
801 | return; | ||
802 | } | ||
803 | port = bp->ports; | ||
804 | bp->status |= BOARD_ACTIVE; | ||
805 | for (channel = 0; channel < bp->port_count; channel++, port++) | ||
806 | drop_dtr_rts(port); | ||
807 | bp->count++; | 797 | bp->count++; |
808 | spin_unlock_irqrestore(&bp->card_lock, flags); | 798 | if (!(bp->status & BOARD_INIT)) { |
799 | port = bp->ports; | ||
800 | for (channel = 0; channel < bp->port_count; channel++, port++) | ||
801 | drop_dtr_rts(port); | ||
802 | } | ||
803 | bp->status |= BOARD_ACTIVE | BOARD_INIT; | ||
809 | } | 804 | } |
810 | 805 | ||
806 | /* Activate and thus setup board are protected from races against shutdown | ||
807 | by the tty_port mutex */ | ||
808 | |||
811 | static int isicom_activate(struct tty_port *tport, struct tty_struct *tty) | 809 | static int isicom_activate(struct tty_port *tport, struct tty_struct *tty) |
812 | { | 810 | { |
813 | struct isi_port *port = container_of(tport, struct isi_port, port); | 811 | struct isi_port *port = container_of(tport, struct isi_port, port); |
@@ -884,19 +882,10 @@ static int isicom_open(struct tty_struct *tty, struct file *filp) | |||
884 | 882 | ||
885 | /* close et all */ | 883 | /* close et all */ |
886 | 884 | ||
887 | static inline void isicom_shutdown_board(struct isi_board *bp) | ||
888 | { | ||
889 | if (bp->status & BOARD_ACTIVE) | ||
890 | bp->status &= ~BOARD_ACTIVE; | ||
891 | } | ||
892 | |||
893 | /* card->lock HAS to be held */ | 885 | /* card->lock HAS to be held */ |
894 | static void isicom_shutdown_port(struct isi_port *port) | 886 | static void isicom_shutdown_port(struct isi_port *port) |
895 | { | 887 | { |
896 | struct isi_board *card = port->card; | 888 | struct isi_board *card = port->card; |
897 | struct tty_struct *tty; | ||
898 | |||
899 | tty = tty_port_tty_get(&port->port); | ||
900 | 889 | ||
901 | tty_port_free_xmit_buf(&port->port); | 890 | tty_port_free_xmit_buf(&port->port); |
902 | if (--card->count < 0) { | 891 | if (--card->count < 0) { |
@@ -904,17 +893,9 @@ static void isicom_shutdown_port(struct isi_port *port) | |||
904 | card->base, card->count); | 893 | card->base, card->count); |
905 | card->count = 0; | 894 | card->count = 0; |
906 | } | 895 | } |
907 | |||
908 | /* last port was closed, shutdown that board too */ | 896 | /* last port was closed, shutdown that board too */ |
909 | if (tty && C_HUPCL(tty)) { | 897 | if (!card->count) |
910 | /* FIXME: this logic is bogus - it's the old logic that was | 898 | card->status &= BOARD_ACTIVE; |
911 | bogus before but it still wants fixing */ | ||
912 | if (!card->count) { | ||
913 | if (card->status & BOARD_ACTIVE) | ||
914 | card->status &= ~BOARD_ACTIVE; | ||
915 | } | ||
916 | } | ||
917 | tty_kref_put(tty); | ||
918 | } | 899 | } |
919 | 900 | ||
920 | static void isicom_flush_buffer(struct tty_struct *tty) | 901 | static void isicom_flush_buffer(struct tty_struct *tty) |