aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/n_tty.c
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2013-12-02 14:24:45 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-08 19:52:40 -0500
commiteafbe67f84761d787802e5113d895a316b6292fe (patch)
treeab2e9fe80d4ce8148334c84fb11ea8f792069d7f /drivers/tty/n_tty.c
parent001ba923719bc555552ac4c9fe8df4d8c888df39 (diff)
n_tty: Refactor input_available_p() by call site
Distinguish if caller is n_tty_poll() or n_tty_read(), and set the read/wakeup threshold accordingly. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/n_tty.c')
-rw-r--r--drivers/tty/n_tty.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 649fd94d1aa6..2caa2936d1b1 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1869,14 +1869,15 @@ err:
1869 return -ENOMEM; 1869 return -ENOMEM;
1870} 1870}
1871 1871
1872static inline int input_available_p(struct tty_struct *tty, int amt) 1872static inline int input_available_p(struct tty_struct *tty, int poll)
1873{ 1873{
1874 struct n_tty_data *ldata = tty->disc_data; 1874 struct n_tty_data *ldata = tty->disc_data;
1875 int amt = poll && !TIME_CHAR(tty) ? MIN_CHAR(tty) : 1;
1875 1876
1876 if (ldata->icanon && !L_EXTPROC(tty)) { 1877 if (ldata->icanon && !L_EXTPROC(tty)) {
1877 if (ldata->canon_head != ldata->read_tail) 1878 if (ldata->canon_head != ldata->read_tail)
1878 return 1; 1879 return 1;
1879 } else if (read_cnt(ldata) >= (amt ? amt : 1)) 1880 } else if (read_cnt(ldata) >= amt)
1880 return 1; 1881 return 1;
1881 1882
1882 return 0; 1883 return 0;
@@ -2375,7 +2376,7 @@ static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file,
2375 2376
2376 poll_wait(file, &tty->read_wait, wait); 2377 poll_wait(file, &tty->read_wait, wait);
2377 poll_wait(file, &tty->write_wait, wait); 2378 poll_wait(file, &tty->write_wait, wait);
2378 if (input_available_p(tty, TIME_CHAR(tty) ? 0 : MIN_CHAR(tty))) 2379 if (input_available_p(tty, 1))
2379 mask |= POLLIN | POLLRDNORM; 2380 mask |= POLLIN | POLLRDNORM;
2380 if (tty->packet && tty->link->ctrl_status) 2381 if (tty->packet && tty->link->ctrl_status)
2381 mask |= POLLPRI | POLLIN | POLLRDNORM; 2382 mask |= POLLPRI | POLLIN | POLLRDNORM;