linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] serial: Core cleanups
@ 2023-03-09  8:09 Ilpo Järvinen
  2023-03-09  8:09 ` [PATCH 1/8] serial: Use ARRAY_SIZE() with iso7816 reserved array Ilpo Järvinen
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2023-03-09  8:09 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-kernel, Ilpo Järvinen

Serial core cleanups.

Ilpo Järvinen (8):
  serial: Use ARRAY_SIZE() with iso7816 reserved array
  serial: Use B0 instead of implicit zero assumption
  serial: Remove extern from func prototypes in headers
  serial: Move uart_change_speed() earlier
  serial: Rename uart_change_speed() to uart_change_line_settings()
  serial: Make hw_stopped bool
  serial: Rename hw_stopped to old_hw_stopped & improve logic
  serial: Remove uart_wait_until_sent() forward declaration

 drivers/tty/serial/serial_core.c | 113 +++++++++++++++----------------
 include/linux/serial_8250.h      |  41 +++++------
 include/linux/serial_core.h      |  15 ++--
 3 files changed, 80 insertions(+), 89 deletions(-)

-- 
2.30.2


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

* [PATCH 1/8] serial: Use ARRAY_SIZE() with iso7816 reserved array
  2023-03-09  8:09 [PATCH 0/8] serial: Core cleanups Ilpo Järvinen
@ 2023-03-09  8:09 ` Ilpo Järvinen
  2023-03-09  8:09 ` [PATCH 2/8] serial: Use B0 instead of implicit zero assumption Ilpo Järvinen
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2023-03-09  8:09 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, linux-kernel
  Cc: Ilpo Järvinen

Instead of a literal, size the for loop iteration based on the actual
array using ARRAY_SIZE().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/serial_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 2bd32c8ece39..ee2aabcc8943 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/console.h>
 #include <linux/gpio/consumer.h>
+#include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
@@ -1491,7 +1492,7 @@ static int uart_set_iso7816_config(struct uart_port *port,
 	 * There are 5 words reserved for future use. Check that userspace
 	 * doesn't put stuff in there to prevent breakages in the future.
 	 */
-	for (i = 0; i < 5; i++)
+	for (i = 0; i < ARRAY_SIZE(iso7816.reserved); i++)
 		if (iso7816.reserved[i])
 			return -EINVAL;
 
-- 
2.30.2


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

* [PATCH 2/8] serial: Use B0 instead of implicit zero assumption
  2023-03-09  8:09 [PATCH 0/8] serial: Core cleanups Ilpo Järvinen
  2023-03-09  8:09 ` [PATCH 1/8] serial: Use ARRAY_SIZE() with iso7816 reserved array Ilpo Järvinen
@ 2023-03-09  8:09 ` Ilpo Järvinen
  2023-03-09  8:09 ` [PATCH 3/8] serial: Remove extern from func prototypes in headers Ilpo Järvinen
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2023-03-09  8:09 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, linux-kernel
  Cc: Ilpo Järvinen

