TTY: switch tty_insert_flip_string

Now, we start converting tty buffer functions to actually use
tty_port. This will allow us to get rid of the need of tty in many
call sites. Only tty_port will needed and hence no more
tty_port_tty_get in those paths.

tty_insert_flip_string this time.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jiri Slaby
2013-01-03 15:53:04 +01:00
committed by Greg Kroah-Hartman
parent 92a19f9cec
commit 05c7cd3990
62 changed files with 130 additions and 127 deletions

View File

@@ -119,9 +119,8 @@ static int aircable_probe(struct usb_serial *serial,
return 0;
}
static int aircable_process_packet(struct tty_struct *tty,
struct usb_serial_port *port, int has_headers,
char *packet, int len)
static int aircable_process_packet(struct usb_serial_port *port,
int has_headers, char *packet, int len)
{
if (has_headers) {
len -= HCI_HEADER_LENGTH;
@@ -132,7 +131,7 @@ static int aircable_process_packet(struct tty_struct *tty,
return 0;
}
tty_insert_flip_string(tty, packet, len);
tty_insert_flip_string(&port->port, packet, len);
return len;
}
@@ -156,7 +155,7 @@ static void aircable_process_read_urb(struct urb *urb)
count = 0;
for (i = 0; i < urb->actual_length; i += HCI_COMPLETE_FRAME) {
len = min_t(int, urb->actual_length - i, HCI_COMPLETE_FRAME);
count += aircable_process_packet(tty, port, has_headers,
count += aircable_process_packet(port, has_headers,
&data[i], len);
}

View File

@@ -343,7 +343,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
return;
}
if (urb->actual_length) {
tty_insert_flip_string(tty, data, urb->actual_length);
tty_insert_flip_string(&port->port, data, urb->actual_length);
tty_flip_buffer_push(tty);
}
tty_kref_put(tty);

View File

@@ -256,7 +256,7 @@ static void send_to_tty(struct usb_serial_port *port,
if (tty && actual_length) {
usb_serial_debug_data(&port->dev, __func__, actual_length, data);
tty_insert_flip_string(tty, data, actual_length);
tty_insert_flip_string(&port->port, data, actual_length);
tty_flip_buffer_push(tty);
}
tty_kref_put(tty);

View File

@@ -328,7 +328,7 @@ void usb_serial_generic_process_read_urb(struct urb *urb)
stuff like 3G modems, so shortcircuit it in the 99.9999999% of cases
where the USB serial is not a console anyway */
if (!port->port.console || !port->sysrq)
tty_insert_flip_string(tty, ch, urb->actual_length);
tty_insert_flip_string(&port->port, ch, urb->actual_length);
else {
for (i = 0; i < urb->actual_length; i++, ch++) {
if (!usb_serial_handle_sysrq_char(port, *ch))

View File

@@ -232,7 +232,7 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
unsigned char *buffer, __u16 bufferLength);
static void process_rcvd_status(struct edgeport_serial *edge_serial,
__u8 byte2, __u8 byte3);
static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty,
unsigned char *data, int length);
static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr);
static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData,
@@ -1865,7 +1865,7 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
if (tty) {
dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n",
__func__, rxLen, edge_serial->rxPort);
edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
edge_tty_recv(edge_port->port, tty, buffer, rxLen);
tty_kref_put(tty);
}
edge_port->icount.rx += rxLen;
@@ -2017,14 +2017,14 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,
* edge_tty_recv
* this function passes data on to the tty flip buffer
*****************************************************************************/
static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty,
unsigned char *data, int length)
{
int cnt;
cnt = tty_insert_flip_string(tty, data, length);
cnt = tty_insert_flip_string(&port->port, data, length);
if (cnt < length) {
dev_err(dev, "%s - dropping data, %d bytes lost\n",
dev_err(&port->dev, "%s - dropping data, %d bytes lost\n",
__func__, length - cnt);
}
data += cnt;
@@ -2090,7 +2090,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData,
struct tty_struct *tty =
tty_port_tty_get(&edge_port->port->port);
if (tty) {
edge_tty_recv(&edge_port->port->dev, tty, &data, 1);
edge_tty_recv(edge_port->port, tty, &data, 1);
tty_kref_put(tty);
}
}

View File

@@ -201,7 +201,7 @@ static int closing_wait = EDGE_CLOSING_WAIT;
static bool ignore_cpu_rev;
static int default_uart_mode; /* RS232 */
static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty,
unsigned char *data, int length);
static void stop_read(struct edgeport_port *edge_port);
@@ -1557,7 +1557,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
if (lsr_data) {
tty = tty_port_tty_get(&edge_port->port->port);
if (tty) {
edge_tty_recv(&edge_port->port->dev, tty, &data, 1);
edge_tty_recv(edge_port->port, tty, &data, 1);
tty_kref_put(tty);
}
}
@@ -1722,7 +1722,8 @@ static void edge_bulk_in_callback(struct urb *urb)
dev_dbg(dev, "%s - close pending, dropping data on the floor\n",
__func__);
else
edge_tty_recv(dev, tty, data, urb->actual_length);
edge_tty_recv(edge_port->port, tty, data,
urb->actual_length);
edge_port->icount.rx += urb->actual_length;
}
tty_kref_put(tty);
@@ -1740,14 +1741,14 @@ exit:
dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval);
}
static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty,
unsigned char *data, int length)
{
int queued;
queued = tty_insert_flip_string(tty, data, length);
queued = tty_insert_flip_string(&port->port, data, length);
if (queued < length)
dev_err(dev, "%s - dropping data, %d bytes lost\n",
dev_err(&port->dev, "%s - dropping data, %d bytes lost\n",
__func__, length - queued);
tty_flip_buffer_push(tty);
}

View File

@@ -305,7 +305,7 @@ static void ir_process_read_urb(struct urb *urb)
tty = tty_port_tty_get(&port->port);
if (!tty)
return;
tty_insert_flip_string(tty, data + 1, urb->actual_length - 1);
tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1);
tty_flip_buffer_push(tty);
tty_kref_put(tty);
}

