Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

serial: ucc_uart: Fix multiple address space type errors

sparse reports multiple problems with address space type.

Most problems are linked to missing __iomem qualifier.

Others are caused by dereferencing __iomem addresses.

Fix all this by adding missing __iomem and using ioread32be().

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202312050412.zN2PKArS-lkp@intel.com/
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/e49deeb079391ff7273ec32f5563df94cf70bc95.1701781976.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Christophe Leroy and committed by
Greg Kroah-Hartman
1e7e5616 0ec058ec

+14 -14
+14 -14
drivers/tty/serial/ucc_uart.c
··· 189 189 u16 tx_fifosize; 190 190 int wait_closing; 191 191 u32 flags; 192 - struct qe_bd *rx_bd_base; 193 - struct qe_bd *rx_cur; 194 - struct qe_bd *tx_bd_base; 195 - struct qe_bd *tx_cur; 192 + struct qe_bd __iomem *rx_bd_base; 193 + struct qe_bd __iomem *rx_cur; 194 + struct qe_bd __iomem *tx_bd_base; 195 + struct qe_bd __iomem *tx_cur; 196 196 unsigned char *tx_buf; 197 197 unsigned char *rx_buf; 198 198 void *bd_virt; /* virtual address of the BD buffers */ ··· 258 258 { 259 259 struct uart_qe_port *qe_port = 260 260 container_of(port, struct uart_qe_port, port); 261 - struct qe_bd *bdp = qe_port->tx_bd_base; 261 + struct qe_bd __iomem *bdp = qe_port->tx_bd_base; 262 262 263 263 while (1) { 264 264 if (ioread16be(&bdp->status) & BD_SC_READY) ··· 330 330 */ 331 331 static int qe_uart_tx_pump(struct uart_qe_port *qe_port) 332 332 { 333 - struct qe_bd *bdp; 333 + struct qe_bd __iomem *bdp; 334 334 unsigned char *p; 335 335 unsigned int count; 336 336 struct uart_port *port = &qe_port->port; ··· 341 341 /* Pick next descriptor and fill from buffer */ 342 342 bdp = qe_port->tx_cur; 343 343 344 - p = qe2cpu_addr(be32_to_cpu(bdp->buf), qe_port); 344 + p = qe2cpu_addr(ioread32be(&bdp->buf), qe_port); 345 345 346 346 *p++ = port->x_char; 347 347 iowrite16be(1, &bdp->length); ··· 368 368 369 369 while (!(ioread16be(&bdp->status) & BD_SC_READY) && !uart_circ_empty(xmit)) { 370 370 count = 0; 371 - p = qe2cpu_addr(be32_to_cpu(bdp->buf), qe_port); 371 + p = qe2cpu_addr(ioread32be(&bdp->buf), qe_port); 372 372 while (count < qe_port->tx_fifosize) { 373 373 *p++ = xmit->buf[xmit->tail]; 374 374 uart_xmit_advance(port, 1); ··· 460 460 unsigned char ch, *cp; 461 461 struct uart_port *port = &qe_port->port; 462 462 struct tty_port *tport = &port->state->port; 463 - struct qe_bd *bdp; 463 + struct qe_bd __iomem *bdp; 464 464 u16 status; 465 465 unsigned int flg; 466 466 ··· 487 487 } 488 488 489 489 /* get pointer */ 490 - cp = qe2cpu_addr(be32_to_cpu(bdp->buf), qe_port); 490 + cp = qe2cpu_addr(ioread32be(&bdp->buf), qe_port); 491 491 492 492 /* loop through the buffer */ 493 493 while (i-- > 0) { ··· 590 590 { 591 591 int i; 592 592 void *bd_virt; 593 - struct qe_bd *bdp; 593 + struct qe_bd __iomem *bdp; 594 594 595 595 /* Set the physical address of the host memory buffers in the buffer 596 596 * descriptors, and the virtual address for us to work with. ··· 648 648 { 649 649 u32 cecr_subblock; 650 650 struct ucc_slow __iomem *uccp = qe_port->uccp; 651 - struct ucc_uart_pram *uccup = qe_port->uccup; 651 + struct ucc_uart_pram __iomem *uccup = qe_port->uccup; 652 652 653 653 unsigned int i; 654 654 ··· 983 983 984 984 qe_port->us_private = uccs; 985 985 qe_port->uccp = uccs->us_regs; 986 - qe_port->uccup = (struct ucc_uart_pram *) uccs->us_pram; 986 + qe_port->uccup = (struct ucc_uart_pram __iomem *)uccs->us_pram; 987 987 qe_port->rx_bd_base = uccs->rx_bd; 988 988 qe_port->tx_bd_base = uccs->tx_bd; 989 989 ··· 1156 1156 1157 1157 firmware = (struct qe_firmware *) fw->data; 1158 1158 1159 - if (firmware->header.length != fw->size) { 1159 + if (be32_to_cpu(firmware->header.length) != fw->size) { 1160 1160 dev_err(dev, "invalid firmware\n"); 1161 1161 goto out; 1162 1162 }