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

Commit fcc8ac18 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds
Browse files

tty: Add carrier processing on close to the tty_port core



Some drivers implement this internally, others miss it out. Push the
behaviour into the core code as that way everyone will do it consistently.

Update the dtr rts method to raise or lower depending upon flags. Having a
single method in this style fits most of the implementations more cleanly than
two funtions.

We need this in place before we tackle the USB side

Signed-off-by: default avatarAlan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 65a29f60
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -745,7 +745,7 @@ static int epca_carrier_raised(struct tty_port *port)
	return 0;
}

static void epca_raise_dtr_rts(struct tty_port *port)
static void epca_dtr_rts(struct tty_port *port, int onoff)
{
}

@@ -925,7 +925,7 @@ static const struct tty_operations pc_ops = {

static const struct tty_port_operations epca_port_ops = {
	.carrier_raised = epca_carrier_raised,
	.raise_dtr_rts = epca_raise_dtr_rts,
	.dtr_rts = epca_dtr_rts,
};

static int info_open(struct tty_struct *tty, struct file *filp)
+13 −6
Original line number Diff line number Diff line
@@ -329,7 +329,7 @@ static inline void drop_rts(struct isi_port *port)

/* card->lock MUST NOT be held */

static void isicom_raise_dtr_rts(struct tty_port *port)
static void isicom_dtr_rts(struct tty_port *port, int on)
{
	struct isi_port *ip = container_of(port, struct isi_port, port);
	struct isi_board *card = ip->card;
@@ -339,10 +339,17 @@ static void isicom_raise_dtr_rts(struct tty_port *port)
	if (!lock_card(card))
		return;

	if (on) {
		outw(0x8000 | (channel << card->shift_count) | 0x02, base);
		outw(0x0f04, base);
		InterruptTheCard(base);
		ip->status |= (ISI_DTR | ISI_RTS);
	} else {
		outw(0x8000 | (channel << card->shift_count) | 0x02, base);
		outw(0x0C04, base);
		InterruptTheCard(base);
		ip->status &= ~(ISI_DTR | ISI_RTS);
	}
	unlock_card(card);
}

@@ -1339,7 +1346,7 @@ static const struct tty_operations isicom_ops = {

static const struct tty_port_operations isicom_port_ops = {
	.carrier_raised		= isicom_carrier_raised,
	.raise_dtr_rts		= isicom_raise_dtr_rts,
	.dtr_rts		= isicom_dtr_rts,
};

static int __devinit reset_card(struct pci_dev *pdev,
+4 −4
Original line number Diff line number Diff line
@@ -1140,14 +1140,14 @@ static int stli_carrier_raised(struct tty_port *port)
	return (portp->sigs & TIOCM_CD) ? 1 : 0;
}

static void stli_raise_dtr_rts(struct tty_port *port)
static void stli_dtr_rts(struct tty_port *port, int on)
{
	struct stliport *portp = container_of(port, struct stliport, port);
	struct stlibrd *brdp = stli_brds[portp->brdnr];
	stli_mkasysigs(&portp->asig, 1, 1);
	stli_mkasysigs(&portp->asig, on, on);
	if (stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig,
		sizeof(asysigs_t), 0) < 0)
			printk(KERN_WARNING "istallion: dtr raise failed.\n");
			printk(KERN_WARNING "istallion: dtr set failed.\n");
}


@@ -4417,7 +4417,7 @@ static const struct tty_operations stli_ops = {

static const struct tty_port_operations stli_port_ops = {
	.carrier_raised = stli_carrier_raised,
	.raise_dtr_rts = stli_raise_dtr_rts,
	.dtr_rts = stli_dtr_rts,
};

/*****************************************************************************/
+8 −4
Original line number Diff line number Diff line
@@ -547,14 +547,18 @@ static int mxser_carrier_raised(struct tty_port *port)
	return (inb(mp->ioaddr + UART_MSR) & UART_MSR_DCD)?1:0;
}

static void mxser_raise_dtr_rts(struct tty_port *port)
static void mxser_dtr_rts(struct tty_port *port, int on)
{
	struct mxser_port *mp = container_of(port, struct mxser_port, port);
	unsigned long flags;

	spin_lock_irqsave(&mp->slock, flags);
	if (on)
		outb(inb(mp->ioaddr + UART_MCR) |
			UART_MCR_DTR | UART_MCR_RTS, mp->ioaddr + UART_MCR);
	else
		outb(inb(mp->ioaddr + UART_MCR)&~(UART_MCR_DTR | UART_MCR_RTS),
			mp->ioaddr + UART_MCR);
	spin_unlock_irqrestore(&mp->slock, flags);
}

@@ -2356,7 +2360,7 @@ static const struct tty_operations mxser_ops = {

struct tty_port_operations mxser_port_ops = {
	.carrier_raised = mxser_carrier_raised,
	.raise_dtr_rts = mxser_raise_dtr_rts,
	.dtr_rts = mxser_dtr_rts,
};

/*
+7 −4
Original line number Diff line number Diff line
@@ -383,7 +383,7 @@ static void async_mode(MGSLPC_INFO *info);
static void tx_timeout(unsigned long context);

static int carrier_raised(struct tty_port *port);
static void raise_dtr_rts(struct tty_port *port);
static void dtr_rts(struct tty_port *port, int onoff);

#if SYNCLINK_GENERIC_HDLC
#define dev_to_port(D) (dev_to_hdlc(D)->priv)
@@ -513,7 +513,7 @@ static void ldisc_receive_buf(struct tty_struct *tty,

static const struct tty_port_operations mgslpc_port_ops = {
	.carrier_raised = carrier_raised,
	.raise_dtr_rts = raise_dtr_rts
	.dtr_rts = dtr_rts
};

static int mgslpc_probe(struct pcmcia_device *link)
@@ -2528,13 +2528,16 @@ static int carrier_raised(struct tty_port *port)
	return 0;
}

static void raise_dtr_rts(struct tty_port *port)
static void dtr_rts(struct tty_port *port, int onoff)
{
	MGSLPC_INFO *info = container_of(port, MGSLPC_INFO, port);
	unsigned long flags;

	spin_lock_irqsave(&info->lock,flags);
	if (onoff)
		info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR;
	else
		info->serial_signals &= ~SerialSignal_RTS + SerialSignal_DTR;
	set_signals(info);
	spin_unlock_irqrestore(&info->lock,flags);
}
Loading