aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/nozomi.c
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2010-02-08 05:07:04 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-02 17:43:20 -0500
commite8c65d143a9903cb553c0d80c819428c5b839a02 (patch)
tree58cea659ac19c23a4c5475a362c157c9497ef10f /drivers/char/nozomi.c
parent266794eb71cfee65b38371954b9db2f6dbda207c (diff)
nozomi: Fix mutex handling
The original author didn't realise the kernel lock was a drop while sleep lock so did clever (and wrong) things to work around the non need to avoid deadlocks. Remove the cleverness and the comment (as we don't hold the BKL now anyway in those paths) Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char/nozomi.c')
-rw-r--r--drivers/char/nozomi.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index cd405bcf53a6..fac9157a0ec0 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -1693,15 +1693,7 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer,
1693 if (!dc || !port) 1693 if (!dc || !port)
1694 return -ENODEV; 1694 return -ENODEV;
1695 1695
1696 if (unlikely(!mutex_trylock(&port->tty_sem))) { 1696 mutex_lock(&port->tty_sem);
1697 /*
1698 * must test lock as tty layer wraps calls
1699 * to this function with BKL
1700 */
1701 dev_err(&dc->pdev->dev, "Would have deadlocked - "
1702 "return EAGAIN\n");
1703 return -EAGAIN;
1704 }
1705 1697
1706 if (unlikely(!port->port.count)) { 1698 if (unlikely(!port->port.count)) {
1707 DBG1(" "); 1699 DBG1(" ");
@@ -1741,25 +1733,23 @@ exit:
1741 * This method is called by the upper tty layer. 1733 * This method is called by the upper tty layer.
1742 * #according to sources N_TTY.c it expects a value >= 0 and 1734 * #according to sources N_TTY.c it expects a value >= 0 and
1743 * does not check for negative values. 1735 * does not check for negative values.
1736 *
1737 * If the port is unplugged report lots of room and let the bits
1738 * dribble away so we don't block anything.
1744 */ 1739 */
1745static int ntty_write_room(struct tty_struct *tty) 1740static int ntty_write_room(struct tty_struct *tty)
1746{ 1741{
1747 struct port *port = tty->driver_data; 1742 struct port *port = tty->driver_data;
1748 int room = 0; 1743 int room = 4096;
1749 const struct nozomi *dc = get_dc_by_tty(tty); 1744 const struct nozomi *dc = get_dc_by_tty(tty);
1750 1745
1751 if (!dc || !port) 1746 if (dc) {
1752 return 0; 1747 mutex_lock(&port->tty_sem);
1753 if (!mutex_trylock(&port->tty_sem)) 1748 if (port->port.count)
1754 return 0; 1749 room = port->fifo_ul.size -
1755 1750 kfifo_len(&port->fifo_ul);
1756 if (!port->port.count) 1751 mutex_unlock(&port->tty_sem);
1757 goto exit; 1752 }
1758
1759 room = port->fifo_ul.size - kfifo_len(&port->fifo_ul);
1760
1761exit:
1762 mutex_unlock(&port->tty_sem);
1763 return room; 1753 return room;
1764} 1754}
1765 1755