tty_insert_flip_string(porty, (u8 *)rx_buf, i);
tty_flip_buffer_push(porty);
-->
void tty_flip_buffer_push(struct tty_port *port)
{
tty_schedule_flip(port);
}
-->
void tty_schedule_flip(struct tty_port *port)
{
struct tty_bufhead *buf = &port->buf;
/* paired w/ acquire in flush_to_ldisc(); ensures
* flush_to_ldisc() sees buffer data.
*/
smp_store_release(&buf->tail->commit, buf->tail->used);
queue_work(system_unbound_wq, &buf->work);
}
---------------------------------------------------------------------------->
INIT_WORK(&buf->work, flush_to_ldisc);
-->
static void flush_to_ldisc(struct work_struct *work)
{
count = receive_buf(disc, head, count);
}
-->
static int
receive_buf(struct tty_ldisc *ld, struct tty_buffer *head, int count)
{
unsigned char *p = char_buf_ptr(head, head->read);
char *f = NULL;
if (~head->flags & TTYB_NORMAL)
f = flag_buf_ptr(head, head->read);
return tty_ldisc_receive_buf(ld, p, f, count);
}
-->
int tty_ldisc_receive_buf(struct tty_ldisc *ld, unsigned char *p,
char *f, int count)
{
if (ld->ops->receive_buf2)
count = ld->ops->receive_buf2(ld->tty, p, f, count);
else {
count = min_t(int, count, ld->tty->receive_room);
if (count && ld->ops->receive_buf)
ld->ops->receive_buf(ld->tty, p, f, count);
}
return count;
}
-->
2441 static struct tty_ldisc_ops n_tty_ops = {
2442 .magic = TTY_LDISC_MAGIC,
2443 .name = "n_tty",
2444 .open = n_tty_open,
2445 .close = n_tty_close,
2446 .flush_buffer = n_tty_flush_buffer,
2447 .read = n_tty_read,
2448 .write = n_tty_write,
2449 .ioctl = n_tty_ioctl,
2450 .set_termios = n_tty_set_termios,
2451 .poll = n_tty_poll,
2452 .receive_buf = n_tty_receive_buf,
2453 .write_wakeup = n_tty_write_wakeup,
2454 .receive_buf2 = n_tty_receive_buf2,
2455 };
-->
static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
char *fp, int count)
{
n_tty_receive_buf_common(tty, cp, fp, count, 0);
}
--->
static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
char *fp, int count)
{
struct n_tty_data *ldata = tty->disc_data;
bool preops = I_ISTRIP(tty) || (I_IUCLC(tty) && L_IEXTEN(tty));
if (ldata->real_raw)
n_tty_receive_buf_real_raw(tty, cp, fp, count);
else if (ldata->raw || (L_EXTPROC(tty) && !preops))
n_tty_receive_buf_raw(tty, cp, fp, count);
-->
static void
n_tty_receive_buf_real_raw(struct tty_struct *tty, const unsigned char *cp,
char *fp, int count)
{
struct n_tty_data *ldata = tty->disc_data;
size_t n, head;
head = ldata->read_head & (N_TTY_BUF_SIZE - 1);
n = min_t(size_t, count, N_TTY_BUF_SIZE - head);
memcpy(read_buf_addr(ldata, head), cp, n);
ldata->read_head += n;
cp += n;
count -= n;
head = ldata->read_head & (N_TTY_BUF_SIZE - 1);
n = min_t(size_t, count, N_TTY_BUF_SIZE - head);
memcpy(read_buf_addr(ldata, head), cp, n);
ldata->read_head += n;
}