diff options
-rw-r--r-- | drivers/char/nozomi.c | 34 |
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 | */ |
1745 | static int ntty_write_room(struct tty_struct *tty) | 1740 | static 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 | |||
1761 | exit: | ||
1762 | mutex_unlock(&port->tty_sem); | ||
1763 | return room; | 1753 | return room; |
1764 | } | 1754 | } |
1765 | 1755 | ||