提交 ddc5fda7 编写于 作者: L Linus Torvalds 提交者: Greg Kroah-Hartman

tty: fix up hung_up_tty_read() conversion

In commit "tty: implement read_iter", I left the read_iter conversion of
the hung up tty case alone, because I incorrectly thought it didn't
matter.

Jiri showed me the errors of my ways, and pointed out the problems with
that incomplete conversion.  Fix it all up.
Reported-by: NJiri Slaby <jirislaby@kernel.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: NJiri Slaby <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/CAHk-=wh+-rGsa=xruEWdg_fJViFG8rN9bpLrfLz=_yBYh2tBhA@mail.gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 c7135bbe
...@@ -431,8 +431,7 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line) ...@@ -431,8 +431,7 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line)
EXPORT_SYMBOL_GPL(tty_find_polling_driver); EXPORT_SYMBOL_GPL(tty_find_polling_driver);
#endif #endif
static ssize_t hung_up_tty_read(struct file *file, char __user *buf, static ssize_t hung_up_tty_read(struct kiocb *iocb, struct iov_iter *to)
size_t count, loff_t *ppos)
{ {
return 0; return 0;
} }
...@@ -504,7 +503,7 @@ static const struct file_operations console_fops = { ...@@ -504,7 +503,7 @@ static const struct file_operations console_fops = {
static const struct file_operations hung_up_tty_fops = { static const struct file_operations hung_up_tty_fops = {
.llseek = no_llseek, .llseek = no_llseek,
.read = hung_up_tty_read, .read_iter = hung_up_tty_read,
.write_iter = hung_up_tty_write, .write_iter = hung_up_tty_write,
.poll = hung_up_tty_poll, .poll = hung_up_tty_poll,
.unlocked_ioctl = hung_up_tty_ioctl, .unlocked_ioctl = hung_up_tty_ioctl,
...@@ -940,8 +939,10 @@ static ssize_t tty_read(struct kiocb *iocb, struct iov_iter *to) ...@@ -940,8 +939,10 @@ static ssize_t tty_read(struct kiocb *iocb, struct iov_iter *to)
/* We want to wait for the line discipline to sort out in this /* We want to wait for the line discipline to sort out in this
situation */ situation */
ld = tty_ldisc_ref_wait(tty); ld = tty_ldisc_ref_wait(tty);
if (!ld)
return hung_up_tty_read(iocb, to);
i = -EIO; i = -EIO;
if (ld && ld->ops->read) if (ld->ops->read)
i = iterate_tty_read(ld, tty, file, to); i = iterate_tty_read(ld, tty, file, to);
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册