hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/tty/pty.c
....@@ -29,6 +29,7 @@
2929 #include <linux/file.h>
3030 #include <linux/ioctl.h>
3131 #include <linux/compat.h>
32
+#include "tty.h"
3233
3334 #undef TTY_DEBUG_HANGUP
3435 #ifdef TTY_DEBUG_HANGUP
....@@ -100,7 +101,7 @@
100101 * pty_write - write to a pty
101102 * @tty: the tty we write from
102103 * @buf: kernel buffer of data
103
- * @count: bytes to write
104
+ * @c: bytes to write
104105 *
105106 * Our "hardware" write method. Data is coming from the ldisc which
106107 * may be in a non sleeping state. We simply throw this at the other
....@@ -111,21 +112,11 @@
111112 static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
112113 {
113114 struct tty_struct *to = tty->link;
114
- unsigned long flags;
115115
116
- if (tty->stopped)
116
+ if (tty->stopped || !c)
117117 return 0;
118118
119
- if (c > 0) {
120
- spin_lock_irqsave(&to->port->lock, flags);
121
- /* Stuff the data into the input queue of the other end */
122
- c = tty_insert_flip_string(to->port, buf, c);
123
- spin_unlock_irqrestore(&to->port->lock, flags);
124
- /* And shovel */
125
- if (c)
126
- tty_flip_buffer_push(to->port);
127
- }
128
- return c;
119
+ return tty_insert_flip_string_and_push_buffer(to->port, buf, c);
129120 }
130121
131122 /**