Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1311057

[PATCH v5 09/11] serial: 8250_early: Use port->regshift

From Peter Hurley <peter@hurleysoftware.com>
Newsgroups linux.kernel
Subject [PATCH v5 09/11] serial: 8250_early: Use port->regshift
Date 2016-01-16 22:50 +0100
Message-ID <qRGTo-1Ej-21@gated-at.bofh.it> (permalink)
References <qQd74-5xe-7@gated-at.bofh.it> <qRGJI-1Au-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


earlycon initializes struct uart_port::regshift to the correct
value for UPIO_MEM32 already. Use the port field rather than
hard-coded value.

This enables broader support for various i/o access methods in
8250 earlycon (eg., omap8250 earlycon).

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/8250/8250_early.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index af62131..180143c 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -39,15 +39,17 @@
 
 static unsigned int __init serial8250_early_in(struct uart_port *port, int offset)
 {
+	offset <<= port->regshift;
+
 	switch (port->iotype) {
 	case UPIO_MEM:
 		return readb(port->membase + offset);
 	case UPIO_MEM16:
-		return readw(port->membase + (offset << 1));
+		return readw(port->membase + offset);
 	case UPIO_MEM32:
-		return readl(port->membase + (offset << 2));
+		return readl(port->membase + offset);
 	case UPIO_MEM32BE:
-		return ioread32be(port->membase + (offset << 2));
+		return ioread32be(port->membase + offset);
 	case UPIO_PORT:
 		return inb(port->iobase + offset);
 	default:
@@ -57,18 +59,20 @@ static unsigned int __init serial8250_early_in(struct uart_port *port, int offse
 
 static void __init serial8250_early_out(struct uart_port *port, int offset, int value)
 {
+	offset <<= port->regshift;
+
 	switch (port->iotype) {
 	case UPIO_MEM:
 		writeb(value, port->membase + offset);
 		break;
 	case UPIO_MEM16:
-		writew(value, port->membase + (offset << 1));
+		writew(value, port->membase + offset);
 		break;
 	case UPIO_MEM32:
-		writel(value, port->membase + (offset << 2));
+		writel(value, port->membase + offset);
 		break;
 	case UPIO_MEM32BE:
-		iowrite32be(value, port->membase + (offset << 2));
+		iowrite32be(value, port->membase + offset);
 		break;
 	case UPIO_PORT:
 		outb(value, port->iobase + offset);
-- 
2.7.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v5 00/11] Earlycon cleanup Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:40 +0100
  [PATCH v5 11/11] serial: 8250_omap: Add omap8250 earlycon Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:40 +0100
  [PATCH v5 06/11] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:40 +0100
    Re: [PATCH v5 06/11] of: earlycon: Move address translation to  of_setup_earlycon() kbuild test robot <lkp@intel.com> - 2016-01-16 23:10 +0100
  [PATCH v5 07/11] serial: earlycon: Common log banner for command line and DT Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:40 +0100
  [PATCH v5 01/11] earlycon: Use common framework for earlycon declarations Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v5 05/11] of: earlycon: Initialize port fields from DT properties Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
    Re: [PATCH v5 05/11] of: earlycon: Initialize port fields from DT  properties kbuild test robot <lkp@intel.com> - 2016-01-16 23:00 +0100
  [PATCH v5 02/11] serial: earlycon: Fixup earlycon console name and index Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v5 03/11] of: earlycon: Fixup earlycon console name and index Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v5 04/11] of: earlycon: Add options string handling Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v5 09/11] serial: 8250_early: Use port->regshift Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v5 08/11] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v5 10/11] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v6 11/12] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
  [PATCH v6 05/12] of: earlycon: Add options string handling Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
  [PATCH v6 04/12] of: earlycon: Fixup earlycon console name and index Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
  [PATCH v6 09/12] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
  [PATCH v6 00/12] Earlycon cleanup Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 02/12] earlycon: Use common framework for earlycon declarations Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 10/12] serial: 8250_early: Use port->regshift Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 07/12] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 01/12] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 03/12] serial: earlycon: Fixup earlycon console name and index Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 08/12] serial: earlycon: Common log banner for command line and DT Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 06/12] of: earlycon: Initialize port fields from DT properties Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 12/12] serial: 8250_omap: Add omap8250 earlycon Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100

csiph-web