linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] tty/serial: clean up uart_match_port
@ 2021-05-19  7:21 Jiri Slaby
  2021-05-19  7:21 ` [PATCH 2/4] tty/serial: make port of serial8250_register_8250_port const Jiri Slaby
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jiri Slaby @ 2021-05-19  7:21 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

* make parameters const (as they are only read)
* return bool (as comparison results are returned)
* add \n before final return

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/serial/serial_core.c | 16 +++++++++-------
 include/linux/serial_core.h      |  3 ++-
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 33a817c57494..e379fa2e32af 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -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);
 
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 7445c8fd88c0..52d7fb92a69d 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -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
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/4] tty/serial: make port of serial8250_register_8250_port const
  2021-05-19  7:21 [PATCH 1/4] tty/serial: clean up uart_match_port Jiri Slaby
@ 2021-05-19  7:21 ` Jiri Slaby
  2021-05-19  7:21 ` [PATCH 3/4] tty: fix kernel-doc for tty_{read,write} Jiri Slaby
  2021-05-19  7:21 ` [PATCH 4/4] tty: fix kernel-doc for {start,stop}_tty Jiri Slaby
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Slaby @ 2021-05-19  7:21 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

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.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/serial/8250/8250_core.c | 4 ++--
 include/linux/serial_8250.h         | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 1082e76c4d37..1ce193daea7f 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -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;
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 9e655055112d..5db211f43b29 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -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);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/4] tty: fix kernel-doc for tty_{read,write}
  2021-05-19  7:21 [PATCH 1/4] tty/serial: clean up uart_match_port Jiri Slaby
  2021-05-19  7:21 ` [PATCH 2/4] tty/serial: make port of serial8250_register_8250_port const Jiri Slaby
@ 2021-05-19  7:21 ` Jiri Slaby
  2021-05-19  7:21 ` [PATCH 4/4] tty: fix kernel-doc for {start,stop}_tty Jiri Slaby
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Slaby @ 2021-05-19  7:21 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby, Linus Torvalds

After 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.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
---
 drivers/tty/tty_io.c | 37 ++++++++++++++++---------------------
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 8f9e89715a68..ad64232cecae 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -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);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 4/4] tty: fix kernel-doc for {start,stop}_tty
  2021-05-19  7:21 [PATCH 1/4] tty/serial: clean up uart_match_port Jiri Slaby
  2021-05-19  7:21 ` [PATCH 2/4] tty/serial: make port of serial8250_register_8250_port const Jiri Slaby
  2021-05-19  7:21 ` [PATCH 3/4] tty: fix kernel-doc for tty_{read,write} Jiri Slaby
@ 2021-05-19  7:21 ` Jiri Slaby
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Slaby @ 2021-05-19  7:21 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Commit f9e053dcfc02 (tty: Serialize tty flow control changes with
flow_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.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/tty_io.c | 40 +++++++++++++++++++---------------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index ad64232cecae..26debec26b4e 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -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;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-19  7:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19  7:21 [PATCH 1/4] tty/serial: clean up uart_match_port Jiri Slaby
2021-05-19  7:21 ` [PATCH 2/4] tty/serial: make port of serial8250_register_8250_port const Jiri Slaby
2021-05-19  7:21 ` [PATCH 3/4] tty: fix kernel-doc for tty_{read,write} Jiri Slaby
2021-05-19  7:21 ` [PATCH 4/4] tty: fix kernel-doc for {start,stop}_tty Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).