static int receive_chars_read(struct uart_port *port) { static int saw_console_brk; int limit = 10000; while (limit-- > 0) { unsigned long ra = __pa(con_read_page); unsigned long bytes_read, i; long stat = sun4v_con_read(ra, PAGE_SIZE, &bytes_read); if (stat != HV_EOK) { bytes_read = 0; if (stat == CON_BREAK) { if (saw_console_brk) sun_do_break(); if (uart_handle_break(port)) continue; saw_console_brk = 1; *con_read_page = 0; bytes_read = 1; } else if (stat == CON_HUP) { hung_up = 1; uart_handle_dcd_change(port, 0); continue; } else { /* HV_EWOULDBLOCK, etc. */ break; } } if (hung_up) { hung_up = 0; uart_handle_dcd_change(port, 1); } if (port->sysrq != 0 && *con_read_page) { for (i = 0; i < bytes_read; i++) uart_handle_sysrq_char(port, con_read_page[i]); saw_console_brk = 0; } if (port->state == NULL) continue; port->icount.rx += bytes_read; tty_insert_flip_string(&port->state->port, con_read_page, bytes_read); } return saw_console_brk; }
static int receive_chars_read(struct uart_port *port, struct tty_struct *tty) { int saw_console_brk = 0; int limit = 10000; while (limit-- > 0) { unsigned long ra = __pa(con_read_page); unsigned long bytes_read, i; unsigned long breaks_received = 0; long stat = sun4v_con_read(ra, PAGE_SIZE, &bytes_read); if (stat != HV_EOK) { bytes_read = 0; if (stat == CON_BREAK) { if (uart_handle_break(port)) continue; saw_console_brk = 1; *con_read_page = 0; bytes_read = 1; } else if (stat == CON_HUP) { hung_up = 1; uart_handle_dcd_change(port, 0); continue; } else { /* HV_EWOULDBLOCK, etc. */ break; } } #ifdef CONFIG_CONSOLE_POLL if (port->poll_rx_cb) { for (i = 0; i < bytes_read; i++) { if (port->poll_rx_cb(con_read_page[i] & 255)) { if ((bytes_read - i - 1) != 0) memcpy(&con_read_page[i], &con_read_page[i+1], bytes_read - i - 1); breaks_received++; continue; } else uart_handle_sysrq_char(port, con_read_page[i]); } } #endif if (hung_up) { hung_up = 0; uart_handle_dcd_change(port, 1); } #ifndef CONFIG_CONSOLE_POLL for (i = 0; i < bytes_read; i++) uart_handle_sysrq_char(port, con_read_page[i]); #endif if (tty == NULL) continue; port->icount.rx += bytes_read - breaks_received; tty_insert_flip_string(tty, con_read_page, bytes_read - breaks_received); } return saw_console_brk; }