Skip to contentSkip to conversation

serial: core: Drop duplicate NULL check in uart_*shutdown()

PATCH In review Andy Shevchenko 3 participants 4 messages Feb 2, 2022 – Feb 4, 2022 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: core: Drop duplicate NULL check in uart_*shutdown()

The free_page(addr), which becomes free_pages(addr, 0) checks addr against 0. No need to repeat this check in the callers.

---
 drivers/tty/serial/serial_core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/tty/serial/serial_core.c +2 -4
index 57f472268b6d..59f93040d807 100644
@@ -328,8 +328,7 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
 	state->xmit.buf = NULL;
 	spin_unlock_irqrestore(&uport->lock, flags);
 
-	if (xmit_buf)
-		free_page((unsigned long)xmit_buf);
+	free_page((unsigned long)xmit_buf);
 }
 
 /**
@@ -1621,8 +1620,7 @@ static void uart_tty_port_shutdown(struct tty_port *port)
 	state->xmit.buf = NULL;
 	spin_unlock_irq(&uport->lock);
 
-	if (buf)
-		free_page((unsigned long)buf);
+	free_page((unsigned long)buf);
 }
 
 static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Andy Shevchenko

The free_page(addr), which becomes free_pages(addr, 0) checks addr against 0. No need to repeat this check in the callers.

Quoted 19 lines
---
  drivers/tty/serial/serial_core.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
drivers/tty/serial/serial_core.c +1 -2
index 57f472268b6d..59f93040d807 100644
@@ -328,8 +328,7 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
  	state->xmit.buf = NULL;
  	spin_unlock_irqrestore(&uport->lock, flags);
 
-	if (xmit_buf)
-		free_page((unsigned long)xmit_buf);
+	free_page((unsigned long)xmit_buf);
  }
 
  /**

drivers/tty/serial/serial_core.c static void uart_tty_port_shutdown(struct tty_port *port) · line 1626

Quoted 9 lines
drivers/tty/serial/serial_core.c +1 -2
@@ -1621,8 +1620,7 @@ static void uart_tty_port_shutdown(struct tty_port *port)
  	state->xmit.buf = NULL;
  	spin_unlock_irq(&uport->lock);
 
-	if (buf)
-		free_page((unsigned long)buf);
+	free_page((unsigned long)buf);
  }
 
  static void uart_wait_until_sent(struct tty_struct *tty, int timeout)

thanks,

Signature · 2 lines
js
suse labs
#2 lore raw
In reply to Andy Shevchenko
Quoted 35 lines · Andy Shevchenko

The free_page(addr), which becomes free_pages(addr, 0) checks addr against 0. No need to repeat this check in the callers.

---
 drivers/tty/serial/serial_core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/tty/serial/serial_core.c +2 -4
index 57f472268b6d..59f93040d807 100644
@@ -328,8 +328,7 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
 	state->xmit.buf = NULL;
 	spin_unlock_irqrestore(&uport->lock, flags);
 
-	if (xmit_buf)
-		free_page((unsigned long)xmit_buf);
+	free_page((unsigned long)xmit_buf);
 }
 
 /**
@@ -1621,8 +1620,7 @@ static void uart_tty_port_shutdown(struct tty_port *port)
 	state->xmit.buf = NULL;
 	spin_unlock_irq(&uport->lock);
 
-	if (buf)
-		free_page((unsigned long)buf);
+	free_page((unsigned long)buf);
 }
 
 static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
Signature · 1 line
2.34.1

What branch is this against? It fails to apply to my tty-next branch :(

#3 lore raw
Quoted 1 line · Greg Kroah-Hartman

On Wed, Feb 02, 2022 at 06:56:48PM +0200, Andy Shevchenko wrote:

...

Quoted 1 line

What branch is this against? It fails to apply to my tty-next branch :(

Linux Next, I think/
Let me rebase on top of yours tty-next.

v2 has just been sent.

Signature · 2 lines
With Best Regards,
Andy Shevchenko