Skip to contentSkip to conversation

serial: 8520_ce4100: Reuse mem_serial_in() in ce4100_mem_serial_in()

PATCH Superseded Andy Shevchenko 2 participants 4 messages Jun 30, 2025 – Jul 1, 2025 TTY layer and serial drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: 8520_ce4100: Reuse mem_serial_in() in ce4100_mem_serial_in()

In one place in ce4100_mem_serial_in() the code may be replaced with mem_serial_in() call. Do it so and collapse two conditionals into one.

---
 drivers/tty/serial/8250/8250_ce4100.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/tty/serial/8250/8250_ce4100.c +2 -7
index 3dd88f372a51..8221b872fd33 100644
@@ -35,13 +35,8 @@ static u32 ce4100_mem_serial_in(struct uart_port *p, unsigned int offset)
 {
 	u32 ret, ier, lsr;
 
-	if (offset != UART_IIR)
-		return mem_serial_in(p, offset);
-
-	offset <<= p->regshift;
-
-	ret = readl(p->membase + offset);
-	if (!(ret & UART_IIR_NO_INT))
+	ret = mem_serial_in(p, offset);
+	if (!(offset == UART_IIR) && (ret & UART_IIR_NO_INT))
 		return ret;
 
 	/* see if the TX interrupt should have really set */
Signature · 1 line
2.47.2
maintainer
#1 lore raw
Quoted 16 lines · Andy Shevchenko

In one place in ce4100_mem_serial_in() the code may be replaced with mem_serial_in() call. Do it so and collapse two conditionals into one.

---
  drivers/tty/serial/8250/8250_ce4100.c | 9 ++-------
  1 file changed, 2 insertions(+), 7 deletions(-)
drivers/tty/serial/8250/8250_ce4100.c +0 -0
index 3dd88f372a51..8221b872fd33 100644
@@ -35,13 +35,8 @@ static u32 ce4100_mem_serial_in(struct uart_port *p, unsigned int offset)
  {
  	u32 ret, ier, lsr;

drivers/tty/serial/8250/8250_ce4100.c static u32 ce4100_mem_serial_in(struct uart_port *p, unsigned int offset) · line 39

Quoted 10 lines
drivers/tty/serial/8250/8250_ce4100.c +2 -7
 
-	if (offset != UART_IIR)
-		return mem_serial_in(p, offset);
-
-	offset <<= p->regshift;
-
-	ret = readl(p->membase + offset);
-	if (!(ret & UART_IIR_NO_INT))
+	ret = mem_serial_in(p, offset);
+	if (!(offset == UART_IIR) && (ret & UART_IIR_NO_INT))

I am in haste, but a misplaced right paren (should be at the end)?

Quoted 3 lines
drivers/tty/serial/8250/8250_ce4100.c +0 -0
  		return ret;
 
  	/* see if the TX interrupt should have really set */
Signature · 2 lines
js
suse labs
#2 lore raw
Quoted 3 lines · Jiri Slaby
Quoted 2 lines · Andy Shevchenko

In one place in ce4100_mem_serial_in() the code may be replaced with mem_serial_in() call. Do it so and collapse two conditionals into one.

...

Quoted 4 lines
Quoted 4 lines

u32 ret, ier, lsr;

drivers/tty/serial/8250/8250_ce4100.c +0 -3
-	if (offset != UART_IIR)
-		return mem_serial_in(p, offset);
-
Quoted 8 lines

drivers/tty/serial/8250/8250_ce4100.c static u32 ce4100_mem_serial_in(struct uart_port *p, unsigned int offset) · line 39

Quoted 6 lines
drivers/tty/serial/8250/8250_ce4100.c +2 -4
-	offset <<= p->regshift;
-
-	ret = readl(p->membase + offset);
-	if (!(ret & UART_IIR_NO_INT))
+	ret = mem_serial_in(p, offset);
+	if (!(offset == UART_IIR) && (ret & UART_IIR_NO_INT))

I am in haste, but a misplaced right paren (should be at the end)?

Ah, good catch! It's probably better in the original form, i.e.

	if ((offset != UART_IIR) || !(ret & UART_IIR_NO_INT))

What do you think?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#3 lore raw
Quoted 20 lines · Andy Shevchenko
Quoted 3 lines · Jiri Slaby
Quoted 2 lines · Andy Shevchenko

In one place in ce4100_mem_serial_in() the code may be replaced with mem_serial_in() call. Do it so and collapse two conditionals into one.

...

Quoted 4 lines
Quoted 4 lines
   	u32 ret, ier, lsr;
drivers/tty/serial/8250/8250_ce4100.c +0 -3
-	if (offset != UART_IIR)
-		return mem_serial_in(p, offset);
-
Quoted 8 lines

drivers/tty/serial/8250/8250_ce4100.c static u32 ce4100_mem_serial_in(struct uart_port *p, unsigned int offset) · line 39

Quoted 6 lines
drivers/tty/serial/8250/8250_ce4100.c +2 -4
-	offset <<= p->regshift;
-
-	ret = readl(p->membase + offset);
-	if (!(ret & UART_IIR_NO_INT))
+	ret = mem_serial_in(p, offset);
+	if (!(offset == UART_IIR) && (ret & UART_IIR_NO_INT))

I am in haste, but a misplaced right paren (should be at the end)?

Quoted 5 lines

Ah, good catch! It's probably better in the original form, i.e.

	if ((offset != UART_IIR) || !(ret & UART_IIR_NO_INT))

What do you think?

Without the parens around the offset check, yes.

Signature · 2 lines
js
suse labs