From patchwork Sun Aug 5 23:26:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 143467 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2665889ljj; Sun, 5 Aug 2018 16:27:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpek5CdpZhfLZ7apo0RoviwQx+BYHyo0YiS1pEKLmeEDVKc2jlRrFqm3qejrhRLhnKOuzp0C X-Received: by 2002:a62:398c:: with SMTP id u12-v6mr14561601pfj.9.1533511626179; Sun, 05 Aug 2018 16:27:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533511626; cv=none; d=google.com; s=arc-20160816; b=kAMAH+2bBtVpBVl8blTC4aXPjsF1QqzZPL7BxIvH2KafwSeqjy3cvimheEBU6IjoPF uhtKyu7DN3MN/7dr5g39V7AXDT39S3tvoWl2jWa7NnT/6em8u986AQweUbMyRmgOGiSt CBZSh0B2NBNnX1OsPnqEhGWpb9Lp5DQPlEjPegjRgjLt4axPDFyE0rEvRlLdL7jCO7/Z +5YNMxvAciajqCqR6UTUon8CwwQXcQTkbM+6voVEeqxEpjWpnAlSegkyPkXWENtnsJzb wr6mSxaYXvt/saa8OqxPFSCsGMjgQ1zaoLlVsEGRCWu2pt0XFxwv/Vvz+XrqWq9C9431 MRUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=I76xhJ3q07vmnty7OP6c3J7ZnPsq4hLerGKCQtub30E=; b=xN57igUbF2KIlxHBCQuwvziTgklJOclHCh8dEliWpxPKoiCje4t3YG9apXp7re1IiD BQ6nP6lHaWtgGwBaIVFCxxQmwC8EnazMwYtVK7zYDHwKgfJDb4qLGfpoMVT+dg8ZNruO GlSilyac0EfDbd+5RiMnrOUpehwv8JG88UbSheEOSVbktw2IouAS4kaSN9nflYjN/BQK aRczU2L4VNZggGyJUgn3o4rvrmCjVIZJ+YDSXbtELPqJCnn4+2rSQVNFqty0gH1Ug1DQ Acf+jv2nem0QSi/skSWm+rDPqYQCNuD04qIhGkoHUQl4I8d7VRIQ+88gyaO6pLofD6pD Ko1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4-v6si11619023pgf.193.2018.08.05.16.27.05; Sun, 05 Aug 2018 16:27:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726691AbeHFBdX (ORCPT + 2 others); Sun, 5 Aug 2018 21:33:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:37766 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726673AbeHFBdX (ORCPT ); Sun, 5 Aug 2018 21:33:23 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 37D09AE62; Sun, 5 Aug 2018 23:27:03 +0000 (UTC) From: =?utf-8?q?Andreas_F=C3=A4rber?= To: linux-serial@vger.kernel.org, Rob Herring Cc: linux-mips@linux-mips.org, jringle@gridpoint.com, allsey87@gmail.com, Jakub Kicinski , Xue Liu , =?utf-8?q?Andreas_F=C3=A4rb?= =?utf-8?q?er?= , Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org Subject: [RFC] serial: sc16is7xx: Use DT sub-nodes for UART ports Date: Mon, 6 Aug 2018 01:26:51 +0200 Message-Id: <20180805232651.10605-1-afaerber@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org This is to allow using serdev. Signed-off-by: Andreas Färber --- drivers/tty/serial/sc16is7xx.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) -- 2.16.4 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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