* [PATCH] serial: mps2-uart: Add parentheses around conditional in mps2_uart_shutdown
@ 2019-01-31 18:06 Nathan Chancellor
2019-01-31 18:11 ` Vladimir Murzin
2019-01-31 18:21 ` Nick Desaulniers
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2019-01-31 18:06 UTC (permalink / raw)
To: Greg Kroah-Hartman, Vladimir Murzin
Cc: Lorenzo Pieralisi, Nick Desaulniers, Jiri Slaby, Liviu Dudau,
linux-kernel, linux-serial, Sudeep Holla, Nathan Chancellor,
linux-arm-kernel
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 <natechancellor@gmail.com>
---
drivers/tty/serial/mps2-uart.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
index 4404eb7d118f..587b42f754cb 100644
--- a/drivers/tty/serial/mps2-uart.c
+++ b/drivers/tty/serial/mps2-uart.c
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] serial: mps2-uart: Add parentheses around conditional in mps2_uart_shutdown
2019-01-31 18:06 [PATCH] serial: mps2-uart: Add parentheses around conditional in mps2_uart_shutdown Nathan Chancellor
@ 2019-01-31 18:11 ` Vladimir Murzin
2019-01-31 18:21 ` Nick Desaulniers
1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Murzin @ 2019-01-31 18:11 UTC (permalink / raw)
To: Nathan Chancellor, Greg Kroah-Hartman
Cc: Jiri Slaby, Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi,
linux-serial, linux-arm-kernel, linux-kernel, Nick Desaulniers
On 1/31/19 6:06 PM, Nathan Chancellor wrote:
> 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 <natechancellor@gmail.com>
> ---
> drivers/tty/serial/mps2-uart.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
> index 4404eb7d118f..587b42f754cb 100644
> --- a/drivers/tty/serial/mps2-uart.c
> +++ b/drivers/tty/serial/mps2-uart.c
> @@ -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);
> }
>
Acked-by: Vladimir Murzin <vladimir.murzin@arm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] serial: mps2-uart: Add parentheses around conditional in mps2_uart_shutdown
2019-01-31 18:06 [PATCH] serial: mps2-uart: Add parentheses around conditional in mps2_uart_shutdown Nathan Chancellor
2019-01-31 18:11 ` Vladimir Murzin
@ 2019-01-31 18:21 ` Nick Desaulniers
1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2019-01-31 18:21 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Greg Kroah-Hartman, Vladimir Murzin, Jiri Slaby, Liviu Dudau,
Sudeep Holla, Lorenzo Pieralisi, linux-serial, Linux ARM, LKML
On Thu, Jan 31, 2019 at 10:06 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> 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.
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.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://github.com/ClangBuiltLinux/linux/issues/344
>
> Fixes: 775ea4ea2fd9 ("serial: mps2-uart: support combined irq")
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/tty/serial/mps2-uart.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
> index 4404eb7d118f..587b42f754cb 100644
> --- a/drivers/tty/serial/mps2-uart.c
> +++ b/drivers/tty/serial/mps2-uart.c
> @@ -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
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-31 18:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-31 18:06 [PATCH] serial: mps2-uart: Add parentheses around conditional in mps2_uart_shutdown Nathan Chancellor
2019-01-31 18:11 ` Vladimir Murzin
2019-01-31 18:21 ` Nick Desaulniers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox