diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-12-11 02:41:08 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-12-11 02:41:08 -0500 |
| commit | 42e64571d516ef761d9f330c80493637cbf3bdda (patch) | |
| tree | 5f3df1c06c2d571efa5fd72d0c8022a80140eec2 /drivers/tty/serdev | |
| parent | b8f3bff057b017309fbd61fe74712b1f185b5399 (diff) | |
| parent | 50c4c4e268a2d7a3e58ebb698ac74da0de40ae36 (diff) | |
Merge 4.15-rc3 into tty-next
We want the serial/tty fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serdev')
| -rw-r--r-- | drivers/tty/serdev/serdev-ttyport.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c index 75f312ed96e8..c2629ab1bbcf 100644 --- a/drivers/tty/serdev/serdev-ttyport.c +++ b/drivers/tty/serdev/serdev-ttyport.c | |||
| @@ -27,23 +27,41 @@ static int ttyport_receive_buf(struct tty_port *port, const unsigned char *cp, | |||
| 27 | { | 27 | { |
| 28 | struct serdev_controller *ctrl = port->client_data; | 28 | struct serdev_controller *ctrl = port->client_data; |
| 29 | struct serport *serport = serdev_controller_get_drvdata(ctrl); | 29 | struct serport *serport = serdev_controller_get_drvdata(ctrl); |
| 30 | int ret; | ||
| 30 | 31 | ||
| 31 | if (!test_bit(SERPORT_ACTIVE, &serport->flags)) | 32 | if (!test_bit(SERPORT_ACTIVE, &serport->flags)) |
| 32 | return 0; | 33 | return 0; |
| 33 | 34 | ||
| 34 | return serdev_controller_receive_buf(ctrl, cp, count); | 35 | ret = serdev_controller_receive_buf(ctrl, cp, count); |
| 36 | |||
| 37 | dev_WARN_ONCE(&ctrl->dev, ret < 0 || ret > count, | ||
| 38 | "receive_buf returns %d (count = %zu)\n", | ||
| 39 | ret, count); | ||
| 40 | if (ret < 0) | ||
| 41 | return 0; | ||
| 42 | else if (ret > count) | ||
| 43 | return count; | ||
| 44 | |||
| 45 | return ret; | ||
| 35 | } | 46 | } |
| 36 | 47 | ||
| 37 | static void ttyport_write_wakeup(struct tty_port *port) | 48 | static void ttyport_write_wakeup(struct tty_port *port) |
| 38 | { | 49 | { |
| 39 | struct serdev_controller *ctrl = port->client_data; | 50 | struct serdev_controller *ctrl = port->client_data; |
| 40 | struct serport *serport = serdev_controller_get_drvdata(ctrl); | 51 | struct serport *serport = serdev_controller_get_drvdata(ctrl); |
| 52 | struct tty_struct *tty; | ||
| 53 | |||
| 54 | tty = tty_port_tty_get(port); | ||
| 55 | if (!tty) | ||
| 56 | return; | ||
| 41 | 57 | ||
| 42 | if (test_and_clear_bit(TTY_DO_WRITE_WAKEUP, &port->tty->flags) && | 58 | if (test_and_clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && |
| 43 | test_bit(SERPORT_ACTIVE, &serport->flags)) | 59 | test_bit(SERPORT_ACTIVE, &serport->flags)) |
| 44 | serdev_controller_write_wakeup(ctrl); | 60 | serdev_controller_write_wakeup(ctrl); |
| 45 | 61 | ||
| 46 | wake_up_interruptible_poll(&port->tty->write_wait, POLLOUT); | 62 | wake_up_interruptible_poll(&tty->write_wait, POLLOUT); |
| 63 | |||
| 64 | tty_kref_put(tty); | ||
| 47 | } | 65 | } |
| 48 | 66 | ||
| 49 | static const struct tty_port_client_operations client_ops = { | 67 | static const struct tty_port_client_operations client_ops = { |
| @@ -139,8 +157,10 @@ static void ttyport_close(struct serdev_controller *ctrl) | |||
| 139 | 157 | ||
| 140 | clear_bit(SERPORT_ACTIVE, &serport->flags); | 158 | clear_bit(SERPORT_ACTIVE, &serport->flags); |
| 141 | 159 | ||
| 160 | tty_lock(tty); | ||
| 142 | if (tty->ops->close) | 161 | if (tty->ops->close) |
| 143 | tty->ops->close(tty, NULL); | 162 | tty->ops->close(tty, NULL); |
| 163 | tty_unlock(tty); | ||
| 144 | 164 | ||
| 145 | tty_release_struct(tty, serport->tty_idx); | 165 | tty_release_struct(tty, serport->tty_idx); |
| 146 | } | 166 | } |
