serial: mps2-uart: Add parentheses around conditional in mps2_uart_shutdown
Subsystems (2)
PATCH 1/1 serial: mps2-uart: Add parentheses around conditional in mps2_uart_shutdown
Clang warns:
drivers/tty/serial/mps2-uart.c:351:6: warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses]
if (!mps_port->flags & UART_PORT_COMBINED_IRQ) {
^ ~
drivers/tty/serial/mps2-uart.c:351:6: note: add parentheses after the
'!' to evaluate the bitwise operator first
if (!mps_port->flags & UART_PORT_COMBINED_IRQ) {
^
( )
drivers/tty/serial/mps2-uart.c:351:6: note: add parentheses around left
hand side expression to silence this warning
if (!mps_port->flags & UART_PORT_COMBINED_IRQ) {
^
( )1 warning generated.
As it was intended for this check to be the inverse of the one at the bottom of mps2_init_port, add parentheses around the whole conditional.
--- drivers/tty/serial/mps2-uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/mps2-uart.c +1 -1
@@ -348,7 +348,7 @@ static void mps2_uart_shutdown(struct uart_port *port)mps2_uart_write8 (port, control, UARTn_CTRL); -if (!mps_port->flags &UART_PORT_COMBINED_IRQ ) { +if (!(mps_port->flags &UART_PORT_COMBINED_IRQ )) {free_irq (mps_port->rx_irq, mps_port);free_irq (mps_port->tx_irq, mps_port); }
Signature · 1 line
2.20.1
Quoted 34 lines · Nathan Chancellor
Clang warns:
drivers/tty/serial/mps2-uart.c:351:6: warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses]if (!mps_port->flags & UART_PORT_COMBINED_IRQ) { ^ ~ drivers/tty/serial/mps2-uart.c:351:6: note: add parentheses after the '!' to evaluate the bitwise operator first if (!mps_port->flags & UART_PORT_COMBINED_IRQ) { ^ ( ) drivers/tty/serial/mps2-uart.c:351:6: note: add parentheses around left hand side expression to silence this warning if (!mps_port->flags & UART_PORT_COMBINED_IRQ) { ^ ( )1 warning generated.
As it was intended for this check to be the inverse of the one at the bottom of
mps2_init_port, add parentheses around the whole conditional.Fixes 775ea4ea2fd9 ("serial: mps2-uart: support combined irq")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/tty/serial/mps2-uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/tty/serial/mps2-uart.c +0
-0
drivers/tty/serial/mps2-uart.c static void mps2_uart_shutdown(struct uart_port *port) · line 354
Quoted 8 lines
drivers/tty/serial/mps2-uart.c +1
-1@@ -348,7 +348,7 @@ static void mps2_uart_shutdown(struct uart_port *port)mps2_uart_write8 (port, control, UARTn_CTRL); -if (!mps_port->flags &UART_PORT_COMBINED_IRQ ) { +if (!(mps_port->flags &UART_PORT_COMBINED_IRQ )) {free_irq (mps_port->rx_irq, mps_port);free_irq (mps_port->tx_irq, mps_port); }
Quoted 18 lines · Nathan Chancellor
Clang warns:
drivers/tty/serial/mps2-uart.c:351:6: warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses]if (!mps_port->flags & UART_PORT_COMBINED_IRQ) { ^ ~ drivers/tty/serial/mps2-uart.c:351:6: note: add parentheses after the '!' to evaluate the bitwise operator first if (!mps_port->flags & UART_PORT_COMBINED_IRQ) { ^ ( ) drivers/tty/serial/mps2-uart.c:351:6: note: add parentheses around left hand side expression to silence this warning if (!mps_port->flags & UART_PORT_COMBINED_IRQ) { ^ ( )
Quoted 4 lines
1 warning generated.
As it was intended for this check to be the inverse of the one at the bottom of
mps2_init_port, add parentheses around the whole conditional.
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/tty/serial/mps2-uart.c
That function currently has the code:
if (mps_port->flags & UART_PORT_COMBINED_IRQ) {
mps_port->port.irq = platform_get_irq(pdev, 0);
} else {
mps_port->rx_irq = platform_get_irq(pdev, 0);
mps_port->tx_irq = platform_get_irq(pdev, 1);
mps_port->port.irq = platform_get_irq(pdev, 2);
}
while shutdown has:
if (!mps_port->flags & UART_PORT_COMBINED_IRQ) {
free_irq(mps_port->rx_irq, mps_port);
free_irq(mps_port->tx_irq, mps_port);
}
free_irq(port->irq, mps_port);
So port->irq is always assigned an irq, and rx_irq & tx_irq are assigned only if !(mps_port->flags & UART_PORT_COMBINED_IRQ).
Yep, patch looks good. Thanks for fixing a real bug here, Nathan.
Quoted 23 lines
Fixes 775ea4ea2fd9 ("serial: mps2-uart: support combined irq")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/tty/serial/mps2-uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/tty/serial/mps2-uart.c +1
-2@@ -348,7 +348,7 @@ static void mps2_uart_shutdown(struct uart_port *port)mps2_uart_write8 (port, control, UARTn_CTRL); -if (!mps_port->flags &UART_PORT_COMBINED_IRQ ) { +if (!(mps_port->flags &UART_PORT_COMBINED_IRQ )) {free_irq (mps_port->rx_irq, mps_port);free_irq (mps_port->tx_irq, mps_port); } --2.20.1
Signature · 2 lines
Thanks, ~Nick Desaulniers