tty: serial: amba-pl011: replace TIOCMBIT macros by static functions
authorThéo Lebrun <theo.lebrun@bootlin.com>
Thu, 7 Dec 2023 17:56:08 +0000 (18:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Dec 2023 13:24:12 +0000 (14:24 +0100)
commitdc00f0cc5e04490416d4c2164011e39b4a2d29df
tree78edd97a767f4ea27308854c424937f2afb673ee
parentd93ebe0fcfbd29e2b93850b5f66f98b0d63cce9c
tty: serial: amba-pl011: replace TIOCMBIT macros by static functions

The driver uses two TIOCMBIT macros inside pl011_{get,set}_mctrl to
simplify the logic. Those look scary to checkpatch because they contain
ifs without do-while loops.

Avoid the macros by creating small equivalent static functions; that
lets the compiler do its type checking & avoids checkpatch errors.

For the second instance __assign_bit is not usable because it deals with
unsigned long pointers whereas we have an unsigned int in
pl011_set_mctrl.

This addresses the following checkpatch warnings:

    $ ./scripts/checkpatch.pl --strict --file \
        drivers/tty/serial/amba-pl011.c

    ERROR: Macros starting with if should be enclosed by a do -
           while loop to avoid possible if/else logic defects

    CHECK: Macro argument 'uartbit' may be better as '(uartbit)' to
           avoid precedence issues

    ERROR: Macros starting with if should be enclosed by a do - while
           loop to avoid possible if/else logic defects

    CHECK: Macro argument 'tiocmbit' may be better as '(tiocmbit)' to
           avoid precedence issues

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20231207-mbly-uart-v6-3-e384afa5e78c@bootlin.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/amba-pl011.c