Compare against B0 rather than assume B0 equals zero, which is true for
all archs but explicit B0 makes the code more obvious.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/serial_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index ee2aabcc8943..296d2c33ea7a 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1662,10 +1662,10 @@ static void uart_set_termios(struct tty_struct *tty,
 	cflag = tty->termios.c_cflag;
 
 	/* Handle transition to B0 status */
-	if ((old_termios->c_cflag & CBAUD) && !(cflag & CBAUD))
+	if (((old_termios->c_cflag & CBAUD) != B0) && ((cflag & CBAUD) == B0))
 		uart_clear_mctrl(uport, TIOCM_RTS | TIOCM_DTR);
 	/* Handle transition away from B0 status */
-	else if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) {
+	else if (((old_termios->c_cflag & CBAUD) == B0) && ((cflag & CBAUD) != B0)) {
 		unsigned int mask = TIOCM_DTR;
 
 		if (!(cflag & CRTSCTS) || !tty_throttled(tty))
-- 
2.30.2


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

* [PATCH 3/8] serial: Remove extern from func prototypes in headers
  2023-03-09  8:09 [PATCH 0/8] serial: Core cleanups Ilpo Järvinen
  2023-03-09  8:09 ` [PATCH 1/8] serial: Use ARRAY_SIZE() with iso7816 reserved array Ilpo Järvinen
  2023-03-09  8:09 ` [PATCH 2/8] serial: Use B0 instead of implicit zero assumption Ilpo Järvinen
@ 2023-03-09  8:09 ` Ilpo Järvinen
  2023-03-09  8:09 ` [PATCH 4/8] serial: Move uart_change_speed() earlier Ilpo Järvinen
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2023-03-09  8:09 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, linux-kernel
  Cc: Ilpo Järvinen

Remove unnecessary externs from function prototypes in serial_8250.h
and serial_core.h.

Suggested-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 include/linux/serial_8250.h | 41 ++++++++++++++++---------------------
 include/linux/serial_core.h | 13 ++++++------
 2 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 19376bee9667..482ce4e66a6b 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -151,26 +151,22 @@ void serial8250_unregister_port(int line);
 void serial8250_suspend_port(int line);
 void serial8250_resume_port(int line);
 
-extern int early_serial_setup(struct uart_port *port);
-
-extern int early_serial8250_setup(struct earlycon_device *device,
-					 const char *options);
-extern void serial8250_update_uartclk(struct uart_port *port,
-				      unsigned int uartclk);
-extern void serial8250_do_set_termios(struct uart_port *port,
-		struct ktermios *termios, const struct ktermios *old);
-extern void serial8250_do_set_ldisc(struct uart_port *port,
-				    struct ktermios *termios);
-extern unsigned int serial8250_do_get_mctrl(struct uart_port *port);
-extern int serial8250_do_startup(struct uart_port *port);
-extern void serial8250_do_shutdown(struct uart_port *port);
-extern void serial8250_do_pm(struct uart_port *port, unsigned int state,
-			     unsigned int oldstate);
-extern void serial8250_do_set_mctrl(struct uart_port *port, unsigned int mctrl);
-extern void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud,
-				      unsigned int quot,
-				      unsigned int quot_frac);
-extern int fsl8250_handle_irq(struct uart_port *port);
+int early_serial_setup(struct uart_port *port);
+int early_serial8250_setup(struct earlycon_device *device, const char *options);
+
+void serial8250_update_uartclk(struct uart_port *port, unsigned int uartclk);
+void serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
+			       const struct ktermios *old);
+void serial8250_do_set_ldisc(struct uart_port *port, struct ktermios *termios);
+unsigned int serial8250_do_get_mctrl(struct uart_port *port);
+int serial8250_do_startup(struct uart_port *port);
+void serial8250_do_shutdown(struct uart_port *port);
+void serial8250_do_pm(struct uart_port *port, unsigned int state,
+		      unsigned int oldstate);
+void serial8250_do_set_mctrl(struct uart_port *port, unsigned int mctrl);
+void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud,
+			       unsigned int quot, unsigned int quot_frac);
+int fsl8250_handle_irq(struct uart_port *port);
 int serial8250_handle_irq(struct uart_port *port, unsigned int iir);
 u16 serial8250_rx_chars(struct uart_8250_port *up, u16 lsr);
 void serial8250_read_char(struct uart_8250_port *up, u16 lsr);
@@ -183,9 +179,8 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s,
 int serial8250_console_setup(struct uart_port *port, char *options, bool probe);
 int serial8250_console_exit(struct uart_port *port);
 
-extern void serial8250_set_isa_configurator(void (*v)
-					(int port, struct uart_port *up,
-						u32 *capabilities));
+void serial8250_set_isa_configurator(void (*v)(int port, struct uart_port *up,
+					       u32 *capabilities));
 
 #ifdef CONFIG_SERIAL_8250_RT288X
 unsigned int au_serial_in(struct uart_port *p, int offset);
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 9e3e5e0d11b2..05d18a145b3a 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -812,9 +812,8 @@ extern const struct earlycon_id __earlycon_table_end[];
 
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
-extern int of_setup_earlycon(const struct earlycon_id *match,
-			     unsigned long node,
-			     const char *options);
+int of_setup_earlycon(const struct earlycon_id *match, unsigned long node,
+		      const char *options);
 
 #ifdef CONFIG_SERIAL_EARLYCON
 extern bool earlycon_acpi_spcr_enable __initdata;
