Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alan Cox and committed by
Greg Kroah-Hartman
6ed847d8 baaa08ac

+12 -30
+11 -30
drivers/char/isicom.c
··· 793 793 { 794 794 int channel; 795 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 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 } 805 + 806 + /* Activate and thus setup board are protected from races against shutdown 807 + by the tty_port mutex */ 810 808 811 809 static int isicom_activate(struct tty_port *tport, struct tty_struct *tty) 812 810 { ··· 882 884 883 885 /* close et all */ 884 886 885 - static inline void isicom_shutdown_board(struct isi_board *bp) 886 - { 887 - if (bp->status & BOARD_ACTIVE) 888 - bp->status &= ~BOARD_ACTIVE; 889 - } 890 - 891 887 /* card->lock HAS to be held */ 892 888 static void isicom_shutdown_port(struct isi_port *port) 893 889 { 894 890 struct isi_board *card = port->card; 895 - struct tty_struct *tty; 896 - 897 - tty = tty_port_tty_get(&port->port); 898 891 899 892 tty_port_free_xmit_buf(&port->port); 900 893 if (--card->count < 0) { ··· 893 904 card->base, card->count); 894 905 card->count = 0; 895 906 } 896 - 897 907 /* last port was closed, shutdown that board too */ 898 - if (tty && C_HUPCL(tty)) { 899 - /* FIXME: this logic is bogus - it's the old logic that was 900 - bogus before but it still wants fixing */ 901 - if (!card->count) { 902 - if (card->status & BOARD_ACTIVE) 903 - card->status &= ~BOARD_ACTIVE; 904 - } 905 - } 906 - tty_kref_put(tty); 908 + if (!card->count) 909 + card->status &= BOARD_ACTIVE; 907 910 } 908 911 909 912 static void isicom_flush_buffer(struct tty_struct *tty)
+1
include/linux/isicom.h
··· 67 67 68 68 #define FIRMWARE_LOADED 0x0001 69 69 #define BOARD_ACTIVE 0x0002 70 + #define BOARD_INIT 0x0004 70 71 71 72 /* isi_port status bitmap */ 72 73