mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-17 02:36:21 +00:00
tty: tty_buffer: use __tty_insert_flip_string_flags() in tty_insert_flip_char()
Use __tty_insert_flip_string_flags() for the slow path of tty_insert_flip_char(). The former is generic enough, so there is no reason to reimplement the injection once again. So now we have a single function stuffing into tty buffers. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230816105530.3335-8-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2ce2983c24
commit
b49a0ff732
@ -15,11 +15,12 @@ Flip Buffer Management
|
|||||||
======================
|
======================
|
||||||
|
|
||||||
.. kernel-doc:: drivers/tty/tty_buffer.c
|
.. kernel-doc:: drivers/tty/tty_buffer.c
|
||||||
:identifiers: tty_prepare_flip_string __tty_insert_flip_char
|
:identifiers: tty_prepare_flip_string
|
||||||
tty_flip_buffer_push tty_ldisc_receive_buf
|
tty_flip_buffer_push tty_ldisc_receive_buf
|
||||||
|
|
||||||
.. kernel-doc:: include/linux/tty_flip.h
|
.. kernel-doc:: include/linux/tty_flip.h
|
||||||
:identifiers: tty_insert_flip_string_fixed_flag tty_insert_flip_string_flags
|
:identifiers: tty_insert_flip_string_fixed_flag tty_insert_flip_string_flags
|
||||||
|
tty_insert_flip_char
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -343,32 +343,6 @@ size_t __tty_insert_flip_string_flags(struct tty_port *port, const u8 *chars,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__tty_insert_flip_string_flags);
|
EXPORT_SYMBOL(__tty_insert_flip_string_flags);
|
||||||
|
|
||||||
/**
|
|
||||||
* __tty_insert_flip_char - add one character to the tty buffer
|
|
||||||
* @port: tty port
|
|
||||||
* @ch: character
|
|
||||||
* @flag: flag byte
|
|
||||||
*
|
|
||||||
* Queue a single byte @ch to the tty buffering, with an optional flag. This is
|
|
||||||
* the slow path of tty_insert_flip_char().
|
|
||||||
*/
|
|
||||||
int __tty_insert_flip_char(struct tty_port *port, u8 ch, u8 flag)
|
|
||||||
{
|
|
||||||
struct tty_buffer *tb;
|
|
||||||
bool flags = flag != TTY_NORMAL;
|
|
||||||
|
|
||||||
if (!__tty_buffer_request_room(port, 1, flags))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
tb = port->buf.tail;
|
|
||||||
if (tb->flags)
|
|
||||||
*flag_buf_ptr(tb, tb->used) = flag;
|
|
||||||
*char_buf_ptr(tb, tb->used++) = ch;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(__tty_insert_flip_char);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tty_prepare_flip_string - make room for characters
|
* tty_prepare_flip_string - make room for characters
|
||||||
* @port: tty port
|
* @port: tty port
|
||||||
|
@ -15,7 +15,6 @@ size_t __tty_insert_flip_string_flags(struct tty_port *port, const u8 *chars,
|
|||||||
size_t size);
|
size_t size);
|
||||||
size_t tty_prepare_flip_string(struct tty_port *port, u8 **chars, size_t size);
|
size_t tty_prepare_flip_string(struct tty_port *port, u8 **chars, size_t size);
|
||||||
void tty_flip_buffer_push(struct tty_port *port);
|
void tty_flip_buffer_push(struct tty_port *port);
|
||||||
int __tty_insert_flip_char(struct tty_port *port, u8 ch, u8 flag);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tty_insert_flip_string_fixed_flag - add characters to the tty buffer
|
* tty_insert_flip_string_fixed_flag - add characters to the tty buffer
|
||||||
@ -55,7 +54,14 @@ static inline size_t tty_insert_flip_string_flags(struct tty_port *port,
|
|||||||
return __tty_insert_flip_string_flags(port, chars, flags, true, size);
|
return __tty_insert_flip_string_flags(port, chars, flags, true, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tty_insert_flip_char - add one character to the tty buffer
|
||||||
|
* @port: tty port
|
||||||
|
* @ch: character
|
||||||
|
* @flag: flag byte
|
||||||
|
*
|
||||||
|
* Queue a single byte @ch to the tty buffering, with an optional flag.
|
||||||
|
*/
|
||||||
static inline size_t tty_insert_flip_char(struct tty_port *port, u8 ch, u8 flag)
|
static inline size_t tty_insert_flip_char(struct tty_port *port, u8 ch, u8 flag)
|
||||||
{
|
{
|
||||||
struct tty_buffer *tb = port->buf.tail;
|
struct tty_buffer *tb = port->buf.tail;
|
||||||
@ -68,7 +74,7 @@ static inline size_t tty_insert_flip_char(struct tty_port *port, u8 ch, u8 flag)
|
|||||||
*char_buf_ptr(tb, tb->used++) = ch;
|
*char_buf_ptr(tb, tb->used++) = ch;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return __tty_insert_flip_char(port, ch, flag);
|
return __tty_insert_flip_string_flags(port, &ch, &flag, false, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t tty_insert_flip_string(struct tty_port *port,
|
static inline size_t tty_insert_flip_string(struct tty_port *port,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user