@@ -897,11 +896,11 @@ static inline bool uart_softcts_mode(struct uart_port *uport)
  * The following are helper functions for the low level drivers.
  */
 
-extern void uart_handle_dcd_change(struct uart_port *uport, bool active);
-extern void uart_handle_cts_change(struct uart_port *uport, bool active);
+void uart_handle_dcd_change(struct uart_port *uport, bool active);
+void uart_handle_cts_change(struct uart_port *uport, bool active);
 
-extern void uart_insert_char(struct uart_port *port, unsigned int status,
-		 unsigned int overrun, unsigned int ch, unsigned int flag);
+void uart_insert_char(struct uart_port *port, unsigned int status,
+		      unsigned int overrun, unsigned int ch, unsigned int flag);
 
 void uart_xchar_out(struct uart_port *uport, int offset);
 
-- 
2.30.2


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

* [PATCH 4/8] serial: Move uart_change_speed() earlier
  2023-03-09  8:09 [PATCH 0/8] serial: Core cleanups Ilpo Järvinen
                   ` (2 preceding siblings ...)
  2023-03-09  8:09 ` [PATCH 3/8] serial: Remove extern from func prototypes in headers Ilpo Järvinen
@ 2023-03-09  8:09 ` Ilpo Järvinen
  2023-03-09  8:09 ` [PATCH 5/8] serial: Rename uart_change_speed() to uart_change_line_settings() Ilpo Järvinen
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2023-03-09  8:09 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, linux-kernel
  Cc: Ilpo Järvinen

Move uart_change_speed() earlier to get rid of its forward declaration.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/serial_core.c | 94 ++++++++++++++++----------------
 1 file changed, 46 insertions(+), 48 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 296d2c33ea7a..7201bbc44fa7 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -49,8 +49,6 @@ static struct lock_class_key port_lock_key;
  */
 #define RS485_MAX_RTS_DELAY	100 /* msecs */
 
-static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
-			      const struct ktermios *old_termios);
 static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
 static void uart_change_pm(struct uart_state *state,
 			   enum uart_pm_state pm_state);
@@ -178,6 +176,52 @@ static void uart_port_dtr_rts(struct uart_port *uport, bool active)
 		uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
 }
 
