Skip to contentSkip to conversation

UPIO_TSI cleanup

PATCH In review Al Viro 2 participants 2 messages Sep 23, 2006 – Sep 24, 2006

lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 1/1 UPIO_TSI cleanup

(le32_to_cpu(x) >> 8) & 0xff is a very odd way to spell (x >> 16) & 0xff, even if that code is hit only on ppc. The value is host-endian - we've got it from readl(), after all...

---
 drivers/serial/8250.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/serial/8250.c +2 -2
index 0ae9ced..10c2daa 100644
@@ -320,8 +320,8 @@ #endif
 
 	case UPIO_TSI:
 		if (offset == UART_IIR) {
-			tmp = readl((u32 *)(up->port.membase + UART_RX));
-			return (cpu_to_le32(tmp) >> 8) & 0xff;
+			tmp = readl(up->port.membase + (UART_IIR & ~3));
+			return (tmp >> 16) & 0xff; /* UART_IIR % 4 == 2 */
 		} else
 			return readb(up->port.membase + offset);
 
Signature · 1 line
1.4.2.GIT
#1 lore raw

Hello.

drivers/serial/8250.c

Quoted 13 lines · Al Viro

(le32_to_cpu(x) >> 8) & 0xff is a very odd way to spell (x >> 16) & 0xff, even if that code is hit only on ppc. The value is host-endian - we've got it from readl(), after all...

---
 drivers/serial/8250.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/serial/8250.c +0 -0
index 0ae9ced..10c2daa 100644

Shouldn't this go to [email protected] instead?

drivers/serial/8250.c #endif · line 327

Quoted 11 lines
drivers/serial/8250.c +2 -2
@@ -320,8 +320,8 @@ #endif
 
 	case UPIO_TSI:
 		if (offset == UART_IIR) {
-			tmp = readl((u32 *)(up->port.membase + UART_RX));
-			return (cpu_to_le32(tmp) >> 8) & 0xff;
+			tmp = readl(up->port.membase + (UART_IIR & ~3));
+			return (tmp >> 16) & 0xff; /* UART_IIR % 4 == 2 */
 		} else
 			return readb(up->port.membase + offset);
 

I'd also like to suggest actually writing to IER in the serial_out() even
if the UUE bit is set, jusk mask 2 MSBs off (Xscale UART detection code which breaks Tsi10x UART sould have been CONFIG_ARM dependent I think). The whole UPIO_TSI thing looks much like an abuse to me, however it still seems to be a necessary evil... :-/

WBR, Sergei