serial: drivers: switch ch and flag to u8
authorJiri Slaby <jirislaby@kernel.org>
Wed, 12 Jul 2023 08:18:11 +0000 (10:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Jul 2023 17:21:04 +0000 (19:21 +0200)
Now that the serial layer explicitly expects 'u8' for flags and
characters, propagate this type to drivers' (RX) routines.

Note that amba-pl011's, clps711x's and st-asc's 'ch' are left unchanged
because 'ch' contains not only a character, but whole status.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Tobias Klauser <tklauser@distanz.ch>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: Richard Genoud <richard.genoud@gmail.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Claudiu Beznea <claudiu.beznea@microchip.com>
Cc: Alexander Shiyan <shc_work@mail.ru>
Cc: Baruch Siach <baruch@tkos.co.il>
Cc: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Taichi Sugaya <sugaya.taichi@socionext.com>
Cc: Takao Orito <orito.takao@socionext.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Kevin Cernekee <cernekee@gmail.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Laxman Dewangan <ldewangan@nvidia.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Orson Zhai <orsonzhai@gmail.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Chunyan Zhang <zhang.lyra@gmail.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Hammer Hsieh <hammerh0314@gmail.com>
Acked-by: Richard GENOUD <richard.genoud@gmail.com>
Acked-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Thierry Reding <treding@nvidia.com>
Acked-by: Maciej W. Rozycki <macro@orcam.me.uk>
Link: https://lore.kernel.org/r/20230712081811.29004-11-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34 files changed:
drivers/tty/serial/21285.c
drivers/tty/serial/8250/8250_port.c
drivers/tty/serial/altera_jtaguart.c
drivers/tty/serial/altera_uart.c
drivers/tty/serial/amba-pl010.c
drivers/tty/serial/amba-pl011.c
drivers/tty/serial/apbuart.c
drivers/tty/serial/arc_uart.c
drivers/tty/serial/atmel_serial.c
drivers/tty/serial/clps711x.c
drivers/tty/serial/digicolor-usart.c
drivers/tty/serial/dz.c
drivers/tty/serial/ip22zilog.c
drivers/tty/serial/max3100.c
drivers/tty/serial/max310x.c
drivers/tty/serial/mcf.c
drivers/tty/serial/milbeaut_usio.c
drivers/tty/serial/mxs-auart.c
drivers/tty/serial/omap-serial.c
drivers/tty/serial/pxa.c
drivers/tty/serial/rp2.c
drivers/tty/serial/sa1100.c
drivers/tty/serial/samsung_tty.c
drivers/tty/serial/sb1250-duart.c
drivers/tty/serial/sc16is7xx.c
drivers/tty/serial/sccnxp.c
drivers/tty/serial/serial-tegra.c
drivers/tty/serial/serial_txx9.c
drivers/tty/serial/sifive.c
drivers/tty/serial/sprd_serial.c
drivers/tty/serial/st-asc.c
drivers/tty/serial/stm32-usart.c
drivers/tty/serial/sunplus-uart.c
drivers/tty/serial/zs.c

index 185462f..d756fcc 100644 (file)
@@ -117,7 +117,8 @@ static void serial21285_stop_rx(struct uart_port *port)
 static irqreturn_t serial21285_rx_chars(int irq, void *dev_id)
 {
        struct uart_port *port = dev_id;
-       unsigned int status, ch, flag, rxs, max_count = 256;
+       unsigned int status, rxs, max_count = 256;
+       u8 ch, flag;
 
        status = *CSR_UARTFLG;
        while (!(status & 0x10) && max_count--) {
index 16aeb14..0533e75 100644 (file)
@@ -1706,8 +1706,7 @@ static void serial8250_enable_ms(struct uart_port *port)
 void serial8250_read_char(struct uart_8250_port *up, u16 lsr)
 {
        struct uart_port *port = &up->port;
-       unsigned char ch;
-       char flag = TTY_NORMAL;
+       u8 ch, flag = TTY_NORMAL;
 
        if (likely(lsr & UART_LSR_DR))
                ch = serial_in(up, UART_RX);
index 9f843d1..6203ca1 100644 (file)
@@ -110,8 +110,8 @@ static void altera_jtaguart_set_termios(struct uart_port *port,
 
 static void altera_jtaguart_rx_chars(struct uart_port *port)
 {
-       unsigned char ch;
        unsigned long status;
+       u8 ch;
 
        while ((status = readl(port->membase + ALTERA_JTAGUART_DATA_REG)) &
               ALTERA_JTAGUART_DATA_RVALID_MSK) {
index 9ce3d24..a9c4194 100644 (file)
@@ -201,8 +201,8 @@ static void altera_uart_set_termios(struct uart_port *port,
 
 static void altera_uart_rx_chars(struct uart_port *port)
 {
-       unsigned char ch, flag;
        unsigned short status;
+       u8 ch, flag;
 
        while ((status = altera_uart_readl(port, ALTERA_UART_STATUS_REG)) &
               ALTERA_UART_STATUS_RRDY_MSK) {
index a98fae2..b5a7404 100644 (file)
@@ -112,7 +112,8 @@ static void pl010_enable_ms(struct uart_port *port)
 
 static void pl010_rx_chars(struct uart_port *port)
 {
-       unsigned int status, ch, flag, rsr, max_count = 256;
+       unsigned int status, rsr, max_count = 256;
+       u8 ch, flag;
 
        status = readb(port->membase + UART01x_FR);
        while (UART_RX_DATA(status) && max_count--) {
index c5c3f46..8bddc74 100644 (file)
@@ -307,9 +307,10 @@ static void pl011_write(unsigned int val, const struct uart_amba_port *uap,
  */
 static int pl011_fifo_to_tty(struct uart_amba_port *uap)
 {
-       unsigned int ch, flag, fifotaken;
+       unsigned int ch, fifotaken;
        int sysrq;
        u16 status;
+       u8 flag;
 
        for (fifotaken = 0; fifotaken != 256; fifotaken++) {
                status = pl011_read(uap, REG_FR);
index 915ee4b..372db05 100644 (file)
@@ -70,8 +70,9 @@ static void apbuart_stop_rx(struct uart_port *port)
 
 static void apbuart_rx_chars(struct uart_port *port)
 {
-       unsigned int status, ch, rsr, flag;
+       unsigned int status, rsr;
        unsigned int max_chars = port->fifosize;
+       u8 ch, flag;
 
        status = UART_GET_STATUS(port);
 
index 8359034..ad4ae19 100644 (file)
@@ -205,7 +205,7 @@ static void arc_serial_rx_chars(struct uart_port *port, unsigned int status)
         * controller, which is indeed the Rx-FIFO.
         */
        do {
-               unsigned int ch, flg = TTY_NORMAL;
+               u8 ch, flg = TTY_NORMAL;
 
                /*
                 * This could be an Rx Intr for err (no data),
index 3467a87..ec54436 100644 (file)
@@ -1516,8 +1516,8 @@ static void atmel_rx_from_ring(struct uart_port *port)
 {
        struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
        struct circ_buf *ring = &atmel_port->rx_ring;
-       unsigned int flg;
        unsigned int status;
+       u8 flg;
 
        while (ring->head != ring->tail) {
                struct atmel_uart_char c;
index e49bc40..be8b878 100644 (file)
@@ -92,8 +92,9 @@ static irqreturn_t uart_clps711x_int_rx(int irq, void *dev_id)
 {
        struct uart_port *port = dev_id;
        struct clps711x_port *s = dev_get_drvdata(port->dev);
-       unsigned int status, flg;
+       unsigned int status;
        u16 ch;
+       u8 flg;
 
        for (;;) {
                u32 sysflg = 0;
index ed19770..128b547 100644 (file)
@@ -136,8 +136,7 @@ static void digicolor_uart_rx(struct uart_port *port)
        spin_lock_irqsave(&port->lock, flags);
 
        while (1) {
-               u8 status, ch;
-               unsigned int ch_flag;
+               u8 status, ch, ch_flag;
 
                if (digicolor_uart_rx_empty(port))
                        break;
index 6b7ed7f..667f52e 100644 (file)
@@ -181,8 +181,8 @@ static inline void dz_receive_chars(struct dz_mux *mux)
        struct dz_port *dport = &mux->dport[0];
        struct uart_icount *icount;
        int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 };
-       unsigned char ch, flag;
        u16 status;
+       u8 ch, flag;
        int i;
 
        while ((status = dz_in(dport, DZ_RBUF)) & DZ_DVAL) {
index b1f27e1..845ff70 100644 (file)
@@ -248,8 +248,8 @@ static void ip22zilog_maybe_update_regs(struct uart_ip22zilog_port *up,
 static bool ip22zilog_receive_chars(struct uart_ip22zilog_port *up,
                                                  struct zilog_channel *channel)
 {
-       unsigned char ch, flag;
        unsigned int r1;
+       u8 ch, flag;
        bool push = up->port.state != NULL;
 
        for (;;) {
index 86dcbff..5efb2b5 100644 (file)
@@ -215,8 +215,9 @@ static int max3100_sr(struct max3100_port *s, u16 tx, u16 *rx)
 
 static int max3100_handlerx(struct max3100_port *s, u16 rx)
 {
-       unsigned int ch, flg, status = 0;
+       unsigned int status = 0;
        int ret = 0, cts;
+       u8 ch, flg;
 
        if (rx & MAX3100_R && s->rx_enabled) {
                dev_dbg(&s->spi->dev, "%s\n", __func__);
index 997e394..416d553 100644 (file)
@@ -669,7 +669,8 @@ static void max310x_batch_read(struct uart_port *port, u8 *rxbuf, unsigned int l
 static void max310x_handle_rx(struct uart_port *port, unsigned int rxlen)
 {
        struct max310x_one *one = to_max310x_port(port);
-       unsigned int sts, ch, flag, i;
+       unsigned int sts, i;
+       u8 ch, flag;
 
        if (port->read_status_mask == MAX310X_LSR_RXOVR_BIT) {
                /* We are just reading, happily ignoring any error conditions.
index 3239bab..1666ce0 100644 (file)
@@ -281,7 +281,7 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios,
 static void mcf_rx_chars(struct mcf_uart *pp)
 {
        struct uart_port *port = &pp->port;
-       unsigned char status, ch, flag;
+       u8 status, ch, flag;
 
        while ((status = readb(port->membase + MCFUART_USR)) & MCFUART_USR_RXREADY) {
                ch = readb(port->membase + MCFUART_URB);
index 44988a2..70a9100 100644 (file)
@@ -148,8 +148,7 @@ static void mlb_usio_enable_ms(struct uart_port *port)
 static void mlb_usio_rx_chars(struct uart_port *port)
 {
        struct tty_port *ttyport = &port->state->port;
-       unsigned long flag = 0;
-       char ch = 0;
+       u8 flag = 0, ch = 0;
        u8 status;
        int max_count = 2;
 
index a368f42..2ef1099 100644 (file)
@@ -616,9 +616,8 @@ static void mxs_auart_tx_chars(struct mxs_auart_port *s)
 
 static void mxs_auart_rx_char(struct mxs_auart_port *s)
 {
-       int flag;
        u32 stat;
-       u8 c;
+       u8 c, flag;
 
        c = mxs_read(s, REG_DATA);
        stat = mxs_read(s, REG_STAT);
index 16ab7ea..2c11870 100644 (file)
@@ -442,7 +442,7 @@ static unsigned int check_modem_status(struct uart_omap_port *up)
 
 static void serial_omap_rlsi(struct uart_omap_port *up, unsigned int lsr)
 {
-       unsigned int flag;
+       u8 flag;
 
        /*
         * Read one data character out to avoid stalling the receiver according
@@ -498,7 +498,7 @@ static void serial_omap_rlsi(struct uart_omap_port *up, unsigned int lsr)
 
 static void serial_omap_rdi(struct uart_omap_port *up, unsigned int lsr)
 {
-       unsigned char ch = 0;
+       u8 ch;
 
        if (!(lsr & UART_LSR_DR))
                return;
index 444fa4b..73c60f5 100644 (file)
@@ -90,7 +90,7 @@ static void serial_pxa_stop_rx(struct uart_port *port)
 
 static inline void receive_chars(struct uart_pxa_port *up, int *status)
 {
-       unsigned int ch, flag;
+       u8 ch, flag;
        int max_count = 256;
 
        do {
index 749b873..de220ac 100644 (file)
@@ -401,14 +401,14 @@ static void rp2_rx_chars(struct rp2_uart_port *up)
 
        for (; bytes != 0; bytes--) {
                u32 byte = readw(up->base + RP2_DATA_BYTE) | RP2_DUMMY_READ;
-               char ch = byte & 0xff;
+               u8 ch = byte & 0xff;
 
                if (likely(!(byte & RP2_DATA_BYTE_EXCEPTION_MASK))) {
                        if (!uart_handle_sysrq_char(&up->port, ch))
                                uart_insert_char(&up->port, byte, 0, ch,
                                                 TTY_NORMAL);
                } else {
-                       char flag = TTY_NORMAL;
+                       u8 flag = TTY_NORMAL;
 
                        if (byte & RP2_DATA_BYTE_BREAK_m)
                                flag = TTY_BREAK;
index 55107bb..ad011f1 100644 (file)
@@ -180,7 +180,8 @@ static void sa1100_enable_ms(struct uart_port *port)
 static void
 sa1100_rx_chars(struct sa1100_port *sport)
 {
-       unsigned int status, ch, flg;
+       unsigned int status;
+       u8 ch, flg;
 
        status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) |
                 UTSR0_TO_SM(UART_GET_UTSR0(sport));
index b29e9df..aa4a184 100644 (file)
@@ -759,9 +759,10 @@ finish:
 static void s3c24xx_serial_rx_drain_fifo(struct s3c24xx_uart_port *ourport)
 {
        struct uart_port *port = &ourport->port;
-       unsigned int ufcon, ch, flag, ufstat, uerstat;
+       unsigned int ufcon, ufstat, uerstat;
        unsigned int fifocnt = 0;
        int max_count = port->fifosize;
+       u8 ch, flag;
 
        while (max_count-- > 0) {
                /*
index b6de0dc..f3cd693 100644 (file)
@@ -331,8 +331,9 @@ static void sbd_receive_chars(struct sbd_port *sport)
 {
        struct uart_port *uport = &sport->port;
        struct uart_icount *icount;
-       unsigned int status, ch, flag;
+       unsigned int status;
        int count;
+       u8 ch, flag;
 
        for (count = 16; count; count--) {
                status = read_sbdchn(sport, R_DUART_STATUS);
index 2e7e7c4..cfffc73 100644 (file)
@@ -578,8 +578,9 @@ static void sc16is7xx_handle_rx(struct uart_port *port, unsigned int rxlen,
                                unsigned int iir)
 {
        struct sc16is7xx_port *s = dev_get_drvdata(port->dev);
-       unsigned int lsr = 0, ch, flag, bytes_read, i;
+       unsigned int lsr = 0, bytes_read, i;
        bool read_lsr = (iir == SC16IS7XX_IIR_RLSE_SRC) ? true : false;
+       u8 ch, flag;
 
        if (unlikely(rxlen >= sizeof(s->buf))) {
                dev_warn_ratelimited(port->dev,
index 4f2fc5f..31ee46e 100644 (file)
@@ -383,8 +383,7 @@ static void sccnxp_set_bit(struct uart_port *port, int sig, int state)
 
 static void sccnxp_handle_rx(struct uart_port *port)
 {
-       u8 sr;
-       unsigned int ch, flag;
+       u8 sr, ch, flag;
 
        for (;;) {
                sr = sccnxp_port_read(port, SCCNXP_SR_REG);
index 1cf08b3..813ae97 100644 (file)
@@ -434,10 +434,10 @@ static int tegra_set_baudrate(struct tegra_uart_port *tup, unsigned int baud)
        return 0;
 }
 
-static char tegra_uart_decode_rx_error(struct tegra_uart_port *tup,
+static u8 tegra_uart_decode_rx_error(struct tegra_uart_port *tup,
                        unsigned long lsr)
 {
-       char flag = TTY_NORMAL;
+       u8 flag = TTY_NORMAL;
 
        if (unlikely(lsr & TEGRA_UART_LSR_ANY)) {
                if (lsr & UART_LSR_OE) {
@@ -642,9 +642,8 @@ static void tegra_uart_handle_rx_pio(struct tegra_uart_port *tup,
                struct tty_port *port)
 {
        do {
-               char flag = TTY_NORMAL;
                unsigned long lsr = 0;
-               unsigned char ch;
+               u8 ch, flag = TTY_NORMAL;
 
                lsr = tegra_uart_read(tup, UART_LSR);
                if (!(lsr & UART_LSR_DR))
index eab387b..be08fb6 100644 (file)
@@ -246,11 +246,10 @@ static void serial_txx9_initialize(struct uart_port *up)
 static inline void
 receive_chars(struct uart_port *up, unsigned int *status)
 {
-       unsigned char ch;
        unsigned int disr = *status;
        int max_count = 256;
-       char flag;
        unsigned int next_ignore_status_mask;
+       u8 ch, flag;
 
        do {
                ch = sio_in(up, TXX9_SIRFIFO);
index 1f565a2..c00080f 100644 (file)
@@ -402,9 +402,9 @@ static char __ssp_receive_char(struct sifive_serial_port *ssp, char *is_empty)
  */
 static void __ssp_receive_chars(struct sifive_serial_port *ssp)
 {
-       unsigned char ch;
        char is_empty;
        int c;
+       u8 ch;
 
        for (c = SIFIVE_RX_FIFO_DEPTH; c > 0; --c) {
                ch = __ssp_receive_char(ssp, &is_empty);
index b58f512..8f6fd1c 100644 (file)
@@ -558,7 +558,7 @@ static void sprd_break_ctl(struct uart_port *port, int break_state)
 }
 
 static int handle_lsr_errors(struct uart_port *port,
-                            unsigned int *flag,
+                            u8 *flag,
                             unsigned int *lsr)
 {
        int ret = 0;
@@ -594,7 +594,8 @@ static inline void sprd_rx(struct uart_port *port)
        struct sprd_uart_port *sp = container_of(port, struct sprd_uart_port,
                                                 port);
        struct tty_port *tty = &port->state->port;
-       unsigned int ch, flag, lsr, max_count = SPRD_TIMEOUT;
+       unsigned int lsr, max_count = SPRD_TIMEOUT;
+       u8 ch, flag;
 
        if (sp->rx_dma.enable) {
                sprd_uart_dma_irq(port);
index aa471c9..387bc69 100644 (file)
@@ -250,7 +250,7 @@ static void asc_receive_chars(struct uart_port *port)
        struct tty_port *tport = &port->state->port;
        unsigned long status, mode;
        unsigned long c = 0;
-       char flag;
+       u8 flag;
        bool ignore_pe = false;
 
        /*
index e9e11a2..be47cd3 100644 (file)
@@ -321,7 +321,7 @@ static bool stm32_usart_pending_rx_pio(struct uart_port *port, u32 *sr)
        return false;
 }
 
-static unsigned long stm32_usart_get_char_pio(struct uart_port *port)
+static u8 stm32_usart_get_char_pio(struct uart_port *port)
 {
        struct stm32_port *stm32_port = to_stm32_port(port);
        const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
@@ -338,10 +338,9 @@ static unsigned int stm32_usart_receive_chars_pio(struct uart_port *port)
 {
        struct stm32_port *stm32_port = to_stm32_port(port);
        const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
-       unsigned long c;
        unsigned int size = 0;
        u32 sr;
-       char flag;
+       u8 c, flag;
 
        while (stm32_usart_pending_rx_pio(port, &sr)) {
                sr |= USART_SR_DUMMY_RX;
index 727942c..3aacd5e 100644 (file)
@@ -231,7 +231,7 @@ static void transmit_chars(struct uart_port *port)
 static void receive_chars(struct uart_port *port)
 {
        unsigned int lsr = readl(port->membase + SUP_UART_LSR);
-       unsigned int ch, flag;
+       u8 ch, flag;
 
        do {
                ch = readl(port->membase + SUP_UART_DATA);
index 730c648..65ca4da 100644 (file)
@@ -539,8 +539,9 @@ static void zs_receive_chars(struct zs_port *zport)
        struct uart_port *uport = &zport->port;
        struct zs_scc *scc = zport->scc;
        struct uart_icount *icount;
-       unsigned int avail, status, ch, flag;
+       unsigned int avail, status;
        int count;
+       u8 ch, flag;
 
        for (count = 16; count; count--) {
                spin_lock(&scc->zlock);