+/* Caller holds port mutex */
+static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
+			      const struct ktermios *old_termios)
+{
+	struct uart_port *uport = uart_port_check(state);
+	struct ktermios *termios;
+	int hw_stopped;
+
+	/*
+	 * If we have no tty, termios, or the port does not exist,
+	 * then we can't set the parameters for this port.
+	 */
+	if (!tty || uport->type == PORT_UNKNOWN)
+		return;
+
+	termios = &tty->termios;
+	uport->ops->set_termios(uport, termios, old_termios);
+
+	/*
+	 * Set modem status enables based on termios cflag
+	 */
+	spin_lock_irq(&uport->lock);
+	if (termios->c_cflag & CRTSCTS)
+		uport->status |= UPSTAT_CTS_ENABLE;
+	else
+		uport->status &= ~UPSTAT_CTS_ENABLE;
+
+	if (termios->c_cflag & CLOCAL)
+		uport->status &= ~UPSTAT_DCD_ENABLE;
+	else
+		uport->status |= UPSTAT_DCD_ENABLE;
+
+	/* reset sw-assisted CTS flow control based on (possibly) new mode */
+	hw_stopped = uport->hw_stopped;
+	uport->hw_stopped = uart_softcts_mode(uport) &&
+			    !(uport->ops->get_mctrl(uport) & TIOCM_CTS);
+	if (uport->hw_stopped) {
+		if (!hw_stopped)
+			uport->ops->stop_tx(uport);
+	} else {
+		if (hw_stopped)
+			__uart_start(tty);
+	}
+	spin_unlock_irq(&uport->lock);
+}
+
 /*
  * Startup the port.  This will be called once per open.  All calls
  * will be serialised by the per-port mutex.
@@ -486,52 +530,6 @@ uart_get_divisor(struct uart_port *port, unsigned int baud)
 }
 EXPORT_SYMBOL(uart_get_divisor);
 
-/* Caller holds port mutex */
-static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
-			      const struct ktermios *old_termios)
-{
-	struct uart_port *uport = uart_port_check(state);
-	struct ktermios *termios;
-	int hw_stopped;
-
-	/*
-	 * If we have no tty, termios, or the port does not exist,
-	 * then we can't set the parameters for this port.
-	 */
-	if (!tty || uport->type == PORT_UNKNOWN)
-		return;
-
-	termios = &tty->termios;
-	uport->ops->set_termios(uport, termios, old_termios);
-
-	/*
-	 * Set modem status enables based on termios cflag
-	 */
-	spin_lock_irq(&uport->lock);
-	if (termios->c_cflag & CRTSCTS)
-		uport->status |= UPSTAT_CTS_ENABLE;
-	else
-		uport->status &= ~UPSTAT_CTS_ENABLE;
-
-	if (termios->c_cflag & CLOCAL)
-		uport->status &= ~UPSTAT_DCD_ENABLE;
-	else
-		uport->status |= UPSTAT_DCD_ENABLE;
-
-	/* reset sw-assisted CTS flow control based on (possibly) new mode */
-	hw_stopped = uport->hw_stopped;
-	uport->hw_stopped = uart_softcts_mode(uport) &&
-				!(uport->ops->get_mctrl(uport) & TIOCM_CTS);
-	if (uport->hw_stopped) {
-		if (!hw_stopped)
-			uport->ops->stop_tx(uport);
-	} else {
-		if (hw_stopped)
-			__uart_start(tty);
-	}
-	spin_unlock_irq(&uport->lock);
-}
-
 static int uart_put_char(struct tty_struct *tty, unsigned char c)
 {
 	struct uart_state *state = tty->driver_data;
-- 
2.30.2


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

* [PATCH 5/8] serial: Rename uart_change_speed() to uart_change_line_settings()
  2023-03-09  8:09 [PATCH 0/8] serial: Core cleanups Ilpo Järvinen
                   ` (3 preceding siblings ...)
  2023-03-09  8:09 ` [PATCH 4/8] serial: Move uart_change_speed() earlier Ilpo Järvinen
@ 2023-03-09  8:09 ` Ilpo Järvinen
  2023-03-09  8:09 ` [PATCH 6/8] serial: Make hw_stopped bool Ilpo Järvinen
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2023-03-09  8:09 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, linux-kernel
  Cc: Ilpo Järvinen

uart_change_speed() changes more than just speed so rename it to more
generic uart_change_line_settings().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/serial_core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 7201bbc44fa7..ecdc5d9cdb53 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -177,8 +177,8 @@ static void uart_port_dtr_rts(struct uart_port *uport, bool active)
 }
 
 /* Caller holds port mutex */
