]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
serial: ce4100: clean up serial_in/out() hooks
authorJiri Slaby (SUSE) <jirislaby@kernel.org>
Mon, 23 Jun 2025 10:12:46 +0000 (12:12 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Jun 2025 14:32:50 +0000 (15:32 +0100)
ce4100_mem_serial_in() unnecessarily contains 4 nested 'if's. That makes
the code hard to follow. Invert the conditions and return early if the
particular conditions do not hold.

And use "<<=" for shifting the offset in both of the hooks.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/r/20250623101246.486866-2-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/platform/ce4100/ce4100.c

index f19d20f0dfa463593e4edca49c7d34effc3034fd..08492bea9713224d0eb949fc6c8003d1716c7b47 100644 (file)
@@ -53,29 +53,32 @@ static u32 ce4100_mem_serial_in(struct uart_port *p, unsigned int offset)
 {
        u32 ret, ier, lsr;
 
-       if (offset == UART_IIR) {
-               offset = offset << p->regshift;
-               ret = readl(p->membase + offset);
-               if (ret & UART_IIR_NO_INT) {
-                       /* see if the TX interrupt should have really set */
-                       ier = mem_serial_in(p, UART_IER);
-                       /* see if the UART's XMIT interrupt is enabled */
-                       if (ier & UART_IER_THRI) {
-                               lsr = mem_serial_in(p, UART_LSR);
-                               /* now check to see if the UART should be
-                                  generating an interrupt (but isn't) */
-                               if (lsr & (UART_LSR_THRE | UART_LSR_TEMT))
-                                       ret &= ~UART_IIR_NO_INT;
-                       }
-               }
-       } else
-               ret =  mem_serial_in(p, offset);
+       if (offset != UART_IIR)
+               return mem_serial_in(p, offset);
+
+       offset <<= p->regshift;
+
+       ret = readl(p->membase + offset);
+       if (!(ret & UART_IIR_NO_INT))
+               return ret;
+
+       /* see if the TX interrupt should have really set */
+       ier = mem_serial_in(p, UART_IER);
+       /* see if the UART's XMIT interrupt is enabled */
+       if (!(ier & UART_IER_THRI))
+               return ret;
+
+       lsr = mem_serial_in(p, UART_LSR);
+       /* now check to see if the UART should be generating an interrupt (but isn't) */
+       if (lsr & (UART_LSR_THRE | UART_LSR_TEMT))
+               ret &= ~UART_IIR_NO_INT;
+
        return ret;
 }
 
 static void ce4100_mem_serial_out(struct uart_port *p, unsigned int offset, u32 value)
 {
-       offset = offset << p->regshift;
+       offset <<= p->regshift;
        writel(value, p->membase + offset);
 }