aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2009-11-05 08:28:38 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 18:18:05 -0500
commit0a68f64febf365313987c570ad59c9069f61306d (patch)
tree4c0c00f0c6374038eb6a42195e77b2b30411f6bb
parent530646f4695b396aeeec2ca912dcc3a9c95e0f52 (diff)
sdio_uart: Move the open lock
When we move to the tty_port logic the port mutex will protect open v close v hangup. Move to this first in the existing open code so we have a bisection point. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/mmc/card/sdio_uart.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c
index 86ad54341128..31f70233133d 100644
--- a/drivers/mmc/card/sdio_uart.c
+++ b/drivers/mmc/card/sdio_uart.c
@@ -78,7 +78,6 @@ struct sdio_uart_port {
78 struct tty_struct *tty; 78 struct tty_struct *tty;
79 unsigned int index; 79 unsigned int index;
80 unsigned int opened; 80 unsigned int opened;
81 struct mutex open_lock;
82 struct sdio_func *func; 81 struct sdio_func *func;
83 struct mutex func_lock; 82 struct mutex func_lock;
84 struct task_struct *in_sdio_uart_irq; 83 struct task_struct *in_sdio_uart_irq;
@@ -103,7 +102,6 @@ static int sdio_uart_add_port(struct sdio_uart_port *port)
103 int index, ret = -EBUSY; 102 int index, ret = -EBUSY;
104 103
105 kref_init(&port->kref); 104 kref_init(&port->kref);
106 mutex_init(&port->open_lock);
107 mutex_init(&port->func_lock); 105 mutex_init(&port->func_lock);
108 spin_lock_init(&port->write_lock); 106 spin_lock_init(&port->write_lock);
109 107
@@ -166,7 +164,7 @@ static void sdio_uart_port_remove(struct sdio_uart_port *port)
166 * give up on that port ASAP. 164 * give up on that port ASAP.
167 * Beware: the lock ordering is critical. 165 * Beware: the lock ordering is critical.
168 */ 166 */
169 mutex_lock(&port->open_lock); 167 mutex_lock(&port->port.mutex);
170 mutex_lock(&port->func_lock); 168 mutex_lock(&port->func_lock);
171 func = port->func; 169 func = port->func;
172 sdio_claim_host(func); 170 sdio_claim_host(func);
@@ -179,7 +177,7 @@ static void sdio_uart_port_remove(struct sdio_uart_port *port)
179 tty_hangup(tty); 177 tty_hangup(tty);
180 tty_kref_put(tty); 178 tty_kref_put(tty);
181 } 179 }
182 mutex_unlock(&port->open_lock); 180 mutex_unlock(&port->port.mutex);
183 sdio_release_irq(func); 181 sdio_release_irq(func);
184 sdio_disable_func(func); 182 sdio_disable_func(func);
185 sdio_release_host(func); 183 sdio_release_host(func);
@@ -699,14 +697,14 @@ static int sdio_uart_open(struct tty_struct *tty, struct file *filp)
699 if (!port) 697 if (!port)
700 return -ENODEV; 698 return -ENODEV;
701 699
702 mutex_lock(&port->open_lock); 700 mutex_lock(&port->port.mutex);
703 701
704 /* 702 /*
705 * Make sure not to mess up with a dead port 703 * Make sure not to mess up with a dead port
706 * which has not been closed yet. 704 * which has not been closed yet.
707 */ 705 */
708 if (tty->driver_data && tty->driver_data != port) { 706 if (tty->driver_data && tty->driver_data != port) {
709 mutex_unlock(&port->open_lock); 707 mutex_unlock(&port->port.mutex);
710 sdio_uart_port_put(port); 708 sdio_uart_port_put(port);
711 return -EBUSY; 709 return -EBUSY;
712 } 710 }
@@ -718,13 +716,13 @@ static int sdio_uart_open(struct tty_struct *tty, struct file *filp)
718 if (ret) { 716 if (ret) {
719 tty->driver_data = NULL; 717 tty->driver_data = NULL;
720 tty_port_tty_set(&port->port, NULL); 718 tty_port_tty_set(&port->port, NULL);
721 mutex_unlock(&port->open_lock); 719 mutex_unlock(&port->port.mutex);
722 sdio_uart_port_put(port); 720 sdio_uart_port_put(port);
723 return ret; 721 return ret;
724 } 722 }
725 } 723 }
726 port->opened++; 724 port->opened++;
727 mutex_unlock(&port->open_lock); 725 mutex_unlock(&port->port.mutex);
728 return 0; 726 return 0;
729} 727}
730 728
@@ -735,7 +733,7 @@ static void sdio_uart_close(struct tty_struct *tty, struct file * filp)
735 if (!port) 733 if (!port)
736 return; 734 return;
737 735
738 mutex_lock(&port->open_lock); 736 mutex_lock(&port->port.mutex);
739 BUG_ON(!port->opened); 737 BUG_ON(!port->opened);
740 738
741 /* 739 /*
@@ -744,7 +742,7 @@ static void sdio_uart_close(struct tty_struct *tty, struct file * filp)
744 * is larger than port->count. 742 * is larger than port->count.
745 */ 743 */
746 if (tty->count > port->opened) { 744 if (tty->count > port->opened) {
747 mutex_unlock(&port->open_lock); 745 mutex_unlock(&port->port.mutex);
748 return; 746 return;
749 } 747 }
750 748
@@ -756,7 +754,7 @@ static void sdio_uart_close(struct tty_struct *tty, struct file * filp)
756 tty->driver_data = NULL; 754 tty->driver_data = NULL;
757 tty->closing = 0; 755 tty->closing = 0;
758 } 756 }
759 mutex_unlock(&port->open_lock); 757 mutex_unlock(&port->port.mutex);
760 sdio_uart_port_put(port); 758 sdio_uart_port_put(port);
761} 759}
762 760