diff options
-rw-r--r-- | drivers/serial/mrst_max3110.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/serial/mrst_max3110.c b/drivers/serial/mrst_max3110.c index f9c01aeb6f80..0341853e0c28 100644 --- a/drivers/serial/mrst_max3110.c +++ b/drivers/serial/mrst_max3110.c | |||
@@ -56,8 +56,7 @@ struct uart_max3110 { | |||
56 | wait_queue_head_t wq; | 56 | wait_queue_head_t wq; |
57 | struct task_struct *main_thread; | 57 | struct task_struct *main_thread; |
58 | struct task_struct *read_thread; | 58 | struct task_struct *read_thread; |
59 | int mthread_up; | 59 | struct mutex thread_mutex;; |
60 | spinlock_t lock; | ||
61 | 60 | ||
62 | u32 baud; | 61 | u32 baud; |
63 | u16 cur_conf; | 62 | u16 cur_conf; |
@@ -397,7 +396,8 @@ static int max3110_main_thread(void *_max) | |||
397 | atomic_read(&max->con_tx_need) || | 396 | atomic_read(&max->con_tx_need) || |
398 | atomic_read(&max->uart_tx_need)) || | 397 | atomic_read(&max->uart_tx_need)) || |
399 | kthread_should_stop()); | 398 | kthread_should_stop()); |
400 | max->mthread_up = 1; | 399 | |
400 | mutex_lock(&max->thread_mutex); | ||
401 | 401 | ||
402 | #ifdef CONFIG_MRST_MAX3110_IRQ | 402 | #ifdef CONFIG_MRST_MAX3110_IRQ |
403 | if (atomic_read(&max->irq_pending)) { | 403 | if (atomic_read(&max->irq_pending)) { |
@@ -417,7 +417,7 @@ static int max3110_main_thread(void *_max) | |||
417 | transmit_char(max); | 417 | transmit_char(max); |
418 | atomic_set(&max->uart_tx_need, 0); | 418 | atomic_set(&max->uart_tx_need, 0); |
419 | } | 419 | } |
420 | max->mthread_up = 0; | 420 | mutex_unlock(&max->thread_mutex); |
421 | } while (!kthread_should_stop()); | 421 | } while (!kthread_should_stop()); |
422 | 422 | ||
423 | return ret; | 423 | return ret; |
@@ -444,8 +444,9 @@ static int max3110_read_thread(void *_max) | |||
444 | 444 | ||
445 | pr_info(PR_FMT "start read thread\n"); | 445 | pr_info(PR_FMT "start read thread\n"); |
446 | do { | 446 | do { |
447 | if (!max->mthread_up) | 447 | mutex_lock(&max->thread_mutex); |
448 | max3110_console_receive(max); | 448 | max3110_console_receive(max); |
449 | mutex_unlock(&max->thread_mutex); | ||
449 | 450 | ||
450 | set_current_state(TASK_INTERRUPTIBLE); | 451 | set_current_state(TASK_INTERRUPTIBLE); |
451 | schedule_timeout(HZ / 20); | 452 | schedule_timeout(HZ / 20); |
@@ -745,7 +746,7 @@ static int serial_m3110_probe(struct spi_device *spi) | |||
745 | max->name = spi->modalias; /* use spi name as the name */ | 746 | max->name = spi->modalias; /* use spi name as the name */ |
746 | max->irq = (u16)spi->irq; | 747 | max->irq = (u16)spi->irq; |
747 | 748 | ||
748 | spin_lock_init(&max->lock); | 749 | mutex_init(&max->thread_mutex); |
749 | 750 | ||
750 | max->word_7bits = 0; | 751 | max->word_7bits = 0; |
751 | max->parity = 0; | 752 | max->parity = 0; |