lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1519324923-196857-2-git-send-email-john.garry@huawei.com>
Date:   Fri, 23 Feb 2018 02:42:02 +0800
From:   John Garry <john.garry@...wei.com>
To:     <andriy.shevchenko@...ux.intel.com>, <gregkh@...uxfoundation.org>,
        <slaby@...e.com>, <p.zabel@...gutronix.de>, <heiko@...ech.de>,
        <ed.blake@...drel.com>, <jhogan@...nel.org>
CC:     <linux-serial@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <linuxarm@...wei.com>
Subject: [RFC PATCH 1/2] serial: 8250_dw: add IO space support

The current 8250_dw driver only supports MEM iotype. It is desired
to have a platform device-based 8250 UART driver for ACPI FW
with IO port iotype, so update the driver to support this.

Note: a solution needs to be found for autconfig
using MEM accessors only.

Signed-off-by: John Garry <john.garry@...wei.com>
---
 drivers/tty/serial/8250/8250_dw.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index cd1b94a..28fbc8f 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -405,7 +405,7 @@ static void dw8250_setup_port(struct uart_port *p)
 static int dw8250_probe(struct platform_device *pdev)
 {
 	struct uart_8250_port uart = {};
-	struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	struct resource *regs;
 	int irq = platform_get_irq(pdev, 0);
 	struct uart_port *p = &uart.port;
 	struct device *dev = &pdev->dev;
@@ -413,6 +413,9 @@ static int dw8250_probe(struct platform_device *pdev)
 	int err;
 	u32 val;
 
+	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0) ?:
+	       platform_get_resource(pdev, IORESOURCE_IO, 0);
+
 	if (!regs) {
 		dev_err(dev, "no registers defined\n");
 		return -EINVAL;
@@ -425,22 +428,28 @@ static int dw8250_probe(struct platform_device *pdev)
 	}
 
 	spin_lock_init(&p->lock);
-	p->mapbase	= regs->start;
 	p->irq		= irq;
 	p->handle_irq	= dw8250_handle_irq;
 	p->pm		= dw8250_do_pm;
 	p->type		= PORT_8250;
 	p->flags	= UPF_SHARE_IRQ | UPF_FIXED_PORT;
 	p->dev		= dev;
-	p->iotype	= UPIO_MEM;
-	p->serial_in	= dw8250_serial_in;
-	p->serial_out	= dw8250_serial_out;
 	p->set_ldisc	= dw8250_set_ldisc;
 	p->set_termios	= dw8250_set_termios;
 
-	p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
-	if (!p->membase)
-		return -ENOMEM;
+	if ((regs->flags & IORESOURCE_TYPE_BITS) == IORESOURCE_MEM) {
+		p->mapbase	= regs->start;
+		p->membase = devm_ioremap(dev, regs->start,
+					  resource_size(regs));
+		if (!p->membase)
+			return -ENOMEM;
+		p->iotype = UPIO_MEM;
+		p->serial_in	= dw8250_serial_in;
+		p->serial_out	= dw8250_serial_out;
+	} else {
+		p->iobase = regs->start;
+		p->iotype = UPIO_PORT;
+	}
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