-static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
-			      const struct ktermios *old_termios)
+static void uart_change_line_settings(struct tty_struct *tty, struct uart_state *state,
+				      const struct ktermios *old_termios)
 {
 	struct uart_port *uport = uart_port_check(state);
 	struct ktermios *termios;
@@ -277,7 +277,7 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
 		/*
 		 * Initialise the hardware port settings.
 		 */
-		uart_change_speed(tty, state, NULL);
+		uart_change_line_settings(tty, state, NULL);
 
 		/*
 		 * Setup the RTS and DTR signals once the
@@ -993,7 +993,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
 				      current->comm,
 				      tty_name(port->tty));
 			}
-			uart_change_speed(tty, state, NULL);
+			uart_change_line_settings(tty, state, NULL);
 		}
 	} else {
 		retval = uart_startup(tty, state, true);
@@ -1655,7 +1655,7 @@ static void uart_set_termios(struct tty_struct *tty,
 		goto out;
 	}
 
-	uart_change_speed(tty, state, old_termios);
+	uart_change_line_settings(tty, state, old_termios);
 	/* reload cflag from termios; port driver may have overridden flags */
 	cflag = tty->termios.c_cflag;
 
@@ -2451,7 +2451,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
 			ret = ops->startup(uport);
 			if (ret == 0) {
 				if (tty)
-					uart_change_speed(tty, state, NULL);
+					uart_change_line_settings(tty, state, NULL);
 				spin_lock_irq(&uport->lock);
 				if (!(uport->rs485.flags & SER_RS485_ENABLED))
 					ops->set_mctrl(uport, uport->mctrl);
-- 
2.30.2


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

* [PATCH 6/8] serial: Make hw_stopped bool
  2023-03-09  8:09 [PATCH 0/8] serial: Core cleanups Ilpo Järvinen
                   ` (4 preceding siblings ...)
  2023-03-09  8:09 ` [PATCH 5/8] serial: Rename uart_change_speed() to uart_change_line_settings() Ilpo Järvinen
@ 2023-03-09  8:09 ` Ilpo Järvinen
  2023-03-09  8:09 ` [PATCH 7/8] serial: Rename hw_stopped to old_hw_stopped & improve logic Ilpo Järvinen
  2023-03-09  8:09 ` [PATCH 8/8] serial: Remove uart_wait_until_sent() forward declaration Ilpo Järvinen
  7 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2023-03-09  8:09 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, linux-kernel
  Cc: Ilpo Järvinen

Convert hw_stopped in uart_port to bool because its more appropriate
type for how it is used.

Also convert the local variable in uart_change_line_settings() caching
old hw_stopped to bool.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/serial_core.c | 6 +++---
 include/linux/serial_core.h      | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index ecdc5d9cdb53..31b69e61e71d 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -182,7 +182,7 @@ static void uart_change_line_settings(struct tty_struct *tty, struct uart_state
 {
 	struct uart_port *uport = uart_port_check(state);
 	struct ktermios *termios;
-	int hw_stopped;
+	bool hw_stopped;
 
 	/*
 	 * If we have no tty, termios, or the port does not exist,
@@ -3304,13 +3304,13 @@ void uart_handle_cts_change(struct uart_port *uport, bool active)
 	if (uart_softcts_mode(uport)) {
 		if (uport->hw_stopped) {
 			if (active) {
-				uport->hw_stopped = 0;
+				uport->hw_stopped = false;
 				uport->ops->start_tx(uport);
 				uart_write_wakeup(uport);
 			}
 		} else {
 			if (!active) {
-				uport->hw_stopped = 1;
+				uport->hw_stopped = true;
 				uport->ops->stop_tx(uport);
 			}
 		}
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 05d18a145b3a..66ecec15a1bf 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -553,7 +553,7 @@ struct uart_port {
 #define UPSTAT_AUTOXOFF		((__force upstat_t) (1 << 4))
 #define UPSTAT_SYNC_FIFO	((__force upstat_t) (1 << 5))
 
-	int			hw_stopped;		/* sw-assisted CTS flow state */
+	bool			hw_stopped;		/* sw-assisted CTS flow state */
 	unsigned int		mctrl;			/* current modem ctrl settings */
 	unsigned int		frame_time;		/* frame timing in ns */
 	unsigned int		type;			/* port type */
-- 
2.30.2


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

* [PATCH 7/8] serial: Rename hw_stopped to old_hw_stopped & improve logic
  2023-03-09  8:09 [PATCH 0/8] serial: Core cleanups Ilpo Järvinen
                   ` (5 preceding siblings ...)
  2023-03-09  8:09 ` [PATCH 6/8] serial: Make hw_stopped bool Ilpo Järvinen
@ 2023-03-09  8:09 ` Ilpo Järvinen
  2023-03-09  8:09 ` [PATCH 8/8] serial: Remove uart_wait_until_sent() forward declaration Ilpo Järvinen
  7 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2023-03-09  8:09 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, linux-kernel
  Cc: Ilpo Järvinen

hw_stopped in uart_change_line_settings() stores old hw_stopped, thus
rename it appropriately.

Alter logic to check first if the hw_stopped was changed, and then pick
which function to call if it was because the logic is more obvious that
way.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/serial_core.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 31b69e61e71d..c494cb39394b 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -182,7 +182,7 @@ static void uart_change_line_settings(struct tty_struct *tty, struct uart_state
 {
 	struct uart_port *uport = uart_port_check(state);
 	struct ktermios *termios;
-	bool hw_stopped;
+	bool old_hw_stopped;
 
 	/*
 	 * If we have no tty, termios, or the port does not exist,
@@ -209,14 +209,13 @@ static void uart_change_line_settings(struct tty_struct *tty, struct uart_state
 		uport->status |= UPSTAT_DCD_ENABLE;
 
 	/* reset sw-assisted CTS flow control based on (possibly) new mode */
-	hw_stopped = uport->hw_stopped;
+	old_hw_stopped = uport->hw_stopped;
 	uport->hw_stopped = uart_softcts_mode(uport) &&
 			    !(uport->ops->get_mctrl(uport) & TIOCM_CTS);
-	if (uport->hw_stopped) {
-		if (!hw_stopped)
+	if (uport->hw_stopped != old_hw_stopped) {
+		if (!old_hw_stopped)
 			uport->ops->stop_tx(uport);
-	} else {
-		if (hw_stopped)
+		else
 			__uart_start(tty);
 	}
 	spin_unlock_irq(&uport->lock);
-- 
2.30.2


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

* [PATCH 8/8] serial: Remove uart_wait_until_sent() forward declaration
  2023-03-09  8:09 [PATCH 0/8] serial: Core cleanups Ilpo Järvinen
                   ` (6 preceding siblings ...)
  2023-03-09  8:09 ` [PATCH 7/8] serial: Rename hw_stopped to old_hw_stopped & improve logic Ilpo Järvinen
@ 2023-03-09  8:09 ` Ilpo Järvinen
  7 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2023-03-09  8:09 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, linux-kernel
  Cc: Ilpo Järvinen

Remove unnecessary forward declaration of uart_wait_until_sent().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/serial_core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index c494cb39394b..db7f6c0c39bf 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -49,7 +49,6 @@ static struct lock_class_key port_lock_key;
  */
 #define RS485_MAX_RTS_DELAY	100 /* msecs */
 
-static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
 static void uart_change_pm(struct uart_state *state,
 			   enum uart_pm_state pm_state);
 
-- 
2.30.2


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

end of thread, other threads:[~2023-03-09  8:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09  8:09 [PATCH 0/8] serial: Core cleanups Ilpo Järvinen
2023-03-09  8:09 ` [PATCH 1/8] serial: Use ARRAY_SIZE() with iso7816 reserved array Ilpo Järvinen
2023-03-09  8:09 ` [PATCH 2/8] serial: Use B0 instead of implicit zero assumption Ilpo Järvinen
2023-03-09  8:09 ` [PATCH 3/8] serial: Remove extern from func prototypes in headers Ilpo Järvinen
2023-03-09  8:09 ` [PATCH 4/8] serial: Move uart_change_speed() earlier Ilpo Järvinen
2023-03-09  8:09 ` [PATCH 5/8] serial: Rename uart_change_speed() to uart_change_line_settings() Ilpo Järvinen
2023-03-09  8:09 ` [PATCH 6/8] serial: Make hw_stopped bool Ilpo Järvinen
2023-03-09  8:09 ` [PATCH 7/8] serial: Rename hw_stopped to old_hw_stopped & improve logic Ilpo Järvinen
2023-03-09  8:09 ` [PATCH 8/8] serial: Remove uart_wait_until_sent() forward declaration Ilpo Järvinen

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