[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180805232651.10605-1-afaerber@suse.de>
Date: Mon, 6 Aug 2018 01:26:51 +0200
From: Andreas Färber <afaerber@...e.de>
To: linux-serial@...r.kernel.org, Rob Herring <robh@...nel.org>
Cc: linux-mips@...ux-mips.org, jringle@...dpoint.com,
allsey87@...il.com, Jakub Kicinski <kubakici@...pl>,
Xue Liu <liuxuenetmail@...il.com>,
Andreas Färber <afaerber@...e.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jslaby@...e.com>, linux-kernel@...r.kernel.org
Subject: [RFC] serial: sc16is7xx: Use DT sub-nodes for UART ports
This is to allow using serdev.
Signed-off-by: Andreas Färber <afaerber@...e.de>
---
drivers/tty/serial/sc16is7xx.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 243c96025053..ad7267274f65 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1213,9 +1213,31 @@ static int sc16is7xx_probe(struct device *dev,
SC16IS7XX_IOCONTROL_SRESET_BIT);
for (i = 0; i < devtype->nr_uart; ++i) {
+#ifdef CONFIG_OF
+ struct device_node *np;
+ struct platform_device *pdev;
+ char name[6] = "uartx";
+#endif
+
s->p[i].line = i;
/* Initialize port data */
+#ifdef CONFIG_OF
+ name[4] = '0' + i;
+ np = of_get_child_by_name(dev->of_node, name);
+ if (IS_ERR(np)) {
+ ret = PTR_ERR(np);
+ goto out_ports;
+ }
+ pdev = of_platform_device_create(np, NULL, dev);
+ if (IS_ERR(pdev)) {
+ ret = PTR_ERR(pdev);
+ goto out_ports;
+ }
+ platform_set_drvdata(pdev, dev_get_drvdata(dev));
+ s->p[i].port.dev = &pdev->dev;
+#else
s->p[i].port.dev = dev;
+#endif
s->p[i].port.irq = irq;
s->p[i].port.type = PORT_SC16IS7XX;
s->p[i].port.fifosize = SC16IS7XX_FIFO_SIZE;
@@ -1271,6 +1293,9 @@ static int sc16is7xx_probe(struct device *dev,
for (i--; i >= 0; i--) {
uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port);
clear_bit(s->p[i].port.line, &sc16is7xx_lines);
+#ifdef CONFIG_OF
+ of_platform_device_destroy(s->p[i].port.dev, NULL);
+#endif
}
#ifdef CONFIG_GPIOLIB
--
2.16.4
Powered by blists - more mailing lists