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

Commit c5f4644e authored by Russell King's avatar Russell King Committed by Russell King
Browse files

[PATCH] Serial: Adjust serial locking



This patch changes the way serial ports are locked when getting modem
status.  This change is necessary because we will need to atomically
read the modem status and take action depending on the CTS status.

Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent a8396883
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -107,8 +107,8 @@ hardware.
	indicate that the signal is permanently active.  If RI is
	not available, the signal should not be indicated as active.

	Locking: none.
	Interrupts: caller dependent.
	Locking: port->lock taken.
	Interrupts: locally disabled.
	This call must not sleep

  stop_tx(port,tty_stop)
+0 −3
Original line number Diff line number Diff line
@@ -1376,13 +1376,10 @@ static unsigned int serial8250_tx_empty(struct uart_port *port)
static unsigned int serial8250_get_mctrl(struct uart_port *port)
{
	struct uart_8250_port *up = (struct uart_8250_port *)port;
	unsigned long flags;
	unsigned char status;
	unsigned int ret;

	spin_lock_irqsave(&up->port.lock, flags);
	status = serial_in(up, UART_MSR);
	spin_unlock_irqrestore(&up->port.lock, flags);

	ret = 0;
	if (status & UART_MSR_DCD)
+0 −3
Original line number Diff line number Diff line
@@ -556,13 +556,10 @@ static unsigned int serial8250_tx_empty(struct uart_port *port)
static unsigned int serial8250_get_mctrl(struct uart_port *port)
{
	struct uart_8250_port *up = (struct uart_8250_port *)port;
	unsigned long flags;
	unsigned char status;
	unsigned int ret;

	spin_lock_irqsave(&up->port.lock, flags);
	status = serial_in(up, UART_MSR);
	spin_unlock_irqrestore(&up->port.lock, flags);

	ret = 0;
	if (status & UART_MSR_DCD)
+7 −6
Original line number Diff line number Diff line
@@ -518,27 +518,28 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id, struct pt_regs *re
static __inline__ unsigned char ip22zilog_read_channel_status(struct uart_port *port)
{
	struct zilog_channel *channel;
	unsigned long flags;
	unsigned char status;

	spin_lock_irqsave(&port->lock, flags);

	channel = ZILOG_CHANNEL_FROM_PORT(port);
	status = readb(&channel->control);
	ZSDELAY();

	spin_unlock_irqrestore(&port->lock, flags);

	return status;
}

/* The port lock is not held.  */
static unsigned int ip22zilog_tx_empty(struct uart_port *port)
{
	unsigned long flags;
	unsigned char status;
	unsigned int ret;

	spin_lock_irqsave(&port->lock, flags);

	status = ip22zilog_read_channel_status(port);

	spin_unlock_irqrestore(&port->lock, flags);

	if (status & Tx_BUF_EMP)
		ret = TIOCSER_TEMT;
	else
@@ -547,7 +548,7 @@ static unsigned int ip22zilog_tx_empty(struct uart_port *port)
	return ret;
}

/* The port lock is not held.  */
/* The port lock is held and interrupts are disabled.  */
static unsigned int ip22zilog_get_mctrl(struct uart_port *port)
{
	unsigned char status;
+0 −3
Original line number Diff line number Diff line
@@ -1058,12 +1058,9 @@ mpsc_get_mctrl(struct uart_port *port)
{
	struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
	u32 mflags, status;
	ulong iflags;

	spin_lock_irqsave(&pi->port.lock, iflags);
	status = (pi->mirror_regs) ? pi->MPSC_CHR_10_m :
		readl(pi->mpsc_base + MPSC_CHR_10);
	spin_unlock_irqrestore(&pi->port.lock, iflags);

	mflags = 0;
	if (status & 0x1)
Loading