Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ed847d8 authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman
Browse files

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: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent baaa08ac
Loading
Loading
Loading
Loading
+11 −30
Original line number Original line Diff line number Diff line
@@ -793,20 +793,18 @@ static inline void isicom_setup_board(struct isi_board *bp)
{
{
	int channel;
	int channel;
	struct isi_port *port;
	struct isi_port *port;
	unsigned long flags;


	spin_lock_irqsave(&bp->card_lock, flags);
	bp->count++;
	if (bp->status & BOARD_ACTIVE) {
	if (!(bp->status & BOARD_INIT)) {
		spin_unlock_irqrestore(&bp->card_lock, flags);
		return;
	}
		port = bp->ports;
		port = bp->ports;
	bp->status |= BOARD_ACTIVE;
		for (channel = 0; channel < bp->port_count; channel++, port++)
		for (channel = 0; channel < bp->port_count; channel++, port++)
			drop_dtr_rts(port);
			drop_dtr_rts(port);
	bp->count++;
	spin_unlock_irqrestore(&bp->card_lock, flags);
	}
	}
	bp->status |= BOARD_ACTIVE | BOARD_INIT;
}

/* Activate and thus setup board are protected from races against shutdown
   by the tty_port mutex */


static int isicom_activate(struct tty_port *tport, struct tty_struct *tty)
static int isicom_activate(struct tty_port *tport, struct tty_struct *tty)
{
{
@@ -884,19 +882,10 @@ static int isicom_open(struct tty_struct *tty, struct file *filp)


/* close et all */
/* close et all */


static inline void isicom_shutdown_board(struct isi_board *bp)
{
	if (bp->status & BOARD_ACTIVE)
		bp->status &= ~BOARD_ACTIVE;
}

/* card->lock HAS to be held */
/* card->lock HAS to be held */
static void isicom_shutdown_port(struct isi_port *port)
static void isicom_shutdown_port(struct isi_port *port)
{
{
	struct isi_board *card = port->card;
	struct isi_board *card = port->card;
	struct tty_struct *tty;

	tty = tty_port_tty_get(&port->port);


	tty_port_free_xmit_buf(&port->port);
	tty_port_free_xmit_buf(&port->port);
	if (--card->count < 0) {
	if (--card->count < 0) {
@@ -904,17 +893,9 @@ static void isicom_shutdown_port(struct isi_port *port)
			card->base, card->count);
			card->base, card->count);
		card->count = 0;
		card->count = 0;
	}
	}

	/* last port was closed, shutdown that board too */
	/* last port was closed, shutdown that board too */
	if (tty && C_HUPCL(tty)) {
	if (!card->count)
		/* FIXME: this logic is bogus - it's the old logic that was
		card->status &= BOARD_ACTIVE;
		   bogus before but it still wants fixing */
		if (!card->count) {
			if (card->status & BOARD_ACTIVE)
				card->status &= ~BOARD_ACTIVE;
		}
	}
	tty_kref_put(tty);
}
}


static void isicom_flush_buffer(struct tty_struct *tty)
static void isicom_flush_buffer(struct tty_struct *tty)
+1 −0
Original line number Original line Diff line number Diff line
@@ -67,6 +67,7 @@


#define		FIRMWARE_LOADED		0x0001
#define		FIRMWARE_LOADED		0x0001
#define		BOARD_ACTIVE		0x0002
#define		BOARD_ACTIVE		0x0002
#define		BOARD_INIT		0x0004


 	/* isi_port status bitmap  */
 	/* isi_port status bitmap  */