@@ -54,11 +54,8 @@
} \
} while(0)
-#define mwrite(dat, addr) writel((dat), addr)
-#define mread(addr) readl(addr)
-
-#define mmwrite(dat, addr) mwrite((dat), (mantis->mmio + (addr)))
-#define mmread(addr) mread(mantis->mmio + (addr))
+#define mmwrite(dat, addr) writel((dat), (mantis->mmio + (addr)))
+#define mmread(addr) readl(mantis->mmio + (addr))
#define MANTIS_TS_188 0
#define MANTIS_TS_204 1
@@ -91,7 +91,7 @@ static void mantis_uart_read(struct mantis_pci *mantis)
static void mantis_uart_work(struct work_struct *work)
{
struct mantis_pci *mantis = container_of(work, struct mantis_pci, uart_work);
- u32 stat;
+ int stat;
stat = mmread(MANTIS_UART_STAT);
@@ -102,7 +102,7 @@ static void mantis_uart_work(struct work_struct *work)
* MANTIS_UART_RXFIFO_DATA is only set if at least
* config->bytes + 1 bytes are in the FIFO.
*/
- while (stat & MANTIS_UART_RXFIFO_DATA) {
+ while ((stat >= 0) && (stat & MANTIS_UART_RXFIFO_DATA)) {
mantis_uart_read(mantis);
stat = mmread(MANTIS_UART_STAT);
}
As warned by smatch: drivers/media/pci/mantis/mantis_uart.c:105 mantis_uart_work() warn: this loop depends on readl() succeeding If readl() fails, this could lead into an endless loop. Avoid that. We might instead add some timeout logic, but it readl() is failing, then something really wrong is happening. While here, remove two defines that are only used once. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com> --- drivers/media/pci/mantis/mantis_common.h | 7 ++----- drivers/media/pci/mantis/mantis_uart.c | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-)