forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/tty/pty.c
....@@ -100,7 +100,7 @@
100100 * pty_write - write to a pty
101101 * @tty: the tty we write from
102102 * @buf: kernel buffer of data
103
- * @count: bytes to write
103
+ * @c: bytes to write
104104 *
105105 * Our "hardware" write method. Data is coming from the ldisc which
106106 * may be in a non sleeping state. We simply throw this at the other
....@@ -111,21 +111,11 @@
111111 static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
112112 {
113113 struct tty_struct *to = tty->link;
114
- unsigned long flags;
115114
116
- if (tty->stopped)
115
+ if (tty->stopped || !c)
117116 return 0;
118117
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;
118
+ return tty_insert_flip_string_and_push_buffer(to->port, buf, c);
129119 }
130120
131121 /**