Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 207880
b: refs/heads/master
c: d6e679b
h: refs/heads/master
v: v3
  • Loading branch information
Arjan van de Ven authored and Greg Kroah-Hartman committed Aug 10, 2010
1 parent a39bdb2 commit 096c220
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 68c16b4117cc746a91897d629b61e5f2af18c225
refs/heads/master: d6e679b474c096f1125087e789e7af8886de39d3
46 changes: 18 additions & 28 deletions trunk/drivers/serial/mrst_max3110.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@

#define PR_FMT "mrst_max3110: "

#define UART_TX_NEEDED 1
#define CON_TX_NEEDED 2
#define BIT_IRQ_PENDING 3

struct uart_max3110 {
struct uart_port port;
struct spi_device *spi;
Expand All @@ -63,15 +67,13 @@ struct uart_max3110 {
u8 clock;
u8 parity, word_7bits;

atomic_t uart_tx_need;
unsigned long uart_flags;

/* console related */
struct circ_buf con_xmit;
atomic_t con_tx_need;

/* irq related */
u16 irq;
atomic_t irq_pending;
};

/* global data structure, may need be removed */
Expand Down Expand Up @@ -176,10 +178,9 @@ static void serial_m3110_con_putchar(struct uart_port *port, int ch)
xmit->head = (xmit->head + 1) & (PAGE_SIZE - 1);
}

if (!atomic_read(&max->con_tx_need)) {
atomic_set(&max->con_tx_need, 1);

if (!test_and_set_bit(CON_TX_NEEDED, &max->uart_flags))
wake_up_process(max->main_thread);
}
}

/*
Expand Down Expand Up @@ -318,10 +319,8 @@ static void serial_m3110_start_tx(struct uart_port *port)
struct uart_max3110 *max =
container_of(port, struct uart_max3110, port);

if (!atomic_read(&max->uart_tx_need)) {
atomic_set(&max->uart_tx_need, 1);
if (!test_and_set_bit(UART_TX_NEEDED, &max->uart_flags))
wake_up_process(max->main_thread);
}
}

static void receive_chars(struct uart_max3110 *max, unsigned char *str, int len)
Expand Down Expand Up @@ -392,32 +391,23 @@ static int max3110_main_thread(void *_max)
pr_info(PR_FMT "start main thread\n");

do {
wait_event_interruptible(*wq, (atomic_read(&max->irq_pending) ||
atomic_read(&max->con_tx_need) ||
atomic_read(&max->uart_tx_need)) ||
kthread_should_stop());
wait_event_interruptible(*wq, max->uart_flags || kthread_should_stop());

mutex_lock(&max->thread_mutex);

#ifdef CONFIG_MRST_MAX3110_IRQ
if (atomic_read(&max->irq_pending)) {
if (test_and_clear_bit(BIT_IRQ_PENDING, &max->uart_flags))
max3110_console_receive(max);
atomic_set(&max->irq_pending, 0);
}
#endif

/* first handle console output */
if (atomic_read(&max->con_tx_need)) {
if (test_and_clear_bit(CON_TX_NEEDED, &max->uart_flags))
send_circ_buf(max, xmit);
atomic_set(&max->con_tx_need, 0);
}

/* handle uart output */
if (atomic_read(&max->uart_tx_need)) {
if (test_and_clear_bit(UART_TX_NEEDED, &max->uart_flags))
transmit_char(max);
atomic_set(&max->uart_tx_need, 0);
}

mutex_unlock(&max->thread_mutex);

} while (!kthread_should_stop());

return ret;
Expand All @@ -430,10 +420,9 @@ static irqreturn_t serial_m3110_irq(int irq, void *dev_id)

/* max3110's irq is a falling edge, not level triggered,
* so no need to disable the irq */
if (!atomic_read(&max->irq_pending)) {
atomic_inc(&max->irq_pending);
if (!test_and_set_bit(BIT_IRQ_PENDING, &max->uart_flags))
wake_up_process(max->main_thread);
}

return IRQ_HANDLED;
}
#else
Expand Down Expand Up @@ -753,7 +742,8 @@ static int serial_m3110_probe(struct spi_device *spi)
max->baud = 0;

max->cur_conf = 0;
atomic_set(&max->irq_pending, 0);
max->uart_flags = 0;

/* Check if reading configuration register returns something sane */

res = RC_TAG;
Expand Down

0 comments on commit 096c220

Please sign in to comment.