Skip to contentSkip to conversation

serial: 8250_port: Drop duplicate NULL check

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: 8250_port: Drop duplicate NULL check

serial8250_release_dma() is NULL-aware, no need to check this in the caller. While at it, make sure DMA won't be used again, by NULLifying the pointer.

---
 drivers/tty/serial/8250/8250_port.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_port.c +2 -2
index d99c5ad7e47c..2a830969d22b 100644
@@ -2366,8 +2366,8 @@ void serial8250_do_shutdown(struct uart_port *port)
 
 	synchronize_irq(port->irq);
 
-	if (up->dma)
-		serial8250_release_dma(up);
+	serial8250_release_dma(up);
+	up->dma = NULL;
 
 	scoped_guard(uart_port_lock_irqsave, port) {
 		if (port->flags & UPF_FOURPORT) {
Signature · 1 line
2.50.1
maintainer
#1 lore raw
Quoted 13 lines · Andy Shevchenko

serial8250_release_dma() is NULL-aware, no need to check this in the caller. While at it, make sure DMA won't be used again, by NULLifying the pointer.

---
  drivers/tty/serial/8250/8250_port.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_port.c +0 -0
index d99c5ad7e47c..2a830969d22b 100644

drivers/tty/serial/8250/8250_port.c void serial8250_do_shutdown(struct uart_port *port) · line 2370

Quoted 7 lines
drivers/tty/serial/8250/8250_port.c +2 -2
@@ -2366,8 +2366,8 @@ void serial8250_do_shutdown(struct uart_port *port)
 
  	synchronize_irq(port->irq);
 
-	if (up->dma)
-		serial8250_release_dma(up);
+	serial8250_release_dma(up);
+	up->dma = NULL;

Shouldn't serial8250_release_dma() NULL it instead, so the callers need not to bother?

thanks,

Signature · 2 lines
js
suse labs
#2 lore raw
Quoted 4 lines · Jiri Slaby
Quoted 2 lines · Andy Shevchenko

serial8250_release_dma() is NULL-aware, no need to check this in the caller. While at it, make sure DMA won't be used again, by NULLifying the pointer.

Quoted 8 lines

drivers/tty/serial/8250/8250_port.c void serial8250_do_shutdown(struct uart_port *port) · line 2370

Quoted 5 lines
  	synchronize_irq(port->irq);
drivers/tty/serial/8250/8250_port.c +2 -2
-	if (up->dma)
-		serial8250_release_dma(up);
+	serial8250_release_dma(up);
+	up->dma = NULL;

Shouldn't serial8250_release_dma() NULL it instead, so the callers need not to bother?

I copied what 8250_omap is doing. But we can do what you suggested I think.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Jiri Slaby
Quoted 2 lines · Andy Shevchenko

serial8250_release_dma() is NULL-aware, no need to check this in the caller. While at it, make sure DMA won't be used again, by NULLifying the pointer.

...

Quoted 9 lines
Quoted 7 lines

drivers/tty/serial/8250/8250_port.c void serial8250_do_shutdown(struct uart_port *port) · line 2370

Quoted 4 lines
drivers/tty/serial/8250/8250_port.c +2 -2
-	if (up->dma)
-		serial8250_release_dma(up);
+	serial8250_release_dma(up);
+	up->dma = NULL;

Shouldn't serial8250_release_dma() NULL it instead, so the callers need not to bother?

I copied what 8250_omap is doing. But we can do what you suggested I think.

I looked at the 8250_dma code and serial8250_release_dma() in particular, and I think I am not going to change the approach. The 'dma' pointer is assigned outside of serial8250_request_dma() and NULLifying it in serial8250_release_dma() will be a layering violation.

Signature · 2 lines
With Best Regards,
Andy Shevchenko