diff options
author | Alan Cox <alan@linux.intel.com> | 2010-06-01 16:52:50 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 16:47:41 -0400 |
commit | a360fae67bc173942f620d44d1b23cfb5ccaaf96 (patch) | |
tree | be45781b50fb44586694e265d9ec113e481809f5 /drivers/char/synclinkmp.c | |
parent | 4287341d4dba27ef8048f589e3c0bc683c9f2017 (diff) |
synclink: reworking locking a bit
Use the port mutex and port lock to fix the various races. The locking
still isn't totally consistent but its better than before. Wants switching
to the port helpers.
Signed-off-by: Alan Cox <alan@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char/synclinkmp.c')
-rw-r--r-- | drivers/char/synclinkmp.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index 8da976bd7314..ac447c7eb572 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c | |||
@@ -812,13 +812,15 @@ static void close(struct tty_struct *tty, struct file *filp) | |||
812 | 812 | ||
813 | if (tty_port_close_start(&info->port, tty, filp) == 0) | 813 | if (tty_port_close_start(&info->port, tty, filp) == 0) |
814 | goto cleanup; | 814 | goto cleanup; |
815 | 815 | ||
816 | mutex_lock(&info->port.mutex); | ||
816 | if (info->port.flags & ASYNC_INITIALIZED) | 817 | if (info->port.flags & ASYNC_INITIALIZED) |
817 | wait_until_sent(tty, info->timeout); | 818 | wait_until_sent(tty, info->timeout); |
818 | 819 | ||
819 | flush_buffer(tty); | 820 | flush_buffer(tty); |
820 | tty_ldisc_flush(tty); | 821 | tty_ldisc_flush(tty); |
821 | shutdown(info); | 822 | shutdown(info); |
823 | mutex_unlock(&info->port.mutex); | ||
822 | 824 | ||
823 | tty_port_close_end(&info->port, tty); | 825 | tty_port_close_end(&info->port, tty); |
824 | info->port.tty = NULL; | 826 | info->port.tty = NULL; |
@@ -834,6 +836,7 @@ cleanup: | |||
834 | static void hangup(struct tty_struct *tty) | 836 | static void hangup(struct tty_struct *tty) |
835 | { | 837 | { |
836 | SLMP_INFO *info = tty->driver_data; | 838 | SLMP_INFO *info = tty->driver_data; |
839 | unsigned long flags; | ||
837 | 840 | ||
838 | if (debug_level >= DEBUG_LEVEL_INFO) | 841 | if (debug_level >= DEBUG_LEVEL_INFO) |
839 | printk("%s(%d):%s hangup()\n", | 842 | printk("%s(%d):%s hangup()\n", |
@@ -842,12 +845,16 @@ static void hangup(struct tty_struct *tty) | |||
842 | if (sanity_check(info, tty->name, "hangup")) | 845 | if (sanity_check(info, tty->name, "hangup")) |
843 | return; | 846 | return; |
844 | 847 | ||
848 | mutex_lock(&info->port.mutex); | ||
845 | flush_buffer(tty); | 849 | flush_buffer(tty); |
846 | shutdown(info); | 850 | shutdown(info); |
847 | 851 | ||
852 | spin_lock_irqsave(&info->port.lock, flags); | ||
848 | info->port.count = 0; | 853 | info->port.count = 0; |
849 | info->port.flags &= ~ASYNC_NORMAL_ACTIVE; | 854 | info->port.flags &= ~ASYNC_NORMAL_ACTIVE; |
850 | info->port.tty = NULL; | 855 | info->port.tty = NULL; |
856 | spin_unlock_irqrestore(&info->port.lock, flags); | ||
857 | mutex_unlock(&info->port.mutex); | ||
851 | 858 | ||
852 | wake_up_interruptible(&info->port.open_wait); | 859 | wake_up_interruptible(&info->port.open_wait); |
853 | } | 860 | } |