Skip to contentSkip to conversation

serial: mrst_max3110: Check the irq number before enable/disabe irq in PM hooks

PATCH New Feng Tang 1 participant 2 messages Oct 9, 2013 TTY layer and serial drivers

lore
Share & tools
lore

Feng Tang

author
#0 lore raw

PATCH 1/2 serial: mrst_max3110: Check the irq number before enable/disabe irq in PM hooks

We should check the validity of the irq number before calling disable_irq() and enable_irq() in the suspend/resume function, as "max->irq == 0" means the irq is not enabled for max3110 device, otherwise it will hurt device whose irq number is really 0.

---
 drivers/tty/serial/mrst_max3110.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/mrst_max3110.c +4 -2
index a67e708..ee77e73 100644
@@ -749,7 +749,8 @@ static int serial_m3110_suspend(struct device *dev)
 	struct spi_device *spi = to_spi_device(dev);
 	struct uart_max3110 *max = spi_get_drvdata(spi);
 
-	disable_irq(max->irq);
+	if (max->irq > 0)
+		disable_irq(max->irq);
 	uart_suspend_port(&serial_m3110_reg, &max->port);
 	max3110_out(max, max->cur_conf | WC_SW_SHDI);
 	return 0;
@@ -762,7 +763,8 @@ static int serial_m3110_resume(struct device *dev)
 
 	max3110_out(max, max->cur_conf);
 	uart_resume_port(&serial_m3110_reg, &max->port);
-	enable_irq(max->irq);
+	if (max->irq > 0)
+		enable_irq(max->irq);
 	return 0;
 }
 
Signature · 1 line
1.7.0.4
author
#1 lore raw

PATCH 2/2 serial: mrst_max3110: Fix race condition between spi transfers

From: Bin Gao <[email protected]>

There is a race between termios configuration and xmit that can cause the intel_mid_ssp_spi driver to stall.

Serializing spi transactions fixes the problem.

---
 drivers/tty/serial/mrst_max3110.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/tty/serial/mrst_max3110.c +4 -0
index ee77e73..565779d 100644
@@ -61,6 +61,7 @@ struct uart_max3110 {
 	struct task_struct *main_thread;
 	struct task_struct *read_thread;
 	struct mutex thread_mutex;
+	struct mutex io_mutex;
 
 	u32 baud;
 	u16 cur_conf;
@@ -90,6 +91,7 @@ static int max3110_write_then_read(struct uart_max3110 *max,
 	struct spi_transfer	x;
 	int ret;
 
+	mutex_lock(&max->io_mutex);
 	spi_message_init(&message);
 	memset(&x, 0, sizeof x);
 	x.len = len;
@@ -104,6 +106,7 @@ static int max3110_write_then_read(struct uart_max3110 *max,
 
 	/* Do the i/o */
 	ret = spi_sync(spi, &message);
+	mutex_unlock(&max->io_mutex);
 	return ret;
 }
 
@@ -805,6 +808,7 @@ static int serial_m3110_probe(struct spi_device *spi)
 	max->irq = (u16)spi->irq;
 
 	mutex_init(&max->thread_mutex);
+	mutex_init(&max->io_mutex);
 
 	max->word_7bits = 0;
 	max->parity = 0;
Signature · 1 line
1.7.0.4