Commit 2f693357 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: convert more flipping functions

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

Now 4 string flipping ones are on turn:
* tty_insert_flip_string_flags
* tty_insert_flip_string_fixed_flag
* tty_prepare_flip_string
* tty_prepare_flip_string_flags
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 227434f8
...@@ -232,7 +232,7 @@ static void dgrp_input(struct ch_struct *ch) ...@@ -232,7 +232,7 @@ static void dgrp_input(struct ch_struct *ch)
(nd->nd_dpa_port == PORT_NUM(MINOR(tty_devnum(tty))))) (nd->nd_dpa_port == PORT_NUM(MINOR(tty_devnum(tty)))))
dgrp_dpa_data(nd, 1, myflipbuf, len); dgrp_dpa_data(nd, 1, myflipbuf, len);
tty_insert_flip_string_flags(tty, myflipbuf, tty_insert_flip_string_flags(&ch->port, myflipbuf,
myflipflagbuf, len); myflipflagbuf, len);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
......
...@@ -507,7 +507,8 @@ static void fwtty_emit_breaks(struct work_struct *work) ...@@ -507,7 +507,8 @@ static void fwtty_emit_breaks(struct work_struct *work)
while (n) { while (n) {
t = min(n, 16); t = min(n, 16);
c = tty_insert_flip_string_fixed_flag(tty, buf, TTY_BREAK, t); c = tty_insert_flip_string_fixed_flag(&port->port, buf,
TTY_BREAK, t);
n -= c; n -= c;
brk += c; brk += c;
if (c < t) if (c < t)
...@@ -535,7 +536,7 @@ static void fwtty_pushrx(struct work_struct *work) ...@@ -535,7 +536,7 @@ static void fwtty_pushrx(struct work_struct *work)
spin_lock_bh(&port->lock); spin_lock_bh(&port->lock);
list_for_each_entry_safe(buf, next, &port->buf_list, list) { list_for_each_entry_safe(buf, next, &port->buf_list, list) {
n = tty_insert_flip_string_fixed_flag(tty, buf->data, n = tty_insert_flip_string_fixed_flag(&port->port, buf->data,
TTY_NORMAL, buf->n); TTY_NORMAL, buf->n);
c += n; c += n;
port->buffered -= n; port->buffered -= n;
...@@ -630,7 +631,8 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) ...@@ -630,7 +631,8 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len)
} }
if (!test_bit(BUFFERING_RX, &port->flags)) { if (!test_bit(BUFFERING_RX, &port->flags)) {
c = tty_insert_flip_string_fixed_flag(tty, data, TTY_NORMAL, n); c = tty_insert_flip_string_fixed_flag(&port->port, data,
TTY_NORMAL, n);
if (c > 0) if (c > 0)
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
n -= c; n -= c;
......
...@@ -968,7 +968,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty) ...@@ -968,7 +968,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty)
for performance, but because of buffer boundaries, there for performance, but because of buffer boundaries, there
may be several steps to the operation */ may be several steps to the operation */
while (1) { while (1) {
len = tty_prepare_flip_string(tty, &buf, len = tty_prepare_flip_string(port, &buf,
char_count); char_count);
if (!len) if (!len)
break; break;
......
...@@ -650,8 +650,8 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) ...@@ -650,8 +650,8 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
break; break;
} }
} else { /* Data Packet */ } else { /* Data Packet */
count = tty_prepare_flip_string(&port->port, &rp,
count = tty_prepare_flip_string(tty, &rp, byte_count & ~1); byte_count & ~1);
pr_debug("%s: Can rx %d of %d bytes.\n", pr_debug("%s: Can rx %d of %d bytes.\n",
__func__, count, byte_count); __func__, count, byte_count);
word_count = count >> 1; word_count = count >> 1;
......
...@@ -1966,7 +1966,7 @@ static int MoxaPortReadData(struct moxa_port *port) ...@@ -1966,7 +1966,7 @@ static int MoxaPortReadData(struct moxa_port *port)
ofs = baseAddr + DynPage_addr + bufhead + head; ofs = baseAddr + DynPage_addr + bufhead + head;
len = (tail >= head) ? (tail - head) : len = (tail >= head) ? (tail - head) :
(rx_mask + 1 - head); (rx_mask + 1 - head);
len = tty_prepare_flip_string(tty, &dst, len = tty_prepare_flip_string(&port->port, &dst,
min(len, count)); min(len, count));
memcpy_fromio(dst, ofs, len); memcpy_fromio(dst, ofs, len);
head = (head + len) & rx_mask; head = (head + len) & rx_mask;
...@@ -1978,7 +1978,7 @@ static int MoxaPortReadData(struct moxa_port *port) ...@@ -1978,7 +1978,7 @@ static int MoxaPortReadData(struct moxa_port *port)
while (count > 0) { while (count > 0) {
writew(pageno, baseAddr + Control_reg); writew(pageno, baseAddr + Control_reg);
ofs = baseAddr + DynPage_addr + pageofs; ofs = baseAddr + DynPage_addr + pageofs;
len = tty_prepare_flip_string(tty, &dst, len = tty_prepare_flip_string(&port->port, &dst,
min(Page_size - pageofs, count)); min(Page_size - pageofs, count));
memcpy_fromio(dst, ofs, len); memcpy_fromio(dst, ofs, len);
......
...@@ -399,7 +399,7 @@ static void rp_do_receive(struct r_port *info, ...@@ -399,7 +399,7 @@ static void rp_do_receive(struct r_port *info,
* characters at time by doing repeated word IO * characters at time by doing repeated word IO
* transfer. * transfer.
*/ */
space = tty_prepare_flip_string(tty, &cbuf, ToRecv); space = tty_prepare_flip_string(&info->port, &cbuf, ToRecv);
if (space < ToRecv) { if (space < ToRecv) {
#ifdef ROCKET_DEBUG_RECEIVE #ifdef ROCKET_DEBUG_RECEIVE
printk(KERN_INFO "rp_do_receive:insufficient space ToRecv=%d space=%d\n", ToRecv, space); printk(KERN_INFO "rp_do_receive:insufficient space ToRecv=%d space=%d\n", ToRecv, space);
......
...@@ -70,7 +70,7 @@ static void smd_tty_notify(void *priv, unsigned event) ...@@ -70,7 +70,7 @@ static void smd_tty_notify(void *priv, unsigned event)
if (avail == 0) if (avail == 0)
break; break;
avail = tty_prepare_flip_string(tty, &ptr, avail); avail = tty_prepare_flip_string(&info->port, &ptr, avail);
if (smd_read(info->ch, ptr, avail) != avail) { if (smd_read(info->ch, ptr, avail) != avail) {
/* shouldn't be possible since we're in interrupt /* shouldn't be possible since we're in interrupt
......
...@@ -257,7 +257,7 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room); ...@@ -257,7 +257,7 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room);
/** /**
* tty_insert_flip_string_fixed_flag - Add characters to the tty buffer * tty_insert_flip_string_fixed_flag - Add characters to the tty buffer
* @tty: tty structure * @port: tty port
* @chars: characters * @chars: characters
* @flag: flag value for each character * @flag: flag value for each character
* @size: size * @size: size
...@@ -268,10 +268,10 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room); ...@@ -268,10 +268,10 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room);
* Locking: Called functions may take port->buf.lock * Locking: Called functions may take port->buf.lock
*/ */
int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, int tty_insert_flip_string_fixed_flag(struct tty_port *port,
const unsigned char *chars, char flag, size_t size) const unsigned char *chars, char flag, size_t size)
{ {
struct tty_bufhead *buf = &tty->port->buf; struct tty_bufhead *buf = &port->buf;
int copied = 0; int copied = 0;
do { do {
int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);
...@@ -280,7 +280,7 @@ int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, ...@@ -280,7 +280,7 @@ int tty_insert_flip_string_fixed_flag(struct tty_struct *tty,
struct tty_buffer *tb; struct tty_buffer *tb;
spin_lock_irqsave(&buf->lock, flags); spin_lock_irqsave(&buf->lock, flags);
space = __tty_buffer_request_room(tty->port, goal); space = __tty_buffer_request_room(port, goal);
tb = buf->tail; tb = buf->tail;
/* If there is no space then tb may be NULL */ /* If there is no space then tb may be NULL */
if (unlikely(space == 0)) { if (unlikely(space == 0)) {
...@@ -302,7 +302,7 @@ EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag); ...@@ -302,7 +302,7 @@ EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag);
/** /**
* tty_insert_flip_string_flags - Add characters to the tty buffer * tty_insert_flip_string_flags - Add characters to the tty buffer
* @tty: tty structure * @port: tty port
* @chars: characters * @chars: characters
* @flags: flag bytes * @flags: flag bytes
* @size: size * @size: size
...@@ -314,10 +314,10 @@ EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag); ...@@ -314,10 +314,10 @@ EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag);
* Locking: Called functions may take port->buf.lock * Locking: Called functions may take port->buf.lock
*/ */
int tty_insert_flip_string_flags(struct tty_struct *tty, int tty_insert_flip_string_flags(struct tty_port *port,
const unsigned char *chars, const char *flags, size_t size) const unsigned char *chars, const char *flags, size_t size)
{ {
struct tty_bufhead *buf = &tty->port->buf; struct tty_bufhead *buf = &port->buf;
int copied = 0; int copied = 0;
do { do {
int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);
...@@ -326,7 +326,7 @@ int tty_insert_flip_string_flags(struct tty_struct *tty, ...@@ -326,7 +326,7 @@ int tty_insert_flip_string_flags(struct tty_struct *tty,
struct tty_buffer *tb; struct tty_buffer *tb;
spin_lock_irqsave(&buf->lock, __flags); spin_lock_irqsave(&buf->lock, __flags);
space = __tty_buffer_request_room(tty->port, goal); space = __tty_buffer_request_room(port, goal);
tb = buf->tail; tb = buf->tail;
/* If there is no space then tb may be NULL */ /* If there is no space then tb may be NULL */
if (unlikely(space == 0)) { if (unlikely(space == 0)) {
...@@ -376,7 +376,7 @@ EXPORT_SYMBOL(tty_schedule_flip); ...@@ -376,7 +376,7 @@ EXPORT_SYMBOL(tty_schedule_flip);
/** /**
* tty_prepare_flip_string - make room for characters * tty_prepare_flip_string - make room for characters
* @tty: tty * @port: tty port
* @chars: return pointer for character write area * @chars: return pointer for character write area
* @size: desired size * @size: desired size
* *
...@@ -389,16 +389,16 @@ EXPORT_SYMBOL(tty_schedule_flip); ...@@ -389,16 +389,16 @@ EXPORT_SYMBOL(tty_schedule_flip);
* Locking: May call functions taking port->buf.lock * Locking: May call functions taking port->buf.lock
*/ */
int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, int tty_prepare_flip_string(struct tty_port *port, unsigned char **chars,
size_t size) size_t size)
{ {
struct tty_bufhead *buf = &tty->port->buf; struct tty_bufhead *buf = &port->buf;
int space; int space;
unsigned long flags; unsigned long flags;
struct tty_buffer *tb; struct tty_buffer *tb;
spin_lock_irqsave(&buf->lock, flags); spin_lock_irqsave(&buf->lock, flags);
space = __tty_buffer_request_room(tty->port, size); space = __tty_buffer_request_room(port, size);
tb = buf->tail; tb = buf->tail;
if (likely(space)) { if (likely(space)) {
...@@ -413,7 +413,7 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string); ...@@ -413,7 +413,7 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string);
/** /**
* tty_prepare_flip_string_flags - make room for characters * tty_prepare_flip_string_flags - make room for characters
* @tty: tty * @port: tty port
* @chars: return pointer for character write area * @chars: return pointer for character write area
* @flags: return pointer for status flag write area * @flags: return pointer for status flag write area
* @size: desired size * @size: desired size
...@@ -427,16 +427,16 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string); ...@@ -427,16 +427,16 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string);
* Locking: May call functions taking port->buf.lock * Locking: May call functions taking port->buf.lock
*/ */
int tty_prepare_flip_string_flags(struct tty_struct *tty, int tty_prepare_flip_string_flags(struct tty_port *port,
unsigned char **chars, char **flags, size_t size) unsigned char **chars, char **flags, size_t size)
{ {
struct tty_bufhead *buf = &tty->port->buf; struct tty_bufhead *buf = &port->buf;
int space; int space;
unsigned long __flags; unsigned long __flags;
struct tty_buffer *tb; struct tty_buffer *tb;
spin_lock_irqsave(&buf->lock, __flags); spin_lock_irqsave(&buf->lock, __flags);
space = __tty_buffer_request_room(tty->port, size); space = __tty_buffer_request_room(port, size);
tb = buf->tail; tb = buf->tail;
if (likely(space)) { if (likely(space)) {
......
...@@ -705,7 +705,7 @@ static void ark3116_process_read_urb(struct urb *urb) ...@@ -705,7 +705,7 @@ static void ark3116_process_read_urb(struct urb *urb)
if (lsr & UART_LSR_OE) if (lsr & UART_LSR_OE)
tty_insert_flip_char(tty, 0, TTY_OVERRUN); tty_insert_flip_char(tty, 0, TTY_OVERRUN);
} }
tty_insert_flip_string_fixed_flag(tty, data, tty_flag, tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
urb->actual_length); urb->actual_length);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
tty_kref_put(tty); tty_kref_put(tty);
......
...@@ -279,7 +279,7 @@ static void belkin_sa_process_read_urb(struct urb *urb) ...@@ -279,7 +279,7 @@ static void belkin_sa_process_read_urb(struct urb *urb)
tty_insert_flip_char(tty, 0, TTY_OVERRUN); tty_insert_flip_char(tty, 0, TTY_OVERRUN);
} }
tty_insert_flip_string_fixed_flag(tty, data, tty_flag, tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
urb->actual_length); urb->actual_length);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
tty_kref_put(tty); tty_kref_put(tty);
......
...@@ -1215,7 +1215,7 @@ static void cypress_read_int_callback(struct urb *urb) ...@@ -1215,7 +1215,7 @@ static void cypress_read_int_callback(struct urb *urb)
/* process read if there is data other than line status */ /* process read if there is data other than line status */
if (tty && bytes > i) { if (tty && bytes > i) {
tty_insert_flip_string_fixed_flag(tty, data + i, tty_insert_flip_string_fixed_flag(&port->port, data + i,
tty_flag, bytes - i); tty_flag, bytes - i);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
} }
......
...@@ -1455,8 +1455,8 @@ static int digi_read_inb_callback(struct urb *urb) ...@@ -1455,8 +1455,8 @@ static int digi_read_inb_callback(struct urb *urb)
/* data length is len-1 (one byte of len is port_status) */ /* data length is len-1 (one byte of len is port_status) */
--len; --len;
if (len > 0) { if (len > 0) {
tty_insert_flip_string_fixed_flag(tty, data, flag, tty_insert_flip_string_fixed_flag(&port->port, data,
len); flag, len);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
} }
} }
......
...@@ -140,7 +140,7 @@ static void f81232_process_read_urb(struct urb *urb) ...@@ -140,7 +140,7 @@ static void f81232_process_read_urb(struct urb *urb)
if (!usb_serial_handle_sysrq_char(port, data[i])) if (!usb_serial_handle_sysrq_char(port, data[i]))
tty_insert_flip_char(tty, data[i], tty_flag); tty_insert_flip_char(tty, data[i], tty_flag);
} else { } else {
tty_insert_flip_string_fixed_flag(tty, data, tty_flag, tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
urb->actual_length); urb->actual_length);
} }
......
...@@ -2032,7 +2032,7 @@ static int ftdi_process_packet(struct tty_struct *tty, ...@@ -2032,7 +2032,7 @@ static int ftdi_process_packet(struct tty_struct *tty,
tty_insert_flip_char(tty, *ch, flag); tty_insert_flip_char(tty, *ch, flag);
} }
} else { } else {
tty_insert_flip_string_fixed_flag(tty, ch, flag, len); tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len);
} }
return len; return len;
......
...@@ -812,7 +812,7 @@ static void pl2303_process_read_urb(struct urb *urb) ...@@ -812,7 +812,7 @@ static void pl2303_process_read_urb(struct urb *urb)
if (!usb_serial_handle_sysrq_char(port, data[i])) if (!usb_serial_handle_sysrq_char(port, data[i]))
tty_insert_flip_char(tty, data[i], tty_flag); tty_insert_flip_char(tty, data[i], tty_flag);
} else { } else {
tty_insert_flip_string_fixed_flag(tty, data, tty_flag, tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
urb->actual_length); urb->actual_length);
} }
......
...@@ -505,7 +505,7 @@ static void spcp8x5_process_read_urb(struct urb *urb) ...@@ -505,7 +505,7 @@ static void spcp8x5_process_read_urb(struct urb *urb)
priv->line_status & MSR_STATUS_LINE_DCD); priv->line_status & MSR_STATUS_LINE_DCD);
} }
tty_insert_flip_string_fixed_flag(tty, data, tty_flag, tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
urb->actual_length); urb->actual_length);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
tty_kref_put(tty); tty_kref_put(tty);
......
...@@ -617,7 +617,7 @@ static int ssu100_process_packet(struct urb *urb, ...@@ -617,7 +617,7 @@ static int ssu100_process_packet(struct urb *urb,
tty_insert_flip_char(tty, *ch, flag); tty_insert_flip_char(tty, *ch, flag);
} }
} else } else
tty_insert_flip_string_fixed_flag(tty, ch, flag, len); tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len);
return len; return len;
} }
......
...@@ -2,10 +2,14 @@ ...@@ -2,10 +2,14 @@
#define _LINUX_TTY_FLIP_H #define _LINUX_TTY_FLIP_H
extern int tty_buffer_request_room(struct tty_port *port, size_t size); extern int tty_buffer_request_room(struct tty_port *port, size_t size);
extern int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size); extern int tty_insert_flip_string_flags(struct tty_port *port,
extern int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, const unsigned char *chars, char flag, size_t size); const unsigned char *chars, const char *flags, size_t size);
extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); extern int tty_insert_flip_string_fixed_flag(struct tty_port *port,
extern int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size); const unsigned char *chars, char flag, size_t size);
extern int tty_prepare_flip_string(struct tty_port *port,
unsigned char **chars, size_t size);
extern int tty_prepare_flip_string_flags(struct tty_port *port,
unsigned char **chars, char **flags, size_t size);
void tty_schedule_flip(struct tty_struct *tty); void tty_schedule_flip(struct tty_struct *tty);
static inline int tty_insert_flip_char(struct tty_struct *tty, static inline int tty_insert_flip_char(struct tty_struct *tty,
...@@ -17,12 +21,12 @@ static inline int tty_insert_flip_char(struct tty_struct *tty, ...@@ -17,12 +21,12 @@ static inline int tty_insert_flip_char(struct tty_struct *tty,
tb->char_buf_ptr[tb->used++] = ch; tb->char_buf_ptr[tb->used++] = ch;
return 1; return 1;
} }
return tty_insert_flip_string_flags(tty, &ch, &flag, 1); return tty_insert_flip_string_flags(tty->port, &ch, &flag, 1);
} }
static inline int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size) static inline int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size)
{ {
return tty_insert_flip_string_fixed_flag(tty, chars, TTY_NORMAL, size); return tty_insert_flip_string_fixed_flag(tty->port, chars, TTY_NORMAL, size);
} }
#endif /* _LINUX_TTY_FLIP_H */ #endif /* _LINUX_TTY_FLIP_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment