tty: cleanup no. 99
Subsystems (13)
Jiri Slaby (SUSE)
maintainerv2 cover tty: cleanup no. 99
Hi,
this is (again) a series of cleanup in tty. I am trying to rework tty+serial to avoid limitations of devices (so called NR_UART or tty_alloc_driver()'s first parameter). And the below popped up while crawling through the code. So this is only a prep cleanup.
* many tty flags are now enums
* many functions were improved for readability
* quite a few unused or old code dropped
In particular, the runtime behaviour of the kernel before and after the changes is supposed to be bug to bug compatible (except moxa's ioctl and ISA evils dropped). That is, noone should notice.
[v2]
* use serial_port_in/out() helpers in 26/30 (and not use serial_in/out())
* the last patch is new
Jiri Slaby (SUSE) (31):
tty: convert "TTY Struct Flags" to an enum
tty: audit: do not use N_TTY_BUF_SIZE
tty: caif: do not use N_TTY_BUF_SIZE
tty: move N_TTY_BUF_SIZE to n_tty
tty: n_tty: use uint for space returned by tty_write_room()
tty: n_tty: simplify process_output()
tty: n_tty: clean up process_output_block()
tty: n_tty: drop n_tty_trace()
tty: n_tty: extract n_tty_continue_cookie() from n_tty_read()
tty: n_tty: extract n_tty_wait_for_input()
tty: n_tty: move more_to_be_read to the end of n_tty_read()
tty: tty_driver: move TTY macros to the top
tty: tty_driver: convert "TTY Driver Flags" to an enum
tty: tty_driver: document both {,__}tty_alloc_driver() properly
tty: tty_driver: introduce TTY driver sub/types enums
tty: serdev: drop serdev_controller_ops::write_room()
tty: mmc: sdio: use bool for cts and remove parentheses
tty: moxa: drop version dump to logs
tty: moxa: drop ISA support
tty: moxa: carve out special ioctls and extra tty_port
tty: srmcons: fix retval from srmcons_init()
tty: staging/greybus: pass tty_driver flags to tty_alloc_driver()
tty: sunsu: drop serial_{in,out}p()
tty: sunsu: remove unused serial_icr_read()
serial: remove redundant tty_port_link_device()
serial: pass struct uart_state to uart_line_info()
serial: 8250: use serial_port_in/out() helpers
serial: 8250_rsa: simplify rsa8250_{request/release}_resource()
serial: 8250_port: do not use goto for UPQ_NO_TXEN_TEST code flow
serial: 8250_port: simplify serial8250_request_std_resource()
serial: switch change_irq and change_port to bool in uart_set_info()
Documentation/driver-api/tty/tty_driver.rst | 4 +- Documentation/driver-api/tty/tty_struct.rst | 2 +- arch/alpha/kernel/srmcons.c | 62 ++--- drivers/mmc/core/sdio_uart.c | 2 +- drivers/net/caif/caif_serial.c | 2 +- drivers/staging/greybus/uart.c | 4 +- drivers/tty/Kconfig | 2 +- drivers/tty/moxa.c | 251 +------------------- drivers/tty/n_tty.c | 212 ++++++++--------- drivers/tty/serdev/core.c | 11 - drivers/tty/serdev/serdev-ttyport.c | 9 - drivers/tty/serial/8250/8250_dw.c | 16 +- drivers/tty/serial/8250/8250_fsl.c | 8 +- drivers/tty/serial/8250/8250_omap.c | 2 +- drivers/tty/serial/8250/8250_port.c | 59 ++--- drivers/tty/serial/8250/8250_rsa.c | 21 +- drivers/tty/serial/serial_core.c | 10 +- drivers/tty/serial/sunsu.c | 178 ++++++-------- drivers/tty/tty_audit.c | 10 +- drivers/tty/tty_io.c | 8 +- include/linux/serdev.h | 6 - include/linux/tty.h | 53 +++-- include/linux/tty_driver.h | 180 +++++++------- 23 files changed, 412 insertions(+), 700 deletions(-)
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 1/31 tty: convert "TTY Struct Flags" to an enum
Convert TTY_* macros (flags) to an enum. This allows for easier kernel-doc (the comment needed fine tuning), grouping of these nicely, and proper checking.
Note that these are bit positions. So they are used such as test_bit(TTY_THROTTLED, ...). Given these are not the user API (only in-kernel API/ABI), the bit positions are NOT preserved in this patch. All are renumbered naturally using the enum-auto-numbering.
--- Documentation/driver-api/tty/tty_struct.rst | 2 +- include/linux/tty.h | 52 +++++++++++---------- 2 files changed, 28 insertions(+), 26 deletions(-)
Documentation/driver-api/tty/tty_struct.rst +1 -1
@@ -72,7 +72,7 @@ TTY Struct Flags ================ .. kernel-doc:: include/linux/tty.h - :doc: TTY Struct Flags + :identifiers: tty_struct_flags TTY Struct Reference ====================
include/linux/tty.h +27 -25
96 lines not on this page · raw message
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 2/31 tty: audit: do not use N_TTY_BUF_SIZE
In reply to Jiri Slaby (SUSE)N_TTY_BUF_SIZE -- as the name suggests -- is the N_TTY's buffer size. There is no reason to couple that to audit's buffer size, so define an own TTY_AUDIT_BUF_SIZE macro (with the same size).
N_TTY_BUF_SIZE is private and will be moved to n_tty.c later.
--- drivers/tty/tty_audit.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/tty/tty_audit.c +6 -4
@@ -12,12 +12,14 @@#include <linux/tty.h> #include "tty.h" +#define TTY_AUDIT_BUF_SIZE 4096 +struct tty_audit_buf {struct mutex mutex;/* Protects all data below */ dev_t dev;/* The TTY which the data is from */ bool icanon;size_t valid; -u8 *data;/* Allocated size N_TTY_BUF_SIZE */ +u8 *data;/* Allocated size TTY_AUDIT_BUF_SIZE */ };static struct tty_audit_buf *tty_audit_buf_ref (void )
@@ -37,7 +39,7 @@ static struct tty_audit_buf *tty_audit_buf_alloc(void)if (!buf) goto err; - buf->data =kmalloc (N_TTY_BUF_SIZE ,GFP_KERNEL ); + buf->data =kmalloc (TTY_AUDIT_BUF_SIZE ,GFP_KERNEL );if (!buf->data) goto err_buf;
@@ -235,14 +237,14 @@ void tty_audit_add_data(const struct tty_struct *tty, const void *data,do {size_t run; - run =N_TTY_BUF_SIZE - buf->valid; + run =TTY_AUDIT_BUF_SIZE - buf->valid;if (run > size) run = size;memcpy (buf->data + buf->valid, data, run); buf->valid += run; data += run; size -= run; -if (buf->valid ==N_TTY_BUF_SIZE ) +if (buf->valid ==TTY_AUDIT_BUF_SIZE )tty_audit_buf_push (buf); }while (size !=0 );mutex_unlock (&buf->mutex);
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 3/31 tty: caif: do not use N_TTY_BUF_SIZE
In reply to Jiri Slaby (SUSE)N_TTY_BUF_SIZE -- as the name suggests -- is the N_TTY's buffer size. There is no reason to couple that to caif's tty->receive_room. Use 4096 directly -- even though, it should be some sort of "SKB_MAX_ALLOC" or alike. But definitely not N_TTY_BUF_SIZE.
N_TTY_BUF_SIZE is private and will be moved to n_tty.c later.
--- drivers/net/caif/caif_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/caif/caif_serial.c +1 -1
@@ -344,7 +344,7 @@ static int ldisc_open(struct tty_struct *tty) ser->tty =tty_kref_get (tty); ser->dev = dev;debugfs_init (ser, tty); - tty->receive_room =N_TTY_BUF_SIZE ; + tty->receive_room =4096 ; tty->disc_data = ser;set_bit (TTY_DO_WRITE_WAKEUP , &tty->flags);rtnl_lock ();
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 4/31 tty: move N_TTY_BUF_SIZE to n_tty
In reply to Jiri Slaby (SUSE)"N_TTY_BUF_SIZE" is private to n_tty and shall not be exposed to the world. Definitely not in tty.h somewhere in the middle of "struct tty_struct".
This is a remnant of moving "read_flags" to "struct n_tty_data" in commit 3fe780b379fa ("TTY: move ldisc data from tty_struct: bitmaps"). But some cleanup was needed first (in previous patches).
--- drivers/tty/n_tty.c | 2 ++ include/linux/tty.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/tty/n_tty.c +2 -0
@@ -56,6 +56,8 @@*/ #define WAKEUP_CHARS 256 +#define N_TTY_BUF_SIZE 4096 +/* * This defines the low- and high-watermarks for throttling and * unthrottling the TTY driver. These watermarks are used for
include/linux/tty.h +0 -1
@@ -239,7 +239,6 @@ struct tty_struct {struct list_head tty_files; -#define N_TTY_BUF_SIZE 4096struct work_struct SAK_work; } __randomize_layout;
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 5/31 tty: n_tty: use uint for space returned by tty_write_room()
In reply to Jiri Slaby (SUSE)tty_write_room() returns an "unsigned int". So in case some insane driver (like my tty test driver) returns (legitimate) UINT_MAX from its tty_operations::write_room(), n_tty is confused on several places.
For example, in process_output_block(), the result of tty_write_room() is stored into (signed) "int". So this UINT_MAX suddenly becomes -1. And that is extended to ssize_t and returned from process_output_block(). This causes a write() to such a node to receive -EPERM (which is -1).
Fix that by using proper "unsigned int" and proper "== 0" test. And return 0 constant directly in that "if", so that it is immediately clear what is returned ("space" equals to 0 at that point).
Similarly for process_output() and __process_echoes().
Note this does not fix any in-tree driver as of now.
If you want "Fixes: something", it would be commit 03b3b1a2405c ("tty:
make tty_operations::write_room return uint"). I intentionally do not mark this patch by a real tag below.
--- drivers/tty/n_tty.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/tty/n_tty.c +7 -6
@@ -488,7 +488,8 @@ static int do_output_char(u8 c, struct tty_struct *tty, int space)static int process_output (u8 c,struct tty_struct *tty) {struct n_tty_data *ldata = tty->disc_data; -int space, retval; +unsigned int space; +int retval;mutex_lock (&ldata->output_lock);
@@ -524,16 +525,16 @@ static ssize_t process_output_block(struct tty_struct *tty, const u8 *buf, unsigned int nr) {struct n_tty_data *ldata = tty->disc_data; -int space; -int i; +unsigned int space; +int i;const u8 *cp;mutex_lock (&ldata->output_lock); space =tty_write_room (tty); -if (space <=0 ) { +if (space ==0 ) {mutex_unlock (&ldata->output_lock); -return space; +return 0 ; }if (nr > space) nr = space;
@@ -698,7 +699,7 @@ static int n_tty_process_echo_ops(struct tty_struct *tty, size_t *tail,static size_t __process_echoes (struct tty_struct *tty) {struct n_tty_data *ldata = tty->disc_data; -int space, old_space; +unsigned int space, old_space;size_t tail;u8 c;
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 6/31 tty: n_tty: simplify process_output()
In reply to Jiri Slaby (SUSE)Using guard(mutex), the function can be written in a much more efficient way.
--- drivers/tty/n_tty.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/tty/n_tty.c +4 -10
@@ -488,19 +488,13 @@ static int do_output_char(u8 c, struct tty_struct *tty, int space)static int process_output (u8 c,struct tty_struct *tty) {struct n_tty_data *ldata = tty->disc_data; -unsigned int space; -int retval; -mutex_lock (&ldata->output_lock); +guard (mutex)(&ldata->output_lock); - space =tty_write_room (tty); - retval =do_output_char (c, tty, space); - -mutex_unlock (&ldata->output_lock); -if (retval <0 ) +if (do_output_char (c, tty,tty_write_room (tty)) <0 )return -1 ; -else -return 0 ; + +return 0 ; }/**
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 7/31 tty: n_tty: clean up process_output_block()
In reply to Jiri Slaby (SUSE)* Use guard(mutex), which results in:
- the function can return directly when "space == 0".
- "i" can now be "unsigned" as it is no longer abused to hold a retval
from tty->ops->write(). Note the compared-to "nr" is already
"unsigned".* The end label is now dubbed "do_write" as that is what happens there. Unlike the uncertain "break_out" name.
--- drivers/tty/n_tty.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-)
drivers/tty/n_tty.c +11 -16
@@ -519,17 +519,15 @@ static ssize_t process_output_block(struct tty_struct *tty, const u8 *buf, unsigned int nr) {struct n_tty_data *ldata = tty->disc_data; -unsigned int space; -int i; +unsigned int space, i;const u8 *cp; -mutex_lock (&ldata->output_lock); +guard (mutex)(&ldata->output_lock); space =tty_write_room (tty); -if (space ==0 ) { -mutex_unlock (&ldata->output_lock); +if (space ==0 )return 0 ; - } +if (nr > space) nr = space;
@@ -541,18 +539,18 @@ static ssize_t process_output_block(struct tty_struct *tty,if (O_ONLRET (tty)) ldata->column =0 ;if (O_ONLCR (tty)) - goto break_out; + goto do_write; ldata->canon_column = ldata->column;break ;case '\r' :if (O_ONOCR (tty) && ldata->column ==0 ) - goto break_out; + goto do_write;if (O_OCRNL (tty)) - goto break_out; + goto do_write; ldata->canon_column = ldata->column =0 ;break ;case '\t' : - goto break_out; + goto do_write;case '\b' :if (ldata->column >0 ) ldata->column--;
@@ -560,18 +558,15 @@ static ssize_t process_output_block(struct tty_struct *tty,default :if (!iscntrl (c)) {if (O_OLCUC (tty)) - goto break_out; + goto do_write;if (!is_continuation (c, tty)) ldata->column++; }break ; } } -break_out: - i = tty->ops->write (tty, buf, i); - -mutex_unlock (&ldata->output_lock); -return i; +do_write: +return tty->ops->write (tty, buf, i); } static int n_tty_process_echo_ops(struct tty_struct *tty, size_t *tail,
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 8/31 tty: n_tty: drop n_tty_trace()
In reply to Jiri Slaby (SUSE)This n_tty_trace() is an always disabled debugging macro. It comes from commit 32f13521ca68 ("n_tty: Line copy to user buffer in canonical mode").
Drop it as it is dead for over a decade.
--- drivers/tty/n_tty.c | 14 -------------- 1 file changed, 14 deletions(-)
drivers/tty/n_tty.c +0 -14
@@ -81,14 +81,6 @@#define ECHO_BLOCK 256#define ECHO_DISCARD_WATERMARK N_TTY_BUF_SIZE - (ECHO_BLOCK + 32) - -#undef N_TTY_TRACE -#ifdef N_TTY_TRACE -# define n_tty_trace(f, args...) trace_printk(f, ##args) -#else -# define n_tty_trace(f, args...) no_printk(f, ##args) -#endif -struct n_tty_data {/* producer-published */ size_t read_head;
@@ -2026,9 +2018,6 @@ static bool canon_copy_from_read_buf(const struct tty_struct *tty, u8 **kbp, tail =MASK (ldata->read_tail); size =min_t (size_t, tail + n,N_TTY_BUF_SIZE ); -n_tty_trace ("%s: nr:%zu tail:%zu n:%zu size:%zu\n" , - __func__, *nr, tail, n, size); - eol =find_next_bit (ldata->read_flags, size, tail); more = n - (size - tail);if (eol ==N_TTY_BUF_SIZE && more) {
@@ -2046,9 +2035,6 @@ static bool canon_copy_from_read_buf(const struct tty_struct *tty, u8 **kbp,if (!found ||read_buf (ldata, eol) != __DISABLED_CHAR) n = c; -n_tty_trace ("%s: eol:%zu found:%d n:%zu c:%zu tail:%zu more:%zu\n" , - __func__, eol, found, n, c, tail, more); -tty_copy (tty, *kbp, tail, n); *kbp += n; *nr -= n;
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 9/31 tty: n_tty: extract n_tty_continue_cookie() from n_tty_read()
In reply to Jiri Slaby (SUSE)n_tty_read() is a very long function doing too much of different stuff. Extract the "cookie" (continuation read) handling to a separate
function: n_tty_continue_cookie().
--- drivers/tty/n_tty.c | 66 ++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 30 deletions(-)
drivers/tty/n_tty.c +36 -30
@@ -2111,6 +2111,39 @@ static int job_control(struct tty_struct *tty, struct file *file)return __tty_check_change (tty,SIGTTIN ); } +/* +* We still hold the atomic_read_lock and the termios_rwsem, and can just +* continue to copy data. +*/ +static ssize_t n_tty_continue_cookie (struct tty_struct *tty,u8 *kbuf, +size_t nr,void **cookie) +{ +struct n_tty_data *ldata = tty->disc_data; +u8 *kb = kbuf; + +if (ldata->icanon && !L_EXTPROC (tty)) { +/* +* If we have filled the user buffer, see if we should skip an +* EOF character before releasing the lock and returning done. +*/ +if (!nr) +canon_skip_eof (ldata); +else if (canon_copy_from_read_buf (tty, &kb, &nr)) +return kb - kbuf; + }else { +if (copy_from_read_buf (tty, &kb, &nr)) +return kb - kbuf; + } + +/* No more data - release locks and stop retries */ +n_tty_kick_worker (tty); +n_tty_check_unthrottle (tty); +up_read (&tty->termios_rwsem); +mutex_unlock (&ldata->atomic_read_lock); + *cookie =NULL ; + +return kb - kbuf; +}/** * n_tty_read - read function for tty
@@ -2144,36 +2177,9 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, u8 *kbuf,bool packet;size_t old_tail; -/* -* Is this a continuation of a read started earler? -* -* If so, we still hold the atomic_read_lock and the -* termios_rwsem, and can just continue to copy data. -*/ -if (*cookie) { -if (ldata->icanon && !L_EXTPROC (tty)) { -/* -* If we have filled the user buffer, see -* if we should skip an EOF character before -* releasing the lock and returning done. -*/ -if (!nr) -canon_skip_eof (ldata); -else if (canon_copy_from_read_buf (tty, &kb, &nr)) -return kb - kbuf; - }else { -if (copy_from_read_buf (tty, &kb, &nr)) -return kb - kbuf; - } - -/* No more data - release locks and stop retries */ -n_tty_kick_worker (tty); -n_tty_check_unthrottle (tty); -up_read (&tty->termios_rwsem); -mutex_unlock (&ldata->atomic_read_lock); - *cookie =NULL ; -return kb - kbuf; - } +/* Is this a continuation of a read started earlier? */ +if (*cookie) +return n_tty_continue_cookie (tty, kbuf, nr, cookie); retval =job_control (tty, file);if (retval <0 )
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 10/31 tty: n_tty: extract n_tty_wait_for_input()
In reply to Jiri Slaby (SUSE)n_tty_read() is a very long function doing too much of different stuff. Extract the "wait for input" to a separate function:n_tty_wait_for_input(). It returns an error (< 0), no input (0), or has potential input (1).
--- drivers/tty/n_tty.c | 57 ++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 26 deletions(-)
drivers/tty/n_tty.c +31 -26
@@ -2145,6 +2145,33 @@ static ssize_t n_tty_continue_cookie(struct tty_struct *tty, u8 *kbuf,return kb - kbuf; } +static int n_tty_wait_for_input (struct tty_struct *tty,struct file *file, +struct wait_queue_entry *wait,long *timeout) +{ +if (test_bit (TTY_OTHER_CLOSED , &tty->flags)) +return -EIO ; +if (tty_hung_up_p (file)) +return 0 ; +/* +* Abort readers for ttys which never actually get hung up. +* See __tty_hangup(). +*/ +if (test_bit (TTY_HUPPING , &tty->flags)) +return 0 ; +if (!*timeout) +return 0 ; +if (tty_io_nonblock (tty, file)) +return -EAGAIN ; +if (signal_pending (current)) +return -ERESTARTSYS ; + +up_read (&tty->termios_rwsem); + *timeout =wait_woken (wait,TASK_INTERRUPTIBLE , *timeout); +down_read (&tty->termios_rwsem); + +return 1 ; +} +/** * n_tty_read - read function for tty * @tty: tty device
@@ -2234,34 +2261,12 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, u8 *kbuf,tty_buffer_flush_work (tty->port);down_read (&tty->termios_rwsem);if (!input_available_p (tty,0 )) { -if (test_bit (TTY_OTHER_CLOSED , &tty->flags)) { - retval = -EIO ; +int ret =n_tty_wait_for_input (tty, file, &wait, + &timeout); +if (ret <=0 ) { + retval = ret;break ; } -if (tty_hung_up_p (file)) -break ; -/* -* Abort readers for ttys which never actually -* get hung up. See __tty_hangup(). -*/ -if (test_bit (TTY_HUPPING , &tty->flags)) -break ; -if (!timeout) -break ; -if (tty_io_nonblock (tty, file)) { - retval = -EAGAIN ; -break ; - } -if (signal_pending (current)) { - retval = -ERESTARTSYS ; -break ; - } -up_read (&tty->termios_rwsem); - - timeout =wait_woken (&wait,TASK_INTERRUPTIBLE , - timeout); - -down_read (&tty->termios_rwsem);continue ; } }
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 11/31 tty: n_tty: move more_to_be_read to the end of n_tty_read()
In reply to Jiri Slaby (SUSE)n_tty_read() contains "we need more data" handling deep in that function. And there is also a label (more_to_be_read) as we handle this situation from two places.
It makes more sense to have all "return"s accumulated at the end of functions. And "goto" from multiple places there. Therefore, do this with the "more_to_be_read" label in n_tty_read().
After this and the previous changes, n_tty_read() is now much more easier to follow.
--- drivers/tty/n_tty.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/tty/n_tty.c +14 -15
@@ -2281,21 +2281,8 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, u8 *kbuf, nr--; } -/* -* Copy data, and if there is more to be had -* and we have nothing more to wait for, then -* let's mark us for retries. -* -* NOTE! We return here with both the termios_sem -* and atomic_read_lock still held, the retries -* will release them when done. -*/ -if (copy_from_read_buf (tty, &kb, &nr) && kb - kbuf >= minimum) { -more_to_be_read: -remove_wait_queue (&tty->read_wait, &wait); - *cookie = cookie; -return kb - kbuf; - } +if (copy_from_read_buf (tty, &kb, &nr) && kb - kbuf >= minimum) + goto more_to_be_read; }n_tty_check_unthrottle (tty);
@@ -2322,6 +2309,18 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, u8 *kbuf, retval = kb - kbuf;return retval; +more_to_be_read: +/* +* There is more to be had and we have nothing more to wait for, so +* let's mark us for retries. +* +* NOTE! We return here with both the termios_sem and atomic_read_lock +* still held, the retries will release them when done. +*/ +remove_wait_queue (&tty->read_wait, &wait); + *cookie = cookie; + +return kb - kbuf; }/**
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 12/31 tty: tty_driver: move TTY macros to the top
In reply to Jiri Slaby (SUSE)So that they can be referenced in structs once converted to enums (in the next patches).
--- include/linux/tty_driver.h | 156 ++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 78 deletions(-)
include/linux/tty_driver.h +78 -78
@@ -16,6 +16,84 @@ struct tty_driver;struct serial_icounter_struct ;struct serial_struct ; +/** +* DOC: TTY Driver Flags +* +* TTY_DRIVER_RESET_TERMIOS +* Requests the tty layer to reset the termios setting when the last +* process has closed the device. Used for PTYs, in particular. +* +* TTY_DRIVER_REAL_RAW +* Indicates that the driver will guarantee not to set any special +* character handling flags if this is set for the tty: +* +* ``(IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || !INPCK)`` +* +* That is, if there is no reason for the driver to +* send notifications of parity and break characters up to the line +* driver, it won't do so. This allows the line driver to optimize for +* this case if this flag is set. (Note that there is also a promise, if +* the above case is true, not to signal overruns, either.) +* +* TTY_DRIVER_DYNAMIC_DEV +* The individual tty devices need to be registered with a call to +* tty_register_device() when the device is found in the system and +* unregistered with a call to tty_unregister_device() so the devices will +* be show up properly in sysfs. If not set, all &tty_driver.num entries +* will be created by the tty core in sysfs when tty_register_driver() is +* called. This is to be used by drivers that have tty devices that can +* appear and disappear while the main tty driver is registered with the +* tty core. +* +* TTY_DRIVER_DEVPTS_MEM +* Don't use the standard arrays (&tty_driver.ttys and +* &tty_driver.termios), instead use dynamic memory keyed through the +* devpts filesystem. This is only applicable to the PTY driver. +* +* TTY_DRIVER_HARDWARE_BREAK +* Hardware handles break signals. Pass the requested timeout to the +* &tty_operations.break_ctl instead of using a simple on/off interface. +* +* TTY_DRIVER_DYNAMIC_ALLOC +* Do not allocate structures which are needed per line for this driver +* (&tty_driver.ports) as it would waste memory. The driver will take +* care. This is only applicable to the PTY driver. +* +* TTY_DRIVER_UNNUMBERED_NODE +* Do not create numbered ``/dev`` nodes. For example, create +* ``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a +* driver for a single tty device is being allocated. +*/ +#define TTY_DRIVER_INSTALLED 0x0001 +#define TTY_DRIVER_RESET_TERMIOS 0x0002 +#define TTY_DRIVER_REAL_RAW 0x0004 +#define TTY_DRIVER_DYNAMIC_DEV 0x0008 +#define TTY_DRIVER_DEVPTS_MEM 0x0010 +#define TTY_DRIVER_HARDWARE_BREAK 0x0020 +#define TTY_DRIVER_DYNAMIC_ALLOC 0x0040 +#define TTY_DRIVER_UNNUMBERED_NODE 0x0080 + +/* tty driver types */ +#define TTY_DRIVER_TYPE_SYSTEM 0x0001 +#define TTY_DRIVER_TYPE_CONSOLE 0x0002 +#define TTY_DRIVER_TYPE_SERIAL 0x0003 +#define TTY_DRIVER_TYPE_PTY 0x0004 +#define TTY_DRIVER_TYPE_SCC 0x0005/* scc driver */ +#define TTY_DRIVER_TYPE_SYSCONS 0x0006 + +/* system subtypes (magic, used by tty_io.c) */ +#define SYSTEM_TYPE_TTY 0x0001 +#define SYSTEM_TYPE_CONSOLE 0x0002 +#define SYSTEM_TYPE_SYSCONS 0x0003 +#define SYSTEM_TYPE_SYSPTMX 0x0004 + +/* pty subtypes (magic, used by tty_io.c) */ +#define PTY_TYPE_MASTER 0x0001 +#define PTY_TYPE_SLAVE 0x0002 + +/* serial subtype definitions */ +#define SERIAL_TYPE_NORMAL 1 +/** * struct tty_operations -- interface between driver and tty *
@@ -494,84 +572,6 @@ static inline void tty_set_operations(struct tty_driver *driver, driver->ops = op; } -/** -* DOC: TTY Driver Flags -* -* TTY_DRIVER_RESET_TERMIOS -* Requests the tty layer to reset the termios setting when the last -* process has closed the device. Used for PTYs, in particular. -* -* TTY_DRIVER_REAL_RAW -* Indicates that the driver will guarantee not to set any special -* character handling flags if this is set for the tty: -* -* ``(IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || !INPCK)`` -* -* That is, if there is no reason for the driver to -* send notifications of parity and break characters up to the line -* driver, it won't do so. This allows the line driver to optimize for -* this case if this flag is set. (Note that there is also a promise, if -* the above case is true, not to signal overruns, either.) -* -* TTY_DRIVER_DYNAMIC_DEV -* The individual tty devices need to be registered with a call to -* tty_register_device() when the device is found in the system and -* unregistered with a call to tty_unregister_device() so the devices will -* be show up properly in sysfs. If not set, all &tty_driver.num entries -* will be created by the tty core in sysfs when tty_register_driver() is -* called. This is to be used by drivers that have tty devices that can -* appear and disappear while the main tty driver is registered with the -* tty core. -* -* TTY_DRIVER_DEVPTS_MEM -* Don't use the standard arrays (&tty_driver.ttys and -* &tty_driver.termios), instead use dynamic memory keyed through the -* devpts filesystem. This is only applicable to the PTY driver. -* -* TTY_DRIVER_HARDWARE_BREAK -* Hardware handles break signals. Pass the requested timeout to the -* &tty_operations.break_ctl instead of using a simple on/off interface. -* -* TTY_DRIVER_DYNAMIC_ALLOC -* Do not allocate structures which are needed per line for this driver -* (&tty_driver.ports) as it would waste memory. The driver will take -* care. This is only applicable to the PTY driver. -* -* TTY_DRIVER_UNNUMBERED_NODE -* Do not create numbered ``/dev`` nodes. For example, create -* ``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a -* driver for a single tty device is being allocated. -*/ -#define TTY_DRIVER_INSTALLED 0x0001 -#define TTY_DRIVER_RESET_TERMIOS 0x0002 -#define TTY_DRIVER_REAL_RAW 0x0004 -#define TTY_DRIVER_DYNAMIC_DEV 0x0008 -#define TTY_DRIVER_DEVPTS_MEM 0x0010 -#define TTY_DRIVER_HARDWARE_BREAK 0x0020 -#define TTY_DRIVER_DYNAMIC_ALLOC 0x0040 -#define TTY_DRIVER_UNNUMBERED_NODE 0x0080 - -/* tty driver types */ -#define TTY_DRIVER_TYPE_SYSTEM 0x0001 -#define TTY_DRIVER_TYPE_CONSOLE 0x0002 -#define TTY_DRIVER_TYPE_SERIAL 0x0003 -#define TTY_DRIVER_TYPE_PTY 0x0004 -#define TTY_DRIVER_TYPE_SCC 0x0005/* scc driver */ -#define TTY_DRIVER_TYPE_SYSCONS 0x0006 - -/* system subtypes (magic, used by tty_io.c) */ -#define SYSTEM_TYPE_TTY 0x0001 -#define SYSTEM_TYPE_CONSOLE 0x0002 -#define SYSTEM_TYPE_SYSCONS 0x0003 -#define SYSTEM_TYPE_SYSPTMX 0x0004 - -/* pty subtypes (magic, used by tty_io.c) */ -#define PTY_TYPE_MASTER 0x0001 -#define PTY_TYPE_SLAVE 0x0002 - -/* serial subtype definitions */ -#define SERIAL_TYPE_NORMAL 1 -int tty_register_driver (struct tty_driver *driver);void tty_unregister_driver (struct tty_driver *driver); struct device *tty_register_device(struct tty_driver *driver, unsigned index,
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 13/31 tty: tty_driver: convert "TTY Driver Flags" to an enum
In reply to Jiri Slaby (SUSE)Convert TTY_DRIVER_* macros (flags) to an enum. This allows for easier kernel-doc (the comment needed fine tuning), grouping of these nicely, and proper checking.
Given these are flags, define them using modern BIT() instead of hex constants.
It turns out (thanks, kernel-doc checker) that internal TTY_DRIVER_INSTALLED was undocumented. Fix that too.
--- Documentation/driver-api/tty/tty_driver.rst | 2 +- include/linux/tty_driver.h | 40 ++++++++++++--------- 2 files changed, 25 insertions(+), 17 deletions(-)
Documentation/driver-api/tty/tty_driver.rst +1 -1
@@ -35,7 +35,7 @@ Here comes the documentation of flags accepted by tty_alloc_driver() (or __tty_alloc_driver()): .. kernel-doc:: include/linux/tty_driver.h - :doc: TTY Driver Flags + :identifiers: tty_driver_flag ----
include/linux/tty_driver.h +24 -16
@@ -17,13 +17,19 @@ struct serial_icounter_struct;struct serial_struct ;/** -* DOC: TTY Driver Flags +* enum tty_driver_flag -- TTY Driver Flags * -* TTY_DRIVER_RESET_TERMIOS +* These are flags passed to tty_alloc_driver(). +* +* @TTY_DRIVER_INSTALLED: +* Whether this driver was succesfully installed. This is a tty internal +* flag. Do not touch. +* +* @TTY_DRIVER_RESET_TERMIOS: * Requests the tty layer to reset the termios setting when the last * process has closed the device. Used for PTYs, in particular. * -* TTY_DRIVER_REAL_RAW +* @TTY_DRIVER_REAL_RAW: * Indicates that the driver will guarantee not to set any special * character handling flags if this is set for the tty: *
@@ -35,7 +41,7 @@ struct serial_struct;* this case if this flag is set. (Note that there is also a promise, if * the above case is true, not to signal overruns, either.) * -* TTY_DRIVER_DYNAMIC_DEV +* @TTY_DRIVER_DYNAMIC_DEV: * The individual tty devices need to be registered with a call to * tty_register_device() when the device is found in the system and * unregistered with a call to tty_unregister_device() so the devices will
@@ -45,33 +51,35 @@ struct serial_struct;* appear and disappear while the main tty driver is registered with the * tty core. * -* TTY_DRIVER_DEVPTS_MEM +* @TTY_DRIVER_DEVPTS_MEM: * Don't use the standard arrays (&tty_driver.ttys and * &tty_driver.termios), instead use dynamic memory keyed through the * devpts filesystem. This is only applicable to the PTY driver. * -* TTY_DRIVER_HARDWARE_BREAK +* @TTY_DRIVER_HARDWARE_BREAK: * Hardware handles break signals. Pass the requested timeout to the * &tty_operations.break_ctl instead of using a simple on/off interface. * -* TTY_DRIVER_DYNAMIC_ALLOC +* @TTY_DRIVER_DYNAMIC_ALLOC: * Do not allocate structures which are needed per line for this driver * (&tty_driver.ports) as it would waste memory. The driver will take * care. This is only applicable to the PTY driver. * -* TTY_DRIVER_UNNUMBERED_NODE +* @TTY_DRIVER_UNNUMBERED_NODE: * Do not create numbered ``/dev`` nodes. For example, create * ``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a * driver for a single tty device is being allocated. */ -#define TTY_DRIVER_INSTALLED 0x0001 -#define TTY_DRIVER_RESET_TERMIOS 0x0002 -#define TTY_DRIVER_REAL_RAW 0x0004 -#define TTY_DRIVER_DYNAMIC_DEV 0x0008 -#define TTY_DRIVER_DEVPTS_MEM 0x0010 -#define TTY_DRIVER_HARDWARE_BREAK 0x0020 -#define TTY_DRIVER_DYNAMIC_ALLOC 0x0040 -#define TTY_DRIVER_UNNUMBERED_NODE 0x0080 +enum tty_driver_flag { +TTY_DRIVER_INSTALLED =BIT (0 ), +TTY_DRIVER_RESET_TERMIOS =BIT (1 ), +TTY_DRIVER_REAL_RAW =BIT (2 ), +TTY_DRIVER_DYNAMIC_DEV =BIT (3 ), +TTY_DRIVER_DEVPTS_MEM =BIT (4 ), +TTY_DRIVER_HARDWARE_BREAK =BIT (5 ), +TTY_DRIVER_DYNAMIC_ALLOC =BIT (6 ), +TTY_DRIVER_UNNUMBERED_NODE =BIT (7 ), +};/* tty driver types */ #define TTY_DRIVER_TYPE_SYSTEM 0x0001
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 14/31 tty: tty_driver: document both {,__}tty_alloc_driver() properly
In reply to Jiri Slaby (SUSE)__tty_alloc_driver()'s kernel-doc needed some care: describe the return value using the standard "Returns:", and use the new enum tty_driver_flag for @flags.
Then, the tty_alloc_driver() macro was undocumented, but referenced many times in the docs. Copy the docs from the above (except the @owner parameter, obviously).
--- Documentation/driver-api/tty/tty_driver.rst | 2 ++ drivers/tty/tty_io.c | 8 +++++--- include/linux/tty_driver.h | 8 +++++++- 3 files changed, 14 insertions(+), 4 deletions(-)
Documentation/driver-api/tty/tty_driver.rst +2 -0
@@ -25,6 +25,8 @@ freed. For reference, both allocation and deallocation functions are explained here in detail: +.. kernel-doc:: include/linux/tty_driver.h + :identifiers: tty_alloc_driver .. kernel-doc:: drivers/tty/tty_io.c :identifiers: __tty_alloc_driver tty_driver_kref_put
drivers/tty/tty_io.c +5 -3
@@ -3329,10 +3329,12 @@ EXPORT_SYMBOL(tty_unregister_device);* __tty_alloc_driver - allocate tty driver * @lines: count of lines this driver can handle at most * @owner: module which is responsible for this driver -* @flags: some of %TTY_DRIVER_ flags, will be set in driver->flags +* @flags: some of enum tty_driver_flag, will be set in driver->flags * -* This should not be called directly, some of the provided macros should be -* used instead. Use IS_ERR() and friends on @retval. +* This should not be called directly, tty_alloc_driver() should be used +* instead. +* +* Returns: struct tty_driver or a PTR-encoded error (use IS_ERR() and friends). */ struct tty_driver *__tty_alloc_driver (unsigned int lines,struct module *owner,unsigned long flags)
include/linux/tty_driver.h +7 -1
@@ -564,7 +564,13 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line);void tty_driver_kref_put (struct tty_driver *driver); -/* Use TTY_DRIVER_* flags below */ +/** +* tty_alloc_driver - allocate tty driver +* @lines: count of lines this driver can handle at most +* @flags: some of enum tty_driver_flag, will be set in driver->flags +* +* Returns: struct tty_driver or a PTR-encoded error (use IS_ERR() and friends). +*/ #define tty_alloc_driver (lines, flags) \ __tty_alloc_driver(lines, THIS_MODULE, flags)
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 15/31 tty: tty_driver: introduce TTY driver sub/types enums
In reply to Jiri Slaby (SUSE)Convert TTY_DRIVER_TYPE_*, and subtype macros to two enums:tty_driver_type and tty_driver_subtype. This allows for easier kernel-doc (later), grouping of these nicely, and proper checking.
The tty_driver's ::type and ::subtype now use these enums instead of bare "short".
--- include/linux/tty_driver.h | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-)
include/linux/tty_driver.h +21 -21
@@ -81,26 +81,26 @@ enum tty_driver_flag { TTY_DRIVER_UNNUMBERED_NODE = BIT(7), }; -/* tty driver types */ -#define TTY_DRIVER_TYPE_SYSTEM 0x0001 -#define TTY_DRIVER_TYPE_CONSOLE 0x0002 -#define TTY_DRIVER_TYPE_SERIAL 0x0003 -#define TTY_DRIVER_TYPE_PTY 0x0004 -#define TTY_DRIVER_TYPE_SCC 0x0005/* scc driver */ -#define TTY_DRIVER_TYPE_SYSCONS 0x0006 +enum tty_driver_type { +TTY_DRIVER_TYPE_SYSTEM , +TTY_DRIVER_TYPE_CONSOLE , +TTY_DRIVER_TYPE_SERIAL , +TTY_DRIVER_TYPE_PTY , +TTY_DRIVER_TYPE_SCC , +TTY_DRIVER_TYPE_SYSCONS , +}; -/* system subtypes (magic, used by tty_io.c) */ -#define SYSTEM_TYPE_TTY 0x0001 -#define SYSTEM_TYPE_CONSOLE 0x0002 -#define SYSTEM_TYPE_SYSCONS 0x0003 -#define SYSTEM_TYPE_SYSPTMX 0x0004 +enum tty_driver_subtype { +SYSTEM_TYPE_TTY =1 , +SYSTEM_TYPE_CONSOLE , +SYSTEM_TYPE_SYSCONS , +SYSTEM_TYPE_SYSPTMX , -/* pty subtypes (magic, used by tty_io.c) */ -#define PTY_TYPE_MASTER 0x0001 -#define PTY_TYPE_SLAVE 0x0002 +PTY_TYPE_MASTER =1 , +PTY_TYPE_SLAVE , -/* serial subtype definitions */ -#define SERIAL_TYPE_NORMAL 1 +SERIAL_TYPE_NORMAL =1 , +};/** * struct tty_operations -- interface between driver and tty
@@ -500,8 +500,8 @@ struct tty_operations {* @major: major /dev device number (zero for autoassignment) * @minor_start: the first minor /dev device number * @num: number of devices allocated -* @type: type of tty driver (%TTY_DRIVER_TYPE_) -* @subtype: subtype of tty driver (%SYSTEM_TYPE_, %PTY_TYPE_, %SERIAL_TYPE_) +* @type: type of tty driver (enum tty_driver_type) +* @subtype: subtype of tty driver (enum tty_driver_subtype) * @init_termios: termios to set to each tty initially (e.g. %tty_std_termios) * @flags: tty driver flags (%TTY_DRIVER_) * @proc_entry: proc fs entry, used internally
@@ -533,8 +533,8 @@ struct tty_driver {int major;int minor_start;unsigned int num; -short type; -short subtype; +enum tty_driver_type type; +enum tty_driver_subtype subtype;struct ktermios init_termios;unsigned long flags;struct proc_dir_entry *proc_entry;
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 16/31 tty: serdev: drop serdev_controller_ops::write_room()
In reply to Jiri Slaby (SUSE)In particular, serdev_device_write_room() is not called, so the whole serdev's write_room() can go.
--- drivers/tty/serdev/core.c | 11 ----------- drivers/tty/serdev/serdev-ttyport.c | 9 --------- include/linux/serdev.h | 6 ------ 3 files changed, 26 deletions(-)
drivers/tty/serdev/core.c +0 -11
@@ -316,17 +316,6 @@ void serdev_device_write_flush(struct serdev_device *serdev) }EXPORT_SYMBOL_GPL (serdev_device_write_flush); -int serdev_device_write_room (struct serdev_device *serdev) -{ -struct serdev_controller *ctrl = serdev->ctrl; - -if (!ctrl || !ctrl->ops->write_room) -return 0 ; - -return serdev->ctrl->ops->write_room (ctrl); -} -EXPORT_SYMBOL_GPL (serdev_device_write_room); -unsigned int serdev_device_set_baudrate (struct serdev_device *serdev,unsigned int speed) {struct serdev_controller *ctrl = serdev->ctrl;
drivers/tty/serdev/serdev-ttyport.c +0 -9
@@ -92,14 +92,6 @@ static void ttyport_write_flush(struct serdev_controller *ctrl)tty_driver_flush_buffer (tty); } -static int ttyport_write_room (struct serdev_controller *ctrl) -{ -struct serport *serport =serdev_controller_get_drvdata (ctrl); -struct tty_struct *tty = serport->tty; - -return tty_write_room (tty); -} -static int ttyport_open (struct serdev_controller *ctrl) {struct serport *serport =serdev_controller_get_drvdata (ctrl);
@@ -259,7 +251,6 @@ static int ttyport_break_ctl(struct serdev_controller *ctrl, unsigned int break_static const struct serdev_controller_ops ctrl_ops = { .write_buf = ttyport_write_buf, .write_flush = ttyport_write_flush, - .write_room = ttyport_write_room, .open = ttyport_open, .close = ttyport_close, .set_flow_control = ttyport_set_flow_control,
include/linux/serdev.h +0 -6
@@ -84,7 +84,6 @@ enum serdev_parity {struct serdev_controller_ops {ssize_t (*write_buf)(struct serdev_controller *,const u8 *,size_t );void (*write_flush)(struct serdev_controller *); -int (*write_room)(struct serdev_controller *);int (*open)(struct serdev_controller *);void (*close)(struct serdev_controller *);void (*set_flow_control)(struct serdev_controller *,bool );
@@ -212,7 +211,6 @@ int serdev_device_break_ctl(struct serdev_device *serdev, int break_state);void serdev_device_write_wakeup (struct serdev_device *);ssize_t serdev_device_write (struct serdev_device *,const u8 *,size_t ,long );void serdev_device_write_flush (struct serdev_device *); -int serdev_device_write_room (struct serdev_device *);/* * serdev device driver functions
@@ -273,10 +271,6 @@ static inline ssize_t serdev_device_write(struct serdev_device *sdev,return -ENODEV ; }static inline void serdev_device_write_flush (struct serdev_device *sdev) {} -static inline int serdev_device_write_room (struct serdev_device *sdev) -{ -return 0 ; -}#define serdev_device_driver_register (x)#define serdev_device_driver_unregister (x)
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 17/31 tty: mmc: sdio: use bool for cts and remove parentheses
In reply to Jiri Slaby (SUSE)'cts' in sdio_uart_check_modem_status() is considered a 'bool', but typed as signed 'int'. Make it 'bool' so it is clear the code does not care about the masked value, but true/false.
--- drivers/mmc/core/sdio_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/sdio_uart.c +1 -1
@@ -471,7 +471,7 @@ static void sdio_uart_check_modem_status(struct sdio_uart_port *port) port->icount.cts++; tty =tty_port_tty_get (&port->port);if (tty &&C_CRTSCTS (tty)) { -int cts = (status &UART_MSR_CTS ); +bool cts = status &UART_MSR_CTS ;if (tty->hw_stopped) {if (cts) { tty->hw_stopped = false;
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 18/31 tty: moxa: drop version dump to logs
In reply to Jiri Slaby (SUSE)The arbitrary MOXA_VERSION is dumped to the logs when the driver is loaded. Avoid this as a driver should be silent unless something breaks.
--- drivers/tty/moxa.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/tty/moxa.c +0 -5
@@ -347,8 +347,6 @@#define MX_PARMARK 0xA0#define MX_PARSPACE 0x20 -#define MOXA_VERSION "6.0k" -#define MOXA_FW_HDRLEN 32#define MOXAMAJOR 172
@@ -1327,9 +1325,6 @@ static int __init moxa_init(void)struct moxa_board_conf *brd = moxa_boards;unsigned int i; -printk (KERN_INFO "MOXA Intellio family driver version %s\n" , -MOXA_VERSION ); -tty_port_init (&moxa_service_port); moxaDriver = tty_alloc_driver(MAX_PORTS + 1,
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 19/31 tty: moxa: drop ISA support
In reply to Jiri Slaby (SUSE)I doubt anyone actually uses this driver (unlike mxser.c and serial moxa driven devices). Even less there is anyone with a moxa ISA card. The newer mxser dropped the support for ISA in 2021. Let this moxa follow now.
Good diet.
--- drivers/tty/Kconfig | 2 +- drivers/tty/moxa.c | 100 +++----------------------------------------- 2 files changed, 6 insertions(+), 96 deletions(-)
drivers/tty/Kconfig +1 -1
@@ -210,7 +210,7 @@ config SERIAL_NONSTANDARD config MOXA_INTELLIO tristate "Moxa Intellio support" - depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) + depends on SERIAL_NONSTANDARD && PCI select FW_LOADER help Say Y here if you have a Moxa Intellio multiport serial card.
drivers/tty/moxa.c +5 -95
223 lines not on this page · raw message
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 20/31 tty: moxa: carve out special ioctls and extra tty_port
In reply to Jiri Slaby (SUSE)These ioctls are undocumented and not exposed -- they are defined locally. Given they need a special tty_port just for them, this is very ugly. So drop this whole functionality. It is barely used for something real. (And if it is, we'd need a common functionality to all drivers.)
--- drivers/tty/moxa.c | 146 +-------------------------------------------- 1 file changed, 1 insertion(+), 145 deletions(-)
drivers/tty/moxa.c +1 -145
@@ -43,15 +43,6 @@#include <linux/ratelimit.h> #include <asm/io.h> -#include <linux/uaccess.h> - -#define MOXA 0x400 -#define MOXA_GET_IQUEUE (MOXA + 1)/* get input buffered count */ -#define MOXA_GET_OQUEUE (MOXA + 2)/* get output buffered count */ -#define MOXA_GETDATACOUNT (MOXA + 23) -#define MOXA_GET_IOQUEUE (MOXA + 27) -#define MOXA_FLUSH_QUEUE (MOXA + 28) -#define MOXA_GETMSTATUS (MOXA + 65)/* * System Configuration
@@ -397,19 +388,6 @@ static struct moxa_board_conf {void __iomem *intTable; } moxa_boards[MAX_BOARDS ]; -struct mxser_mstatus { -tcflag_t cflag; -int cts; -int dsr; -int ri; -int dcd; -}; - -struct moxaq_str { -int inq; -int outq; -}; -struct moxa_port {struct tty_port port;struct moxa_board_conf *board;
@@ -424,12 +402,6 @@ struct moxa_port {u8 lowChkFlag; }; -struct mon_str { -int tick; -int rxcnt[MAX_PORTS ]; -int txcnt[MAX_PORTS ]; -}; -/* statusflags */ #define TXSTOPPED 1#define LOWWAIT 2
@@ -439,14 +411,11 @@ struct mon_str {#define WAKEUP_CHARS 256static int ttymajor =MOXAMAJOR ; -static struct mon_str moxaLog;static unsigned int moxaFuncTout =HZ /2 ;static unsigned int moxaLowWaterChk;static DEFINE_MUTEX (moxa_openlock);static DEFINE_SPINLOCK (moxa_lock); -static struct tty_port moxa_service_port; -MODULE_AUTHOR ("William Chen" );MODULE_DESCRIPTION ("MOXA Intellio Family Multiport Board Device Driver" );MODULE_LICENSE ("GPL" );
@@ -557,104 +526,6 @@ static void moxa_low_water_check(void __iomem *ofsAddr)* TTY operations */ -static int moxa_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg) -{ -struct moxa_port *ch = tty->driver_data; -void __user *argp = (void __user *)arg; -int status, ret =0 ; - -if (tty->index ==MAX_PORTS ) { -if (cmd !=MOXA_GETDATACOUNT && cmd !=MOXA_GET_IOQUEUE && - cmd !=MOXA_GETMSTATUS ) -return -EINVAL ; - }else if (!ch) -return -ENODEV ; - -switch (cmd) { -case MOXA_GETDATACOUNT : - moxaLog.tick = jiffies; -if (copy_to_user (argp, &moxaLog,sizeof (moxaLog))) - ret = -EFAULT ; -break ; -case MOXA_FLUSH_QUEUE : -MoxaPortFlushData (ch, arg); -break ; -case MOXA_GET_IOQUEUE : { -struct moxaq_str __user *argm = argp; -struct moxaq_str tmp; -struct moxa_port *p; -unsigned int i, j; - -for (i =0 ; i <MAX_BOARDS ; i++) { - p = moxa_boards[i].ports; -for (j =0 ; j <MAX_PORTS_PER_BOARD ; j++, p++, argm++) { -memset (&tmp,0 ,sizeof (tmp)); -spin_lock_bh (&moxa_lock); -if (moxa_boards[i].ready) { - tmp.inq =MoxaPortRxQueue (p); - tmp.outq =MoxaPortTxQueue (p); - } -spin_unlock_bh (&moxa_lock); -if (copy_to_user (argm, &tmp,sizeof (tmp))) -return -EFAULT ; - } - } -break ; - }case MOXA_GET_OQUEUE : - status =MoxaPortTxQueue (ch); - ret =put_user (status, (unsigned long __user *)argp); -break ; -case MOXA_GET_IQUEUE : - status =MoxaPortRxQueue (ch); - ret =put_user (status, (unsigned long __user *)argp); -break ; -case MOXA_GETMSTATUS : { -struct mxser_mstatus __user *argm = argp; -struct mxser_mstatus tmp; -struct moxa_port *p; -unsigned int i, j; - -for (i =0 ; i <MAX_BOARDS ; i++) { - p = moxa_boards[i].ports; -for (j =0 ; j <MAX_PORTS_PER_BOARD ; j++, p++, argm++) { -struct tty_struct *ttyp; -memset (&tmp,0 ,sizeof (tmp)); -spin_lock_bh (&moxa_lock); -if (!moxa_boards[i].ready) { -spin_unlock_bh (&moxa_lock); - goto copy; - } - - status =MoxaPortLineStatus (p); -spin_unlock_bh (&moxa_lock); - -if (status &1 ) - tmp.cts =1 ; -if (status &2 ) - tmp.dsr =1 ; -if (status &4 ) - tmp.dcd =1 ; - - ttyp =tty_port_tty_get (&p->port); -if (!ttyp) - tmp.cflag = p->cflag; -else - tmp.cflag = ttyp->termios.c_cflag; -tty_kref_put (ttyp); -copy: -if (copy_to_user (argm, &tmp,sizeof (tmp))) -return -EFAULT ; - } - } -break ; - } -default : - ret = -ENOIOCTLCMD ; - } -return ret; -} -static int moxa_break_ctl (struct tty_struct *tty,int state) {struct moxa_port *port = tty->driver_data;
@@ -671,7 +542,6 @@ static const struct tty_operations moxa_ops = { .write_room = moxa_write_room, .flush_buffer = moxa_flush_buffer, .chars_in_buffer = moxa_chars_in_buffer, - .ioctl = moxa_ioctl, .set_termios = moxa_set_termios, .stop = moxa_stop, .start = moxa_start,
@@ -1283,9 +1153,7 @@ static int __init moxa_init(void) {int retval =0 ; -tty_port_init (&moxa_service_port); - - moxaDriver =tty_alloc_driver (MAX_PORTS +1 , + moxaDriver =tty_alloc_driver (MAX_PORTS ,TTY_DRIVER_REAL_RAW |TTY_DRIVER_DYNAMIC_DEV );if (IS_ERR (moxaDriver))
@@ -1301,8 +1169,6 @@ static int __init moxa_init(void) moxaDriver->init_termios.c_ispeed =9600 ; moxaDriver->init_termios.c_ospeed =9600 ;tty_set_operations (moxaDriver, &moxa_ops); -/* Having one more port only for ioctls is ugly */ -tty_port_link_device (&moxa_service_port, moxaDriver,MAX_PORTS );if (tty_register_driver (moxaDriver)) {printk (KERN_ERR "can't register MOXA Smartio tty driver!\n" );
@@ -1362,9 +1228,6 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)int port; port = tty->index; -if (port ==MAX_PORTS ) { -return capable (CAP_SYS_ADMIN ) ?0 : -EPERM ; - }if (mutex_lock_interruptible (&moxa_openlock))return -ERESTARTSYS ; brd = &moxa_boards[port /MAX_PORTS_PER_BOARD ];
@@ -2087,7 +1950,6 @@ static ssize_t MoxaPortWriteData(struct tty_struct *tty, const u8 *buffer, c = (head > tail) ? (head - tail -1 ) : (head - tail + tx_mask);if (c > len) c = len; - moxaLog.txcnt[port->port.tty->index] += c; total = c;if (spage == epage) { bufhead =readw (ofsAddr + Ofs_txb);
@@ -2129,7 +1991,6 @@ static ssize_t MoxaPortWriteData(struct tty_struct *tty, const u8 *buffer,static int MoxaPortReadData (struct moxa_port *port) { -struct tty_struct *tty = port->port.tty;void __iomem *baseAddr, *ofsAddr, *ofs;u8 *dst;unsigned int count, len, total;
@@ -2148,7 +2009,6 @@ static int MoxaPortReadData(struct moxa_port *port)return 0 ; total = count; - moxaLog.rxcnt[tty->index] += total;if (spage == epage) { bufhead =readw (ofsAddr + Ofs_rxb);writew (spage, baseAddr + Control_reg);
@@ -2236,8 +2096,6 @@ static int moxa_get_serial_info(struct tty_struct *tty, {struct moxa_port *info = tty->driver_data; -if (tty->index ==MAX_PORTS ) -return -EINVAL ;if (!info)return -ENODEV ;mutex_lock (&info->port.mutex);
@@ -2257,8 +2115,6 @@ static int moxa_set_serial_info(struct tty_struct *tty,struct moxa_port *info = tty->driver_data;unsigned int close_delay; -if (tty->index ==MAX_PORTS ) -return -EINVAL ;if (!info)return -ENODEV ;
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 21/31 tty: srmcons: fix retval from srmcons_init()
In reply to Jiri Slaby (SUSE)The value returned from srmcons_init() was -ENODEV for over 2 decades. But it does not matter, given device_initcall() ignores retvals.
But to be honest, return 0 in case the tty driver was registered properly.
To do that, the condition is inverted and a short path taken in case of error.
err_free_drv is introduced as it will be used from more places later.
--- arch/alpha/kernel/srmcons.c | 62 ++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 29 deletions(-)
arch/alpha/kernel/srmcons.c +33 -29
@@ -196,40 +196,44 @@ static const struct tty_operations srmcons_ops = {static int __init srmcons_init (void ) { +struct tty_driver *driver; +int err; +timer_setup (&srmcons_singleton.timer, srmcons_receive_chars,0 ); -if (srm_is_registered_console) { -struct tty_driver *driver; -int err; - - driver =tty_alloc_driver (MAX_SRM_CONSOLE_DEVICES ,0 ); -if (IS_ERR (driver)) -return PTR_ERR (driver); - -tty_port_init (&srmcons_singleton.port); - - driver->driver_name ="srm" ; - driver->name ="srm" ; - driver->major =0 ;/* dynamic */ - driver->minor_start =0 ; - driver->type =TTY_DRIVER_TYPE_SYSTEM ; - driver->subtype =SYSTEM_TYPE_SYSCONS ; - driver->init_termios = tty_std_termios; -tty_set_operations (driver, &srmcons_ops); -tty_port_link_device (&srmcons_singleton.port, driver,0 ); - err =tty_register_driver (driver); -if (err) { -tty_driver_kref_put (driver); -tty_port_destroy (&srmcons_singleton.port); -return err; - } - srmcons_driver = driver; - } -return -ENODEV ; +if (!srm_is_registered_console) +return -ENODEV ; + + driver =tty_alloc_driver (MAX_SRM_CONSOLE_DEVICES ,0 ); +if (IS_ERR (driver)) +return PTR_ERR (driver); + +tty_port_init (&srmcons_singleton.port); + + driver->driver_name ="srm" ; + driver->name ="srm" ; + driver->major =0 ;/* dynamic */ + driver->minor_start =0 ; + driver->type =TTY_DRIVER_TYPE_SYSTEM ; + driver->subtype =SYSTEM_TYPE_SYSCONS ; + driver->init_termios = tty_std_termios; +tty_set_operations (driver, &srmcons_ops); +tty_port_link_device (&srmcons_singleton.port, driver,0 ); + err =tty_register_driver (driver); +if (err) + goto err_free_drv; + + srmcons_driver = driver; + +return 0 ; +err_free_drv: +tty_driver_kref_put (driver); +tty_port_destroy (&srmcons_singleton.port); + +return err; }device_initcall (srmcons_init); -/* * The console driver */
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 22/31 tty: staging/greybus: pass tty_driver flags to tty_alloc_driver()
In reply to Jiri Slaby (SUSE)tty_alloc_driver() is supposed to receive tty driver flags.
--- drivers/staging/greybus/uart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/uart.c +2 -2
@@ -948,7 +948,8 @@ static int gb_tty_init(void) {int retval =0 ; - gb_tty_driver =tty_alloc_driver (GB_NUM_MINORS ,0 ); + gb_tty_driver =tty_alloc_driver (GB_NUM_MINORS ,TTY_DRIVER_REAL_RAW | +TTY_DRIVER_DYNAMIC_DEV );if (IS_ERR (gb_tty_driver)) {pr_err ("Can not allocate tty driver\n" ); retval = -ENOMEM ;
@@ -961,7 +962,6 @@ static int gb_tty_init(void) gb_tty_driver->minor_start =0 ; gb_tty_driver->type =TTY_DRIVER_TYPE_SERIAL ; gb_tty_driver->subtype =SERIAL_TYPE_NORMAL ; - gb_tty_driver->flags =TTY_DRIVER_REAL_RAW |TTY_DRIVER_DYNAMIC_DEV ; gb_tty_driver->init_termios = tty_std_termios; gb_tty_driver->init_termios.c_cflag =B9600 |CS8 |CREAD |HUPCL |CLOCAL ;
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 23/31 tty: sunsu: drop serial_{in,out}p()
In reply to Jiri Slaby (SUSE)They are simple wrappers around serial_{in/out}() without actually pausing the execution. Since ever. So drop these useless wrappers.
--- drivers/tty/serial/sunsu.c | 164 +++++++++++++++++-------------------- 1 file changed, 77 insertions(+), 87 deletions(-)
drivers/tty/serial/sunsu.c +77 -87
@@ -150,16 +150,6 @@ static void serial_out(struct uart_sunsu_port *up, int offset, int value) } } -/* -* We used to support using pause I/O for certain machines. We -* haven't supported this for a while, but just in case it's badly -* needed for certain old 386 machines, I've left these #define's -* in.... -*/ -#define serial_inp (up, offset) serial_in(up, offset) -#define serial_outp (up, offset, value) serial_out(up, offset, value) - -/* * For the 16C950 */
@@ -193,12 +183,12 @@ static int __enable_rsa(struct uart_sunsu_port *up)unsigned char mode;int result; - mode =serial_inp (up,UART_RSA_MSR ); + mode =serial_in (up,UART_RSA_MSR ); result = mode &UART_RSA_MSR_FIFO ;if (!result) { -serial_outp (up,UART_RSA_MSR , mode |UART_RSA_MSR_FIFO ); - mode =serial_inp (up,UART_RSA_MSR ); +serial_out (up,UART_RSA_MSR , mode |UART_RSA_MSR_FIFO ); + mode =serial_in (up,UART_RSA_MSR ); result = mode &UART_RSA_MSR_FIFO ; }
@@ -217,7 +207,7 @@ static void enable_rsa(struct uart_sunsu_port *up)uart_port_unlock_irq (&up->port); }if (up->port.uartclk ==SERIAL_RSA_BAUD_BASE *16 ) -serial_outp (up,UART_RSA_FRR ,0 ); +serial_out (up,UART_RSA_FRR ,0 ); } }
@@ -236,12 +226,12 @@ static void disable_rsa(struct uart_sunsu_port *up) up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) {uart_port_lock_irq (&up->port); - mode =serial_inp (up,UART_RSA_MSR ); + mode =serial_in (up,UART_RSA_MSR ); result = !(mode &UART_RSA_MSR_FIFO );if (!result) { -serial_outp (up,UART_RSA_MSR , mode & ~UART_RSA_MSR_FIFO ); - mode =serial_inp (up,UART_RSA_MSR ); +serial_out (up,UART_RSA_MSR , mode & ~UART_RSA_MSR_FIFO ); + mode =serial_in (up,UART_RSA_MSR ); result = !(mode &UART_RSA_MSR_FIFO ); }
@@ -326,7 +316,7 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status)int saw_console_brk =0 ; do { - ch = serial_inp(up, UART_RX); + ch = serial_in(up, UART_RX); flag = TTY_NORMAL; up->port.icount.rx++;
@@ -387,7 +377,7 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status)*/ tty_insert_flip_char (port,0 ,TTY_OVERRUN ); ignore_char: - *status =serial_inp (up,UART_LSR ); + *status =serial_in (up,UART_LSR ); }while ((*status &UART_LSR_DR ) && (max_count-- >0 ));if (saw_console_brk)
@@ -401,7 +391,7 @@ static void transmit_chars(struct uart_sunsu_port *up)int count;if (up->port.x_char) { -serial_outp (up,UART_TX , up->port.x_char); +serial_out (up,UART_TX , up->port.x_char); up->port.icount.tx++; up->port.x_char =0 ;return ;
@@ -460,7 +450,7 @@ static irqreturn_t sunsu_serial_interrupt(int irq, void *dev_id)uart_port_lock_irqsave (&up->port, &flags); do { - status = serial_inp(up, UART_LSR); + status = serial_in(up, UART_LSR); if (status & UART_LSR_DR) receive_chars(up, &status); check_modem_status(up);
@@ -498,7 +488,7 @@ static void sunsu_change_mouse_baud(struct uart_sunsu_port *up)static void receive_kbd_ms_chars (struct uart_sunsu_port *up,int is_break) { do { - unsigned char ch = serial_inp(up, UART_RX); + unsigned char ch = serial_in(up, UART_RX); /* Stop-A is handled by drivers/char/keyboard.c now. */ if (up->su_type == SU_PORT_KBD) {
@@ -530,7 +520,7 @@ static irqreturn_t sunsu_kbd_ms_interrupt(int irq, void *dev_id)struct uart_sunsu_port *up = dev_id;if (!(serial_in (up,UART_IIR ) &UART_IIR_NO_INT )) { -unsigned char status =serial_inp (up,UART_LSR ); +unsigned char status =serial_in (up,UART_LSR );if ((status &UART_LSR_DR ) || (status &UART_LSR_BI ))receive_kbd_ms_chars (up, (status &UART_LSR_BI ) !=0 );
@@ -619,14 +609,14 @@ static int sunsu_startup(struct uart_port *port)if (up->port.type ==PORT_16C950 ) {/* Wake up and initialize UART */ up->acr =0 ; -serial_outp (up,UART_LCR ,0xBF ); -serial_outp (up,UART_EFR ,UART_EFR_ECB ); -serial_outp (up,UART_IER ,0 ); -serial_outp (up,UART_LCR ,0 ); +serial_out (up,UART_LCR ,0xBF ); +serial_out (up,UART_EFR ,UART_EFR_ECB ); +serial_out (up,UART_IER ,0 ); +serial_out (up,UART_LCR ,0 );serial_icr_write (up,UART_CSR ,0 );/* Reset the UART */ -serial_outp (up,UART_LCR ,0xBF ); -serial_outp (up,UART_EFR ,UART_EFR_ECB ); -serial_outp (up,UART_LCR ,0 ); +serial_out (up,UART_LCR ,0xBF ); +serial_out (up,UART_EFR ,UART_EFR_ECB ); +serial_out (up,UART_LCR ,0 ); }#ifdef CONFIG_SERIAL_8250_RSA
@@ -642,19 +632,19 @@ static int sunsu_startup(struct uart_port *port)* (they will be reenabled in set_termios()) */ if (uart_config[up->port.type].flags &UART_CLEAR_FIFO ) { -serial_outp (up,UART_FCR ,UART_FCR_ENABLE_FIFO ); -serial_outp (up,UART_FCR ,UART_FCR_ENABLE_FIFO | +serial_out (up,UART_FCR ,UART_FCR_ENABLE_FIFO ); +serial_out (up,UART_FCR ,UART_FCR_ENABLE_FIFO |UART_FCR_CLEAR_RCVR |UART_FCR_CLEAR_XMIT ); -serial_outp (up,UART_FCR ,0 ); +serial_out (up,UART_FCR ,0 ); }/* * Clear the interrupt registers. */ - (void )serial_inp (up,UART_LSR ); - (void )serial_inp (up,UART_RX ); - (void )serial_inp (up,UART_IIR ); - (void )serial_inp (up,UART_MSR ); + (void )serial_in (up,UART_LSR ); + (void )serial_in (up,UART_RX ); + (void )serial_in (up,UART_IIR ); + (void )serial_in (up,UART_MSR );/* * At this point, there's no way the LSR could still be 0xff;
@@ -662,7 +652,7 @@ static int sunsu_startup(struct uart_port *port)* here. */ if (!(up->port.flags &UPF_BUGGY_UART ) && - (serial_inp (up,UART_LSR ) ==0xff )) { + (serial_in (up,UART_LSR ) ==0xff )) {printk ("ttyS%d: LSR safety check engaged!\n" , up->port.line);return -ENODEV ; }
@@ -682,7 +672,7 @@ static int sunsu_startup(struct uart_port *port)/* * Now, initialize the UART */ -serial_outp (up,UART_LCR ,UART_LCR_WLEN8 ); +serial_out (up,UART_LCR ,UART_LCR_WLEN8 );uart_port_lock_irqsave (&up->port, &flags);
@@ -697,7 +687,7 @@ static int sunsu_startup(struct uart_port *port)* anyway, so we don't enable them here. */ up->ier =UART_IER_RLSI |UART_IER_RDI ; -serial_outp (up,UART_IER , up->ier); +serial_out (up,UART_IER , up->ier);if (up->port.flags &UPF_FOURPORT ) {unsigned int icp;
@@ -712,10 +702,10 @@ static int sunsu_startup(struct uart_port *port)/* * And clear the interrupt registers again for luck. */ - (void )serial_inp (up,UART_LSR ); - (void )serial_inp (up,UART_RX ); - (void )serial_inp (up,UART_IIR ); - (void )serial_inp (up,UART_MSR ); + (void )serial_in (up,UART_LSR ); + (void )serial_in (up,UART_RX ); + (void )serial_in (up,UART_IIR ); + (void )serial_in (up,UART_MSR );return 0 ; }
@@ -730,7 +720,7 @@ static void sunsu_shutdown(struct uart_port *port)* Disable interrupts from this port */ up->ier =0 ; -serial_outp (up,UART_IER ,0 ); +serial_out (up,UART_IER ,0 );uart_port_lock_irqsave (&up->port, &flags);if (up->port.flags &UPF_FOURPORT ) {
@@ -746,11 +736,11 @@ static void sunsu_shutdown(struct uart_port *port)/* * Disable break condition and FIFOs */ -serial_out (up,UART_LCR ,serial_inp (up,UART_LCR ) & ~UART_LCR_SBC ); -serial_outp (up,UART_FCR ,UART_FCR_ENABLE_FIFO | +serial_out (up,UART_LCR ,serial_in (up,UART_LCR ) & ~UART_LCR_SBC ); +serial_out (up,UART_FCR ,UART_FCR_ENABLE_FIFO |UART_FCR_CLEAR_RCVR |UART_FCR_CLEAR_XMIT ); -serial_outp (up,UART_FCR ,0 ); +serial_out (up,UART_FCR ,0 );#ifdef CONFIG_SERIAL_8250_RSA /*
@@ -872,22 +862,22 @@ sunsu_change_speed(struct uart_port *port, unsigned int cflag,serial_out (up,UART_IER , up->ier);if (uart_config[up->port.type].flags &UART_STARTECH ) { -serial_outp (up,UART_LCR ,0xBF ); -serial_outp (up,UART_EFR , cflag &CRTSCTS ?UART_EFR_CTS :0 ); +serial_out (up,UART_LCR ,0xBF ); +serial_out (up,UART_EFR , cflag &CRTSCTS ?UART_EFR_CTS :0 ); } -serial_outp (up,UART_LCR , cval |UART_LCR_DLAB );/* set DLAB */ -serial_outp (up,UART_DLL , quot &0xff );/* LS of divisor */ -serial_outp (up,UART_DLM , quot >>8 );/* MS of divisor */ +serial_out (up,UART_LCR , cval |UART_LCR_DLAB );/* set DLAB */ +serial_out (up,UART_DLL , quot &0xff );/* LS of divisor */ +serial_out (up,UART_DLM , quot >>8 );/* MS of divisor */ if (up->port.type ==PORT_16750 ) -serial_outp (up,UART_FCR , fcr);/* set fcr */ -serial_outp (up,UART_LCR , cval);/* reset DLAB */ +serial_out (up,UART_FCR , fcr);/* set fcr */ +serial_out (up,UART_LCR , cval);/* reset DLAB */ up->lcr = cval;/* Save LCR */ if (up->port.type !=PORT_16750 ) {if (fcr &UART_FCR_ENABLE_FIFO ) {/* emulated UARTs (Lucent Venus 167x) need two steps */ -serial_outp (up,UART_FCR ,UART_FCR_ENABLE_FIFO ); +serial_out (up,UART_FCR ,UART_FCR_ENABLE_FIFO ); } -serial_outp (up,UART_FCR , fcr);/* set fcr */ +serial_out (up,UART_FCR , fcr);/* set fcr */ } up->cflag = cflag;
@@ -1051,18 +1041,18 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up)* 0x80 is a non-existent port; which should be safe since * include/asm/io.h also makes this assumption. */ - scratch =serial_inp (up,UART_IER ); -serial_outp (up,UART_IER ,0 ); + scratch =serial_in (up,UART_IER ); +serial_out (up,UART_IER ,0 );#ifdef __i386__outb (0xff ,0x080 );#endif - scratch2 =serial_inp (up,UART_IER ); -serial_outp (up,UART_IER ,0x0f ); + scratch2 =serial_in (up,UART_IER ); +serial_out (up,UART_IER ,0x0f );#ifdef __i386__outb (0 ,0x080 );#endif - scratch3 =serial_inp (up,UART_IER ); -serial_outp (up,UART_IER , scratch); + scratch3 =serial_in (up,UART_IER ); +serial_out (up,UART_IER , scratch);if (scratch2 !=0 || scratch3 !=0x0F ) goto out;/* We failed; there's nothing here */ }
@@ -1080,16 +1070,16 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up)* that conflicts with COM 1-4 --- we hope! */ if (!(up->port.flags &UPF_SKIP_TEST )) { -serial_outp (up,UART_MCR ,UART_MCR_LOOP |0x0A ); - status1 =serial_inp (up,UART_MSR ) &0xF0 ; -serial_outp (up,UART_MCR , save_mcr); +serial_out (up,UART_MCR ,UART_MCR_LOOP |0x0A ); + status1 =serial_in (up,UART_MSR ) &0xF0 ; +serial_out (up,UART_MCR , save_mcr);if (status1 !=0x90 ) goto out;/* We failed loopback test */ } -serial_outp (up,UART_LCR ,0xBF );/* set up for StarTech test */ -serial_outp (up,UART_EFR ,0 );/* EFR is the same as FCR */ -serial_outp (up,UART_LCR ,0 ); -serial_outp (up,UART_FCR ,UART_FCR_ENABLE_FIFO ); +serial_out (up,UART_LCR ,0xBF );/* set up for StarTech test */ +serial_out (up,UART_EFR ,0 );/* EFR is the same as FCR */ +serial_out (up,UART_LCR ,0 ); +serial_out (up,UART_FCR ,UART_FCR_ENABLE_FIFO ); scratch =serial_in (up,UART_IIR ) >>6 ;switch (scratch) {case 0 :
@@ -1107,19 +1097,19 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up) }if (up->port.type ==PORT_16550A ) {/* Check for Startech UART's */ -serial_outp (up,UART_LCR ,UART_LCR_DLAB ); +serial_out (up,UART_LCR ,UART_LCR_DLAB );if (serial_in (up,UART_EFR ) ==0 ) { up->port.type =PORT_16650 ; }else { -serial_outp (up,UART_LCR ,0xBF ); +serial_out (up,UART_LCR ,0xBF );if (serial_in (up,UART_EFR ) ==0 ) up->port.type =PORT_16650V2 ; } }if (up->port.type ==PORT_16550A ) {/* Check for TI 16750 */ -serial_outp (up,UART_LCR , save_lcr |UART_LCR_DLAB ); -serial_outp (up,UART_FCR , +serial_out (up,UART_LCR , save_lcr |UART_LCR_DLAB ); +serial_out (up,UART_FCR ,UART_FCR_ENABLE_FIFO |UART_FCR7_64BYTE ); scratch =serial_in (up,UART_IIR ) >>5 ;if (scratch ==7 ) {
@@ -1129,24 +1119,24 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up)* mode if the UART_FCR7_64BYTE bit was set * while UART_LCR_DLAB was latched. */ -serial_outp (up,UART_FCR ,UART_FCR_ENABLE_FIFO ); -serial_outp (up,UART_LCR ,0 ); -serial_outp (up,UART_FCR , +serial_out (up,UART_FCR ,UART_FCR_ENABLE_FIFO ); +serial_out (up,UART_LCR ,0 ); +serial_out (up,UART_FCR ,UART_FCR_ENABLE_FIFO |UART_FCR7_64BYTE ); scratch =serial_in (up,UART_IIR ) >>5 ;if (scratch ==6 ) up->port.type =PORT_16750 ; } -serial_outp (up,UART_FCR ,UART_FCR_ENABLE_FIFO ); +serial_out (up,UART_FCR ,UART_FCR_ENABLE_FIFO ); } -serial_outp (up,UART_LCR , save_lcr); +serial_out (up,UART_LCR , save_lcr);if (up->port.type ==PORT_16450 ) { scratch =serial_in (up,UART_SCR ); -serial_outp (up,UART_SCR ,0xa5 ); +serial_out (up,UART_SCR ,0xa5 ); status1 =serial_in (up,UART_SCR ); -serial_outp (up,UART_SCR ,0x5a ); +serial_out (up,UART_SCR ,0x5a ); status2 =serial_in (up,UART_SCR ); -serial_outp (up,UART_SCR , scratch); +serial_out (up,UART_SCR , scratch);if ((status1 !=0xa5 ) || (status2 !=0x5a )) up->port.type =PORT_8250 ;
@@ -1163,15 +1153,15 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up)*/ #ifdef CONFIG_SERIAL_8250_RSA if (up->port.type ==PORT_RSA ) -serial_outp (up,UART_RSA_FRR ,0 ); +serial_out (up,UART_RSA_FRR ,0 );#endif -serial_outp (up,UART_MCR , save_mcr); -serial_outp (up,UART_FCR , (UART_FCR_ENABLE_FIFO | +serial_out (up,UART_MCR , save_mcr); +serial_out (up,UART_FCR , (UART_FCR_ENABLE_FIFO |UART_FCR_CLEAR_RCVR |UART_FCR_CLEAR_XMIT )); -serial_outp (up,UART_FCR ,0 ); +serial_out (up,UART_FCR ,0 ); (void )serial_in (up,UART_RX ); -serial_outp (up,UART_IER ,0 ); +serial_out (up,UART_IER ,0 ); out:uart_port_unlock_irqrestore (&up->port, flags);
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 24/31 tty: sunsu: remove unused serial_icr_read()
In reply to Jiri Slaby (SUSE)It is commented and never used.
--- drivers/tty/serial/sunsu.c | 14 -------------- 1 file changed, 14 deletions(-)
drivers/tty/serial/sunsu.c +0 -14
@@ -159,20 +159,6 @@ static void serial_icr_write(struct uart_sunsu_port *up, int offset, int value)serial_out (up,UART_ICR , value); } -#if 0 /* Unused currently */ -static unsigned int serial_icr_read (struct uart_sunsu_port *up,int offset) -{ -unsigned int value; - -serial_icr_write (up,UART_ACR , up->acr |UART_ACR_ICRRD ); -serial_out (up,UART_SCR , offset); - value =serial_in (up,UART_ICR ); -serial_icr_write (up,UART_ACR , up->acr); - -return value; -} -#endif -#ifdef CONFIG_SERIAL_8250_RSA /* * Attempts to turn on the RSA FIFO. Returns zero on failure.
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 25/31 serial: remove redundant tty_port_link_device()
In reply to Jiri Slaby (SUSE)The linking is done implicitly by tty_port_register_device_attr_serdev() few lines below. So drop this explicit tty_port_link_device().
--- drivers/tty/serial/serial_core.c | 1 - 1 file changed, 1 deletion(-)
drivers/tty/serial/serial_core.c +0 -1
@@ -3156,7 +3156,6 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *uif (uport->cons && uport->dev)of_console_check (uport->dev->of_node, uport->cons->name, uport->line); -tty_port_link_device (port, drv->tty_driver, uport->line);uart_configure_port (drv, state, uport); port->console =uart_console (uport);
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 26/31 serial: pass struct uart_state to uart_line_info()
In reply to Jiri Slaby (SUSE)uart_line_info() wants to work with struct uart_state. Do not pass a driver and an index. Pass the precomputed struct directly.
--- drivers/tty/serial/serial_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/tty/serial/serial_core.c +2 -3
@@ -2013,9 +2013,8 @@ static const char *uart_type(struct uart_port *port)#ifdef CONFIG_PROC_FS -static void uart_line_info (struct seq_file *m,struct uart_driver *drv,int i) +static void uart_line_info (struct seq_file *m,struct uart_state *state) { -struct uart_state *state = drv->state + i;struct tty_port *port = &state->port;enum uart_pm_state pm_state;struct uart_port *uport;
@@ -2100,7 +2099,7 @@ static int uart_proc_show(struct seq_file *m, void *v)seq_printf (m,"serinfo:1.0 driver%s%s revision:%s\n" ,"" ,"" ,"" );for (i =0 ; i < drv->nr; i++) -uart_line_info (m, drv, i); +uart_line_info (m, drv->state + i); return 0; }#endif
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 27/31 serial: 8250: use serial_port_in/out() helpers
In reply to Jiri Slaby (SUSE)There are serial_port_in/out() helpers to be used instead of direct p->serial_in/out(). Use them in various 8250 drivers.
--
[v2]
* Use serial_port_in/out() and not serial_in/out() [Andy]
--- drivers/tty/serial/8250/8250_dw.c | 16 ++++++++-------- drivers/tty/serial/8250/8250_fsl.c | 8 ++++---- drivers/tty/serial/8250/8250_omap.c | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/tty/serial/8250/8250_dw.c +8 -8
@@ -120,12 +120,12 @@ static void dw8250_force_idle(struct uart_port *p)* enabled. */ if (up->fcr &UART_FCR_ENABLE_FIFO ) { - lsr = p->serial_in (p,UART_LSR ); + lsr =serial_port_in (p,UART_LSR );if (!(lsr &UART_LSR_DR ))return ; } - (void )p->serial_in (p,UART_RX ); +serial_port_in (p,UART_RX ); }static void dw8250_check_lcr (struct uart_port *p,int offset,int value)
@@ -139,7 +139,7 @@ static void dw8250_check_lcr(struct uart_port *p, int offset, int value)/* Make sure LCR write wasn't ignored */ while (tries--) { -unsigned int lcr = p->serial_in (p, offset); +unsigned int lcr =serial_port_in (p, offset);if ((value & ~UART_LCR_SPAR ) == (lcr & ~UART_LCR_SPAR ))return ;
@@ -260,7 +260,7 @@ static int dw8250_handle_irq(struct uart_port *p) {struct uart_8250_port *up =up_to_u8250p (p);struct dw8250_data *d =to_dw8250_data (p->private_data); -unsigned int iir = p->serial_in (p,UART_IIR ); +unsigned int iir =serial_port_in (p,UART_IIR );bool rx_timeout = (iir &0x3f ) ==UART_IIR_RX_TIMEOUT ;unsigned int quirks = d->pdata->quirks;unsigned int status;
@@ -281,7 +281,7 @@ static int dw8250_handle_irq(struct uart_port *p) status =serial_lsr_in (up);if (!(status & (UART_LSR_DR |UART_LSR_BI ))) - (void ) p->serial_in (p,UART_RX ); +serial_port_in (p,UART_RX );uart_port_unlock_irqrestore (p, flags); }
@@ -303,7 +303,7 @@ static int dw8250_handle_irq(struct uart_port *p)if ((iir &UART_IIR_BUSY ) ==UART_IIR_BUSY ) {/* Clear the USR */ - (void )p->serial_in (p, d->pdata->usr_reg); +serial_port_in (p, d->pdata->usr_reg);return 1 ; }
@@ -390,7 +390,7 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,static void dw8250_set_ldisc (struct uart_port *p,struct ktermios *termios) {struct uart_8250_port *up =up_to_u8250p (p); -unsigned int mcr = p->serial_in (p,UART_MCR ); +unsigned int mcr =serial_port_in (p,UART_MCR );if (up->capabilities &UART_CAP_IRDA ) {if (termios->c_line ==N_IRDA )
@@ -398,7 +398,7 @@ static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios)else mcr &= ~DW_UART_MCR_SIRE ; - p->serial_out (p,UART_MCR , mcr); +serial_port_out (p,UART_MCR , mcr); }serial8250_do_set_ldisc (p, termios); }
drivers/tty/serial/8250/8250_fsl.c +4 -4
@@ -32,7 +32,7 @@ int fsl8250_handle_irq(struct uart_port *port)uart_port_lock_irqsave (&up->port, &flags); - iir = port->serial_in (port,UART_IIR ); + iir =serial_port_in (port,UART_IIR );if (iir &UART_IIR_NO_INT ) {uart_port_unlock_irqrestore (&up->port, flags);return 0 ;
@@ -54,12 +54,12 @@ int fsl8250_handle_irq(struct uart_port *port)if (unlikely ((iir &UART_IIR_ID ) ==UART_IIR_RLSI && (up->lsr_saved_flags &UART_LSR_BI ))) { up->lsr_saved_flags &= ~UART_LSR_BI ; - port->serial_in (port,UART_RX ); +serial_port_in (port,UART_RX );uart_port_unlock_irqrestore (&up->port, flags);return 1 ; } - lsr = orig_lsr = up->port.serial_in (&up->port,UART_LSR ); + lsr = orig_lsr =serial_port_in (port,UART_LSR );/* Process incoming characters first */ if ((lsr & (UART_LSR_DR | UART_LSR_BI)) &&
@@ -71,7 +71,7 @@ int fsl8250_handle_irq(struct uart_port *port)if ((orig_lsr &UART_LSR_OE ) && (up->overrun_backoff_time_ms >0 )) {unsigned long delay; - up->ier = port->serial_in (port,UART_IER ); + up->ier =serial_port_in (port,UART_IER );if (up->ier & (UART_IER_RLSI |UART_IER_RDI )) { port->ops->stop_rx (port); }else {
drivers/tty/serial/8250/8250_omap.c +1 -1
@@ -692,7 +692,7 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id)/* Synchronize UART_IER access against the console. */ uart_port_lock (port); - up->ier = port->serial_in (port,UART_IER ); + up->ier =serial_port_in (port,UART_IER );if (up->ier & (UART_IER_RLSI |UART_IER_RDI )) { port->ops->stop_rx (port); }else {
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 28/31 serial: 8250_rsa: simplify rsa8250_{request/release}_resource()
In reply to Jiri Slaby (SUSE)* Use already defined 'port' for fetching start/offset, and size.
* Return from the switch immediately -- so it is clear what is returned and when.
--- drivers/tty/serial/8250/8250_rsa.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/tty/serial/8250/8250_rsa.c +9 -12
@@ -16,30 +16,27 @@ static unsigned int probe_rsa_count;static int rsa8250_request_resource (struct uart_8250_port *up) { -unsigned long start =UART_RSA_BASE << up->port.regshift; -unsigned int size =8 << up->port.regshift;struct uart_port *port = &up->port; -int ret = -EINVAL ; +unsigned long start =UART_RSA_BASE << port->regshift; +unsigned int size =8 << port->regshift;switch (port->iotype) {case UPIO_HUB6 :case UPIO_PORT : start += port->iobase; -if (request_region (start, size,"serial-rsa" )) - ret =0 ; -else - ret = -EBUSY ; -break ; +if (!request_region (start, size,"serial-rsa" )) +return -EBUSY ; +return 0 ; +default : +return -EINVAL ; } - -return ret; }static void rsa8250_release_resource (struct uart_8250_port *up) { -unsigned long offset =UART_RSA_BASE << up->port.regshift; -unsigned int size =8 << up->port.regshift;struct uart_port *port = &up->port; +unsigned long offset =UART_RSA_BASE << port->regshift; +unsigned int size =8 << port->regshift;switch (port->iotype) {case UPIO_HUB6 :
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 29/31 serial: 8250_port: do not use goto for UPQ_NO_TXEN_TEST code flow
In reply to Jiri Slaby (SUSE)This is unnecessary here and makes the code harder to follow. Invert the condition and drop the goto+label.
--- drivers/tty/serial/8250/8250_port.c | 34 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 18 deletions(-)
drivers/tty/serial/8250/8250_port.c +16 -18
@@ -2406,28 +2406,26 @@ int serial8250_do_startup(struct uart_port *port)* test if we receive TX irq. This way, we'll never enable * UART_BUG_TXEN. */ -if (up->port.quirks &UPQ_NO_TXEN_TEST ) - goto dont_test_tx_en; - -/* -* Do a quick test to see if we receive an interrupt when we enable -* the TX irq. -*/ -serial_port_out (port,UART_IER ,UART_IER_THRI ); - lsr =serial_port_in (port,UART_LSR ); - iir =serial_port_in (port,UART_IIR ); -serial_port_out (port,UART_IER ,0 ); +if (!(up->port.quirks &UPQ_NO_TXEN_TEST )) { +/* +* Do a quick test to see if we receive an interrupt when we +* enable the TX irq. +*/ +serial_port_out (port,UART_IER ,UART_IER_THRI ); + lsr =serial_port_in (port,UART_LSR ); + iir =serial_port_in (port,UART_IIR ); +serial_port_out (port,UART_IER ,0 ); -if (lsr &UART_LSR_TEMT && iir &UART_IIR_NO_INT ) { -if (!(up->bugs &UART_BUG_TXEN )) { - up->bugs |=UART_BUG_TXEN ; -dev_dbg (port->dev,"enabling bad tx status workarounds\n" ); +if (lsr &UART_LSR_TEMT && iir &UART_IIR_NO_INT ) { +if (!(up->bugs &UART_BUG_TXEN )) { + up->bugs |=UART_BUG_TXEN ; +dev_dbg (port->dev,"enabling bad tx status workarounds\n" ); + } + }else { + up->bugs &= ~UART_BUG_TXEN ; } - }else { - up->bugs &= ~UART_BUG_TXEN ; } -dont_test_tx_en:uart_port_unlock_irqrestore (port, flags);/*
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 30/31 serial: 8250_port: simplify serial8250_request_std_resource()
In reply to Jiri Slaby (SUSE)Return immediately from the error locations or switch-case ends. It is therefore easier to see the flow.
--- drivers/tty/serial/8250/8250_port.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-)
drivers/tty/serial/8250/8250_port.c +10 -15
@@ -2966,7 +2966,6 @@ static int serial8250_request_std_resource(struct uart_8250_port *up) {unsigned int size =serial8250_port_size (up);struct uart_port *port = &up->port; -int ret =0 ;switch (port->iotype) {case UPIO_AU :
@@ -2975,32 +2974,28 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)case UPIO_MEM32BE :case UPIO_MEM16 :case UPIO_MEM : -if (!port->mapbase) { - ret = -EINVAL ; -break ; - } +if (!port->mapbase) +return -EINVAL ; -if (!request_mem_region (port->mapbase, size,"serial" )) { - ret = -EBUSY ; -break ; - } +if (!request_mem_region (port->mapbase, size,"serial" )) +return -EBUSY ;if (port->flags &UPF_IOREMAP ) { port->membase =ioremap (port->mapbase, size);if (!port->membase) {release_mem_region (port->mapbase, size); - ret = -ENOMEM ; +return -ENOMEM ; } } -break ; - +return 0 ;case UPIO_HUB6 :case UPIO_PORT :if (!request_region (port->iobase, size,"serial" )) - ret = -EBUSY ; -break ; +return -EBUSY ; +return 0 ; } -return ret; + +return 0 ; }static void serial8250_release_std_resource (struct uart_8250_port *up)
Signature · 1 line
2.49.0
Jiri Slaby (SUSE)
maintainerPATCH v2 31/31 serial: switch change_irq and change_port to bool in uart_set_info()
In reply to Jiri Slaby (SUSE)change_irq and change_port are boolean variables. Mark them as such (instead of uint).
---
[v2] this is a new patch
--- drivers/tty/serial/serial_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/serial_core.c +2 -2
@@ -895,8 +895,8 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, {struct uart_port *uport =uart_port_check (state);unsigned long new_port; -unsigned int change_irq, change_port, closing_wait; -unsigned int old_custom_divisor, close_delay; +unsigned int old_custom_divisor, close_delay, closing_wait; +bool change_irq, change_port;upf_t old_flags, new_flags;int retval;
Signature · 1 line
2.49.0
Jiri Slaby
maintainerCc (sorry):
Alex Elder <[email protected]>
Andrew Lunn <[email protected]>
Andy Shevchenko <[email protected]> David Lin <[email protected]>
"David S. Miller" <[email protected]> Eric Dumazet <[email protected]> [email protected]
"Ilpo Järvinen" <[email protected]> Jakub Kicinski <[email protected]>
Johan Hovold <[email protected]> [email protected] [email protected] [email protected]
Matt Turner <[email protected]> [email protected]
Paolo Abeni <[email protected]>
Richard Henderson <[email protected]> Rob Herring <[email protected]> [email protected]
Ulf Hansson <[email protected]>
Quoted 77 lines · Jiri Slaby (SUSE)
Hi,
this is (again) a series of cleanup in tty. I am trying to rework tty+serial to avoid limitations of devices (so called
NR_UARTor tty_alloc_driver()'s first parameter). And the below popped up while crawling through the code. So this is only a prep cleanup.* many tty flags are now enums
* many functions were improved for readability
* quite a few unused or old code droppedIn particular, the runtime behaviour of the kernel before and after the changes is supposed to be bug to bug compatible (except moxa's ioctl and ISA evils dropped). That is, noone should notice.
[v2]
* use serial_port_in/out() helpers in 26/30 (and not use serial_in/out())
* the last patch is newJiri Slaby (SUSE) (31):
tty: convert "TTY Struct Flags" to an enum
tty: audit: do not useN_TTY_BUF_SIZE
tty: caif: do not useN_TTY_BUF_SIZE
tty: moveN_TTY_BUF_SIZEton_tty
tty:n_tty: use uint for space returned bytty_write_room()
tty:n_tty: simplifyprocess_output()
tty:n_tty: clean upprocess_output_block()
tty:n_tty: dropn_tty_trace()
tty:n_tty: extractn_tty_continue_cookie()fromn_tty_read()
tty:n_tty: extractn_tty_wait_for_input()
tty:n_tty: movemore_to_be_readto the end ofn_tty_read()
tty:tty_driver: move TTY macros to the top
tty:tty_driver: convert "TTY Driver Flags" to an enum
tty:tty_driver: document both {,__}tty_alloc_driver() properly
tty:tty_driver: introduce TTY driver sub/types enums
tty: serdev: dropserdev_controller_ops::write_room()
tty: mmc: sdio: use bool for cts and remove parentheses
tty: moxa: drop version dump to logs
tty: moxa: drop ISA support
tty: moxa: carve out special ioctls and extratty_port
tty: srmcons: fix retval fromsrmcons_init()
tty: staging/greybus: passtty_driverflags totty_alloc_driver()
tty: sunsu: drop serial_{in,out}p()
tty: sunsu: remove unusedserial_icr_read()
serial: remove redundanttty_port_link_device()
serial: pass structuart_statetouart_line_info()
serial: 8250: use serial_port_in/out() helpers
serial: 8250_rsa: simplify rsa8250_{request/release}_resource()
serial: 8250_port: do not use goto forUPQ_NO_TXEN_TESTcode flow
serial: 8250_port: simplifyserial8250_request_std_resource()
serial: switchchange_irqandchange_portto bool inuart_set_info()Documentation/driver-api/tty/tty_driver.rst | 4 +- Documentation/driver-api/tty/tty_struct.rst | 2 +- arch/alpha/kernel/srmcons.c | 62 ++--- drivers/mmc/core/sdio_uart.c | 2 +- drivers/net/caif/caif_serial.c | 2 +- drivers/staging/greybus/uart.c | 4 +- drivers/tty/Kconfig | 2 +- drivers/tty/moxa.c | 251 +------------------- drivers/tty/n_tty.c | 212 ++++++++--------- drivers/tty/serdev/core.c | 11 - drivers/tty/serdev/serdev-ttyport.c | 9 - drivers/tty/serial/8250/8250_dw.c | 16 +- drivers/tty/serial/8250/8250_fsl.c | 8 +- drivers/tty/serial/8250/8250_omap.c | 2 +- drivers/tty/serial/8250/8250_port.c | 59 ++--- drivers/tty/serial/8250/8250_rsa.c | 21 +- drivers/tty/serial/serial_core.c | 10 +- drivers/tty/serial/sunsu.c | 178 ++++++-------- drivers/tty/tty_audit.c | 10 +- drivers/tty/tty_io.c | 8 +- include/linux/serdev.h | 6 - include/linux/tty.h | 53 +++-- include/linux/tty_driver.h | 180 +++++++------- 23 files changed, 412 insertions(+), 700 deletions(-)
Signature · 2 lines
js suse labs
Re: [PATCH v2 27/31] serial: 8250: use serial_port_in/out() helpers
In reply to Jiri Slaby (SUSE)Quoted 2 lines · Jiri Slaby (SUSE)
There are serial_port_in/out() helpers to be used instead of direct p->serial_in/out(). Use them in various 8250 drivers.
We also discussed adding some comments. Would you like to send an additional patch or do you rely on me adding them?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jiri Slaby
maintainerRe: [PATCH v2 27/31] serial: 8250: use serial_port_in/out() helpers
Quoted 8 lines · Andy Shevchenko
Quoted 2 lines · Jiri Slaby (SUSE)
There are serial_port_in/out() helpers to be used instead of direct p->serial_in/out(). Use them in various 8250 drivers.
Reviewed-by Andy Shevchenko <[email protected]> # 8250_dwWe also discussed adding some comments. Would you like to send an additional patch or do you rely on me adding them?
Ah, I considered them irrelevant when not using serial_in(), but serial_port_in() et al.
Please send them, it's your (good) work anyway.
thanks,
Signature · 2 lines
js suse labs
Re: [PATCH v2 17/31] tty: mmc: sdio: use bool for cts and remove parentheses
In reply to Jiri Slaby (SUSE)Quoted 8 lines · Jiri Slaby (SUSE)
'cts' in
sdio_uart_check_modem_status()is considered a 'bool', but typed as signed 'int'. Make it 'bool' so it is clear the code does not care about the masked value, but true/false.Signed-off-by Jiri Slaby (SUSE) <[email protected]>Cc Ulf Hansson <[email protected]>
Applied for next, thanks!
Kind regards
Uffe
Quoted 20 lines
--- drivers/mmc/core/sdio_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mmc/core/sdio_uart.c +1
-2@@ -471,7 +471,7 @@ static void sdio_uart_check_modem_status(struct sdio_uart_port *port) port->icount.cts++; tty =tty_port_tty_get (&port->port);if (tty &&C_CRTSCTS (tty)) { -int cts = (status &UART_MSR_CTS ); +bool cts = status &UART_MSR_CTS ;if (tty->hw_stopped) {if (cts) { tty->hw_stopped = false; --2.49.0
Re: [PATCH v2 22/31] tty: staging/greybus: pass tty_driver flags to tty_alloc_driver()
In reply to Jiri Slaby (SUSE)Quoted 1 line · Jiri Slaby (SUSE)
tty_alloc_driver()is supposed to receive tty driver flags.
Looks like tty_alloc_driver() doesn't directly depend on the two flags passed in this case, but this corrects the code.
Looks good to me.
Quoted 33 lines
Signed-off-by Jiri Slaby (SUSE) <[email protected]>Acked-by Johan Hovold <[email protected]>Cc David Lin <[email protected]>Cc Alex Elder <[email protected]>--- drivers/staging/greybus/uart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/greybus/uart.c +2
-2@@ -948,7 +948,8 @@ static int gb_tty_init(void) {int retval =0 ; - gb_tty_driver =tty_alloc_driver (GB_NUM_MINORS ,0 ); + gb_tty_driver =tty_alloc_driver (GB_NUM_MINORS ,TTY_DRIVER_REAL_RAW | +TTY_DRIVER_DYNAMIC_DEV );if (IS_ERR (gb_tty_driver)) {pr_err ("Can not allocate tty driver\n" ); retval = -ENOMEM ;@@ -961,7 +962,6 @@ static int gb_tty_init(void) gb_tty_driver->minor_start =0 ; gb_tty_driver->type =TTY_DRIVER_TYPE_SERIAL ; gb_tty_driver->subtype =SERIAL_TYPE_NORMAL ; - gb_tty_driver->flags =TTY_DRIVER_REAL_RAW |TTY_DRIVER_DYNAMIC_DEV ; gb_tty_driver->init_termios = tty_std_termios; gb_tty_driver->init_termios.c_cflag =B9600 |CS8 |CREAD |HUPCL |CLOCAL ;
Simon Horman
reviewerRe: [PATCH v2 03/31] tty: caif: do not use N_TTY_BUF_SIZE
In reply to Jiri Slaby (SUSE)Quoted 4 lines · Jiri Slaby (SUSE)
N_TTY_BUF_SIZE-- as the name suggests -- is the N_TTY's buffer size. There is no reason to couple that to caif'stty->receive_room. Use 4096 directly -- even though, it should be some sort of "SKB_MAX_ALLOC" or alike. But definitely notN_TTY_BUF_SIZE.
Hi Jiri,
My 2c worth is that 4096 seems like an arbitrary value. Which is fine, but perhaps a comment is warranted.
Quoted 31 lines
N_TTY_BUF_SIZEis private and will be moved ton_tty.clater.Signed-off-by Jiri Slaby (SUSE) <[email protected]>Acked-by Jakub Kicinski <[email protected]>Cc Andrew Lunn <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Paolo Abeni <[email protected]>--- drivers/net/caif/caif_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/caif/caif_serial.c +1
-1@@ -344,7 +344,7 @@ static int ldisc_open(struct tty_struct *tty) ser->tty =tty_kref_get (tty); ser->dev = dev;debugfs_init (ser, tty); - tty->receive_room =N_TTY_BUF_SIZE ; + tty->receive_room =4096 ; tty->disc_data = ser;set_bit (TTY_DO_WRITE_WAKEUP , &tty->flags);rtnl_lock ();Signature · 1 line
2.49.0