View File

@@ -596,7 +596,7 @@ static void read_buf_callback(struct urb *urb)
if (data == NULL)
dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__);
if (tty && urb->actual_length && data) {
tty_insert_flip_string(tty, data, urb->actual_length);
tty_insert_flip_string(&port->port, data, urb->actual_length);
tty_flip_buffer_push(tty);
}
tty_kref_put(tty);

View File

@@ -472,7 +472,8 @@ static void usa28_indat_callback(struct urb *urb)
tty = tty_port_tty_get(&port->port);
if (tty && urb->actual_length) {
tty_insert_flip_string(tty, data, urb->actual_length);
tty_insert_flip_string(&port->port, data,
urb->actual_length);
tty_flip_buffer_push(tty);
}
tty_kref_put(tty);
@@ -688,7 +689,7 @@ static void usa49_indat_callback(struct urb *urb)
/* 0x80 bit is error flag */
if ((data[0] & 0x80) == 0) {
/* no error on any byte */
tty_insert_flip_string(tty, data + 1,
tty_insert_flip_string(&port->port, data + 1,
urb->actual_length - 1);
} else {
/* some bytes had errors, every byte has status */
@@ -816,7 +817,8 @@ static void usa90_indat_callback(struct urb *urb)
otherwise looks like usa26 data format */
if (p_priv->baud > 57600)
tty_insert_flip_string(tty, data, urb->actual_length);
tty_insert_flip_string(&port->port, data,
urb->actual_length);
else {
/* 0x80 bit is error flag */
if ((data[0] & 0x80) == 0) {

View File

@@ -166,7 +166,7 @@ static void keyspan_pda_rx_interrupt(struct urb *urb)
tty = tty_port_tty_get(&port->port);
/* rest of message is rx data */
if (tty && urb->actual_length) {
tty_insert_flip_string(tty, data + 1,
tty_insert_flip_string(&port->port, data + 1,
urb->actual_length - 1);
tty_flip_buffer_push(tty);
}

View File

@@ -411,7 +411,7 @@ static void klsi_105_process_read_urb(struct urb *urb)
len = urb->actual_length - KLSI_HDR_LEN;
}
tty_insert_flip_string(tty, data + KLSI_HDR_LEN, len);
tty_insert_flip_string(&port->port, data + KLSI_HDR_LEN, len);
tty_flip_buffer_push(tty);
tty_kref_put(tty);
}

View File

@@ -353,7 +353,7 @@ static void kobil_read_int_callback(struct urb *urb)
*/
/* END DEBUG */
tty_insert_flip_string(tty, data, urb->actual_length);
tty_insert_flip_string(&port->port, data, urb->actual_length);
tty_flip_buffer_push(tty);
}
tty_kref_put(tty);

View File

@@ -563,7 +563,7 @@ static void mct_u232_read_int_callback(struct urb *urb)
if (urb->actual_length) {
tty = tty_port_tty_get(&port->port);
if (tty) {
tty_insert_flip_string(tty, data,
tty_insert_flip_string(&port->port, data,
urb->actual_length);
tty_flip_buffer_push(tty);
}

View File

@@ -127,7 +127,7 @@ static void metrousb_read_int_callback(struct urb *urb)
tty = tty_port_tty_get(&port->port);
if (tty && urb->actual_length) {
/* Loop through the data copying each byte to the tty layer. */
tty_insert_flip_string(tty, data, urb->actual_length);
tty_insert_flip_string(&port->port, data, urb->actual_length);
/* Force the data to the tty layer. */
tty_flip_buffer_push(tty);

View File

@@ -915,7 +915,7 @@ static void mos7720_bulk_in_callback(struct urb *urb)
tty = tty_port_tty_get(&port->port);
if (tty && urb->actual_length) {
tty_insert_flip_string(tty, data, urb->actual_length);
tty_insert_flip_string(&port->port, data, urb->actual_length);
tty_flip_buffer_push(tty);
}
tty_kref_put(tty);

View File

@@ -773,9 +773,10 @@ static void mos7840_bulk_in_callback(struct urb *urb)
usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
if (urb->actual_length) {
tty = tty_port_tty_get(&mos7840_port->port->port);
struct tty_port *tport = &mos7840_port->port->port;
tty = tty_port_tty_get(tport);
if (tty) {
tty_insert_flip_string(tty, data, urb->actual_length);
tty_insert_flip_string(tport, data, urb->actual_length);
tty_flip_buffer_push(tty);
tty_kref_put(tty);
}

View File

@@ -57,7 +57,7 @@ static void navman_read_int_callback(struct urb *urb)
tty = tty_port_tty_get(&port->port);
if (tty && urb->actual_length) {
tty_insert_flip_string(tty, data, urb->actual_length);
tty_insert_flip_string(&port->port, data, urb->actual_length);
tty_flip_buffer_push(tty);
}
tty_kref_put(tty);

View File

@@ -176,8 +176,9 @@ static void omninet_read_bulk_callback(struct urb *urb)
if (urb->actual_length && header->oh_len) {
struct tty_struct *tty = tty_port_tty_get(&port->port);
if (tty) {
tty_insert_flip_string(tty, data + OMNINET_DATAOFFSET,
header->oh_len);
tty_insert_flip_string(&port->port,
data + OMNINET_DATAOFFSET,
header->oh_len);
tty_flip_buffer_push(tty);
tty_kref_put(tty);
}

View File

@@ -57,7 +57,7 @@ static void opticon_process_data_packet(struct usb_serial_port *port,
if (!tty)
return;
tty_insert_flip_string(tty, buf, len);
tty_insert_flip_string(&port->port, buf, len);
tty_flip_buffer_push(tty);
tty_kref_put(tty);
}

View File

@@ -837,7 +837,7 @@ static void oti6858_read_bulk_callback(struct urb *urb)
tty = tty_port_tty_get(&port->port);
if (tty != NULL && urb->actual_length > 0) {
tty_insert_flip_string(tty, data, urb->actual_length);
tty_insert_flip_string(&port->port, data, urb->actual_length);
tty_flip_buffer_push(tty);
}
tty_kref_put(tty);

View File

@@ -698,7 +698,7 @@ void qt2_process_read_urb(struct urb *urb)
break;
case QT2_CONTROL_ESCAPE:
tty_buffer_request_room(&port->port, 2);
tty_insert_flip_string(tty, ch, 2);
tty_insert_flip_string(&port->port, ch, 2);
i += 2;
escapeflag = true;
break;
@@ -712,10 +712,8 @@ void qt2_process_read_urb(struct urb *urb)
continue;
}
if (tty) {
tty_buffer_request_room(&port->port, 1);
tty_insert_flip_string(tty, ch, 1);
}
tty_buffer_request_room(&port->port, 1);
tty_insert_flip_string(&port->port, ch, 1);
}
if (tty) {

View File

@@ -235,7 +235,7 @@ static void safe_process_read_urb(struct urb *urb)
dev_info(&urb->dev->dev, "%s - actual: %d\n", __func__, actual_length);
length = actual_length;
out:
tty_insert_flip_string(tty, data, length);
tty_insert_flip_string(&port->port, data, length);
tty_flip_buffer_push(tty);
err:
tty_kref_put(tty);

View File

@@ -583,7 +583,7 @@ static void sierra_indat_callback(struct urb *urb)
if (urb->actual_length) {
tty = tty_port_tty_get(&port->port);
if (tty) {
tty_insert_flip_string(tty, data,
tty_insert_flip_string(&port->port, data,
urb->actual_length);
tty_flip_buffer_push(tty);

View File

@@ -84,7 +84,8 @@ static void symbol_int_callback(struct urb *urb)
*/
tty = tty_port_tty_get(&port->port);
if (tty) {
tty_insert_flip_string(tty, &data[1], data_length);
tty_insert_flip_string(&port->port, &data[1],
data_length);
tty_flip_buffer_push(tty);
tty_kref_put(tty);
}

View File

@@ -121,7 +121,7 @@ static void ti_interrupt_callback(struct urb *urb);
static void ti_bulk_in_callback(struct urb *urb);
static void ti_bulk_out_callback(struct urb *urb);
static void ti_recv(struct device *dev, struct tty_struct *tty,
static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty,
unsigned char *data, int length);
static void ti_send(struct ti_port *tport);
static int ti_set_mcr(struct ti_port *tport, unsigned int mcr);
@@ -1155,8 +1155,7 @@ static void ti_bulk_in_callback(struct urb *urb)
dev_dbg(dev, "%s - port closed, dropping data\n",
__func__);
else
ti_recv(&urb->dev->dev, tty,
urb->transfer_buffer,
ti_recv(port, tty, urb->transfer_buffer,
urb->actual_length);
spin_lock(&tport->tp_lock);
tport->tp_icount.rx += urb->actual_length;
@@ -1210,15 +1209,15 @@ static void ti_bulk_out_callback(struct urb *urb)
}
static void ti_recv(struct device *dev, struct tty_struct *tty,
static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty,
unsigned char *data, int length)
{
int cnt;
do {
cnt = tty_insert_flip_string(tty, data, length);
cnt = tty_insert_flip_string(&port->port, data, length);
if (cnt < length) {
dev_err(dev, "%s - dropping data, %d bytes lost\n",
dev_err(&port->dev, "%s - dropping data, %d bytes lost\n",
__func__, length - cnt);
if (cnt == 0)
break;

View File

@@ -291,7 +291,7 @@ static void usb_wwan_indat_callback(struct urb *urb)
tty = tty_port_tty_get(&port->port);
if (tty) {
if (urb->actual_length) {
tty_insert_flip_string(tty, data,
tty_insert_flip_string(&port->port, data,
urb->actual_length);
tty_flip_buffer_push(tty);
} else