tty/serial: clean up uart_match_port
PATCH 1/4 tty/serial: clean up uart_match_port
* make parameters const (as they are only read)
* return bool (as comparison results are returned)
* add \n before final return
--- drivers/tty/serial/serial_core.c | 16 +++++++++------- include/linux/serial_core.h | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-)
drivers/tty/serial/serial_core.c +9 -7
@@ -3005,26 +3005,28 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *uport)/* * Are the two ports equivalent? */ -int uart_match_port (struct uart_port *port1,struct uart_port *port2) +bool uart_match_port (const struct uart_port *port1, +const struct uart_port *port2) {if (port1->iotype != port2->iotype) -return 0 ; +return false;switch (port1->iotype) {case UPIO_PORT : -return (port1->iobase == port2->iobase); +return port1->iobase == port2->iobase;case UPIO_HUB6 : -return (port1->iobase == port2->iobase) && - (port1->hub6 == port2->hub6); +return port1->iobase == port2->iobase && + port1->hub6 == port2->hub6;case UPIO_MEM :case UPIO_MEM16 :case UPIO_MEM32 :case UPIO_MEM32BE :case UPIO_AU :case UPIO_TSI : -return (port1->mapbase == port2->mapbase); +return port1->mapbase == port2->mapbase; } -return 0 ; + +return false; }EXPORT_SYMBOL (uart_match_port);
include/linux/serial_core.h +2 -1
@@ -408,7 +408,8 @@ int uart_register_driver(struct uart_driver *uart);void uart_unregister_driver (struct uart_driver *uart);int uart_add_one_port (struct uart_driver *reg,struct uart_port *port);int uart_remove_one_port (struct uart_driver *reg,struct uart_port *port); -int uart_match_port (struct uart_port *port1,struct uart_port *port2); +bool uart_match_port (const struct uart_port *port1, +const struct uart_port *port2);/* * Power Management
Signature · 1 line
2.31.1
PATCH 2/4 tty/serial: make port of serial8250_register_8250_port const
After the previous patch, we can make port passed to serial8250_find_match_or_unused const. And then we can make const also port of serial8250_register_8250_port.
--- drivers/tty/serial/8250/8250_core.c | 4 ++-- include/linux/serial_8250.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/tty/serial/8250/8250_core.c +2 -2
@@ -906,7 +906,7 @@ static struct platform_device *serial8250_isa_devs;*/ static DEFINE_MUTEX (serial_mutex); -static struct uart_8250_port *serial8250_find_match_or_unused (struct uart_port *port) +static struct uart_8250_port *serial8250_find_match_or_unused (const struct uart_port *port) {int i;
@@ -971,7 +971,7 @@ static void serial_8250_overrun_backoff_work(struct work_struct *work)* * On success the port is ready to use and the line number is returned. */ -int serial8250_register_8250_port (struct uart_8250_port *up) +int serial8250_register_8250_port (const struct uart_8250_port *up) {struct uart_8250_port *uart;int ret = -ENOSPC ;
include/linux/serial_8250.h +1 -1
@@ -146,7 +146,7 @@ static inline struct uart_8250_port *up_to_u8250p(struct uart_port *up) return container_of(up, struct uart_8250_port, port); } -int serial8250_register_8250_port (struct uart_8250_port *); +int serial8250_register_8250_port (const struct uart_8250_port *);void serial8250_unregister_port (int line);void serial8250_suspend_port (int line);void serial8250_resume_port (int line);
Signature · 1 line
2.31.1
PATCH 3/4 tty: fix kernel-doc for tty_{read,write}
In reply to Jiri SlabyAfter commits a9cbbb80e3e7 (tty: avoid using vfs_iocb_iter_write() for
redirected console writes) and dd78b0c483e3 (tty: implement read_iter),
the tty_read and tty_write kernel-doc comments don't match the code:
tty_io.c:931: warning: Function parameter or member 'iocb' not described in 'tty_read' tty_io.c:931: warning: Function parameter or member 'to' not described in 'tty_read' tty_io.c:931: warning: Excess function parameter 'file' description in 'tty_read' tty_io.c:931: warning: Excess function parameter 'buf' description in 'tty_read' tty_io.c:931: warning: Excess function parameter 'count' description in 'tty_read' tty_io.c:931: warning: Excess function parameter 'ppos' description in 'tty_read' tty_io.c:1115: warning: Function parameter or member 'iocb' not described in 'file_tty_write' tty_io.c:1115: warning: Function parameter or member 'from' not described in 'file_tty_write' tty_io.c:1115: warning: expecting prototype for tty_write(). Prototype was for file_tty_write() instead
Fix them to correspond the reality, i.e. the switch from read/write to read_iter/write_iter.
--- drivers/tty/tty_io.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-)
drivers/tty/tty_io.c +16 -21
@@ -911,10 +911,8 @@ static int iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty,/** * tty_read - read method for tty device files -* @file: pointer to tty file -* @buf: user buffer -* @count: size of user buffer -* @ppos: unused +* @iocb: kernel I/O control block +* @to: destination for the data read * * Perform the read system call function on this terminal device. Checks * for hung up devices before calling the line discipline method.
@@ -1092,23 +1090,6 @@ void tty_write_message(struct tty_struct *tty, char *msg) } } - -/** -* tty_write - write method for tty device file -* @file: tty file pointer -* @buf: user data to write -* @count: bytes to write -* @ppos: unused -* -* Write data to a tty device via the line discipline. -* -* Locking: -* Locks the line discipline as required -* Writes to the tty driver are serialized by the atomic_write_lock -* and are then processed in chunks to the device. The line discipline -* write method will not be invoked in parallel for each device. -*/ -static ssize_t file_tty_write (struct file *file,struct kiocb *iocb,struct iov_iter *from) {struct tty_struct *tty =file_tty (file);
@@ -1133,6 +1114,20 @@ static ssize_t file_tty_write(struct file *file, struct kiocb *iocb, struct iov_return ret; } +/** +* tty_write - write method for tty device file +* @iocb: kernel I/O control block +* @from: iov_iter with data to write +* +* Write data to a tty device via the line discipline. +* +* Locking: +* Locks the line discipline as required +* Writes to the tty driver are serialized by the atomic_write_lock +* and are then processed in chunks to the device. The line +* discipline write method will not be invoked in parallel for +* each device. +*/ static ssize_t tty_write (struct kiocb *iocb,struct iov_iter *from) {return file_tty_write (iocb->ki_filp, iocb, from);
Signature · 1 line
2.31.1
PATCH 4/4 tty: fix kernel-doc for {start,stop}_tty
In reply to Jiri SlabyCommit f9e053dcfc02 (tty: Serialize tty flow control changes withflow_lock) renamed start_tty to __start_tty and stop_tty to __stop_tty
and introduced new start_tty and stop_tty. But it left kernel-doc
comments on the old locations:
tty_io.c:785: warning: expecting prototype for stop_tty(). Prototype was for __stop_tty() instead tty_io.c:816: warning: expecting prototype for start_tty(). Prototype was for __start_tty() instead
Fix that by moving the comments to appropriate locations.
--- drivers/tty/tty_io.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-)
drivers/tty/tty_io.c +19 -21
@@ -761,6 +761,15 @@ int tty_hung_up_p(struct file *filp) }EXPORT_SYMBOL (tty_hung_up_p); +void __stop_tty (struct tty_struct *tty) +{ +if (tty->flow.stopped) +return ; + tty->flow.stopped = true; +if (tty->ops->stop) + tty->ops->stop (tty); +} +/** * stop_tty - propagate flow control * @tty: tty to stop
@@ -777,16 +786,6 @@ EXPORT_SYMBOL(tty_hung_up_p);* Locking: * flow.lock */ - -void __stop_tty (struct tty_struct *tty) -{ -if (tty->flow.stopped) -return ; - tty->flow.stopped = true; -if (tty->ops->stop) - tty->ops->stop (tty); -} -void stop_tty (struct tty_struct *tty) {unsigned long flags;
@@ -797,6 +796,16 @@ void stop_tty(struct tty_struct *tty) }EXPORT_SYMBOL (stop_tty); +void __start_tty (struct tty_struct *tty) +{ +if (!tty->flow.stopped || tty->flow.tco_stopped) +return ; + tty->flow.stopped = false; +if (tty->ops->start) + tty->ops->start (tty); +tty_wakeup (tty); +} +/** * start_tty - propagate flow control * @tty: tty to start
@@ -808,17 +817,6 @@ EXPORT_SYMBOL(stop_tty);* Locking: * flow.lock */ - -void __start_tty (struct tty_struct *tty) -{ -if (!tty->flow.stopped || tty->flow.tco_stopped) -return ; - tty->flow.stopped = false; -if (tty->ops->start) - tty->ops->start (tty); -tty_wakeup (tty); -} -void start_tty (struct tty_struct *tty) {unsigned long flags;
Signature · 1 line
2.31.1