Skip to content

Commit d22cf13

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
serial: ce4100: clean up serial_in/out() hooks
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)" <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: [email protected] Cc: "H. Peter Anvin" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f565594 commit d22cf13

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

arch/x86/platform/ce4100/ce4100.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,32 @@ static u32 ce4100_mem_serial_in(struct uart_port *p, unsigned int offset)
5353
{
5454
u32 ret, ier, lsr;
5555

56-
if (offset == UART_IIR) {
57-
offset = offset << p->regshift;
58-
ret = readl(p->membase + offset);
59-
if (ret & UART_IIR_NO_INT) {
60-
/* see if the TX interrupt should have really set */
61-
ier = mem_serial_in(p, UART_IER);
62-
/* see if the UART's XMIT interrupt is enabled */
63-
if (ier & UART_IER_THRI) {
64-
lsr = mem_serial_in(p, UART_LSR);
65-
/* now check to see if the UART should be
66-
generating an interrupt (but isn't) */
67-
if (lsr & (UART_LSR_THRE | UART_LSR_TEMT))
68-
ret &= ~UART_IIR_NO_INT;
69-
}
70-
}
71-
} else
72-
ret = mem_serial_in(p, offset);
56+
if (offset != UART_IIR)
57+
return mem_serial_in(p, offset);
58+
59+
offset <<= p->regshift;
60+
61+
ret = readl(p->membase + offset);
62+
if (!(ret & UART_IIR_NO_INT))
63+
return ret;
64+
65+
/* see if the TX interrupt should have really set */
66+
ier = mem_serial_in(p, UART_IER);
67+
/* see if the UART's XMIT interrupt is enabled */
68+
if (!(ier & UART_IER_THRI))
69+
return ret;
70+
71+
lsr = mem_serial_in(p, UART_LSR);
72+
/* now check to see if the UART should be generating an interrupt (but isn't) */
73+
if (lsr & (UART_LSR_THRE | UART_LSR_TEMT))
74+
ret &= ~UART_IIR_NO_INT;
75+
7376
return ret;
7477
}
7578

7679
static void ce4100_mem_serial_out(struct uart_port *p, unsigned int offset, u32 value)
7780
{
78-
offset = offset << p->regshift;
81+
offset <<= p->regshift;
7982
writel(value, p->membase + offset);
8083
}
8184

0 commit comments

Comments
 (0)