From patchwork Tue Aug 29 14:27:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 9927551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 66FC7603B4 for ; Tue, 29 Aug 2017 14:38:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B49128972 for ; Tue, 29 Aug 2017 14:38:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FE4F1FF82; Tue, 29 Aug 2017 14:38:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 34EA628985 for ; Tue, 29 Aug 2017 14:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:References:To:From:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=njMsj1ZB6aM48EkuLjBP2rpWAOduZlaqvlHDaF/+uv4=; b=ObbnBt1rd4Z306 D27UWvD10GEMW1ljWmPe8fr1ZpnUCv8FRXtJsHmsRXc7LETVrujB7yv7LBak4rPXgkVxp6RQlOJX2 +BBnD2sMXhawdZ1mwo87PG3phx7SDd0T91sfVXqQu/y+tVqagx3giwCAYscmwwqH7aantpGSNaExX gZMo7lbpDDHsSmD/Px2Q2TIhSmaMjYwWRBDXUGyKYgWhUEeLSqDcTIqTsPvQ7bBcuHr4Xl4QaypDZ X7DIyzPKq/Kw5Tp1Izx2z8xPjI/GzUW57s3oJNoX3qt68MtnICyISF003E++dOTFimkscDlKdwSuQ YWPog/e6DuAkgT4UNzMw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dmhdf-0005V2-Hr; Tue, 29 Aug 2017 14:37:11 +0000 Received: from us-smtp-delivery-107.mimecast.com ([63.128.21.107]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dmhcO-0004aL-Dv for linux-arm-kernel@lists.infradead.org; Tue, 29 Aug 2017 14:36:04 +0000 Received: from CPH-EX1.SDESIGNS.COM (195-215-56-170-static.dk.customer.tdc.net [195.215.56.170]) (Using TLS) by us-smtp-1.mimecast.com with ESMTP id us-mta-44-tnX7XmsiNJez1e_UrGiaTg-1; Tue, 29 Aug 2017 10:35:28 -0400 Received: from [172.27.0.114] (172.27.0.114) by CPH-EX1.sdesigns.com (192.168.10.36) with Microsoft SMTP Server (TLS) id 14.3.294.0; Tue, 29 Aug 2017 16:35:25 +0200 Subject: [PATCH 2/3] PCI: Use of_pci_dma_range_parser_init API From: Marc Gonzalez To: Bjorn Helgaas References: Message-ID: <05956f46-6882-7f7b-1c4c-5851b4e8b8e6@sigmadesigns.com> Date: Tue, 29 Aug 2017 16:27:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.1 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [172.27.0.114] X-MC-Unique: tnX7XmsiNJez1e_UrGiaTg-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170829_073553_597594_91003450 X-CRM114-Status: UNSURE ( 8.08 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mason , linux-pci , Thibaud Cornic , Liviu Dudau , Simon Horman , Ray Jui , Robin Murphy , Linus Walleij , Linux ARM Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use the factorized implementation. Signed-off-by: Marc Gonzalez Acked-by: Linus Walleij --- drivers/pci/host/pci-ftpci100.c | 20 +------------------- drivers/pci/host/pci-rcar-gen2.c | 20 +------------------- drivers/pci/host/pci-xgene.c | 20 +------------------- drivers/pci/host/pcie-iproc.c | 20 +------------------- drivers/pci/host/pcie-rcar.c | 20 +------------------- 5 files changed, 5 insertions(+), 95 deletions(-) diff --git a/drivers/pci/host/pci-ftpci100.c b/drivers/pci/host/pci-ftpci100.c index 5162dffc102b..12d78bba1bd3 100644 --- a/drivers/pci/host/pci-ftpci100.c +++ b/drivers/pci/host/pci-ftpci100.c @@ -370,24 +370,6 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p) return 0; } -static int pci_dma_range_parser_init(struct of_pci_range_parser *parser, - struct device_node *node) -{ - const int na = 3, ns = 2; - int rlen; - - parser->node = node; - parser->pna = of_n_addr_cells(node); - parser->np = parser->pna + na + ns; - - parser->range = of_get_property(node, "dma-ranges", &rlen); - if (!parser->range) - return -ENOENT; - parser->end = parser->range + rlen / sizeof(__be32); - - return 0; -} - static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p, struct device_node *np) { @@ -402,7 +384,7 @@ static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p, int i = 0; u32 val; - if (pci_dma_range_parser_init(&parser, np)) { + if (of_pci_dma_range_parser_init(&parser, np)) { dev_err(dev, "missing dma-ranges property\n"); return -EINVAL; } diff --git a/drivers/pci/host/pci-rcar-gen2.c b/drivers/pci/host/pci-rcar-gen2.c index 6f879685fedd..e46de69f0380 100644 --- a/drivers/pci/host/pci-rcar-gen2.c +++ b/drivers/pci/host/pci-rcar-gen2.c @@ -293,24 +293,6 @@ static struct pci_ops rcar_pci_ops = { .write = pci_generic_config_write, }; -static int pci_dma_range_parser_init(struct of_pci_range_parser *parser, - struct device_node *node) -{ - const int na = 3, ns = 2; - int rlen; - - parser->node = node; - parser->pna = of_n_addr_cells(node); - parser->np = parser->pna + na + ns; - - parser->range = of_get_property(node, "dma-ranges", &rlen); - if (!parser->range) - return -ENOENT; - - parser->end = parser->range + rlen / sizeof(__be32); - return 0; -} - static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci, struct device_node *np) { @@ -320,7 +302,7 @@ static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci, int index = 0; /* Failure to parse is ok as we fall back to defaults */ - if (pci_dma_range_parser_init(&parser, np)) + if (of_pci_dma_range_parser_init(&parser, np)) return 0; /* Get the dma-ranges from DT */ diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c index bd897479a215..f660513946d3 100644 --- a/drivers/pci/host/pci-xgene.c +++ b/drivers/pci/host/pci-xgene.c @@ -542,24 +542,6 @@ static void xgene_pcie_setup_ib_reg(struct xgene_pcie_port *port, xgene_pcie_setup_pims(port, pim_reg, pci_addr, ~(size - 1)); } -static int pci_dma_range_parser_init(struct of_pci_range_parser *parser, - struct device_node *node) -{ - const int na = 3, ns = 2; - int rlen; - - parser->node = node; - parser->pna = of_n_addr_cells(node); - parser->np = parser->pna + na + ns; - - parser->range = of_get_property(node, "dma-ranges", &rlen); - if (!parser->range) - return -ENOENT; - parser->end = parser->range + rlen / sizeof(__be32); - - return 0; -} - static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie_port *port) { struct device_node *np = port->node; @@ -568,7 +550,7 @@ static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie_port *port) struct device *dev = port->dev; u8 ib_reg_mask = 0; - if (pci_dma_range_parser_init(&parser, np)) { + if (of_pci_dma_range_parser_init(&parser, np)) { dev_err(dev, "missing dma-ranges property\n"); return -EINVAL; } diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c index c57486348856..aa4f6d519053 100644 --- a/drivers/pci/host/pcie-iproc.c +++ b/drivers/pci/host/pcie-iproc.c @@ -1000,24 +1000,6 @@ static int iproc_pcie_setup_ib(struct iproc_pcie *pcie, return ret; } -static int pci_dma_range_parser_init(struct of_pci_range_parser *parser, - struct device_node *node) -{ - const int na = 3, ns = 2; - int rlen; - - parser->node = node; - parser->pna = of_n_addr_cells(node); - parser->np = parser->pna + na + ns; - - parser->range = of_get_property(node, "dma-ranges", &rlen); - if (!parser->range) - return -ENOENT; - - parser->end = parser->range + rlen / sizeof(__be32); - return 0; -} - static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie) { struct of_pci_range range; @@ -1025,7 +1007,7 @@ static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie) int ret; /* Get the dma-ranges from DT */ - ret = pci_dma_range_parser_init(&parser, pcie->dev->of_node); + ret = of_pci_dma_range_parser_init(&parser, pcie->dev->of_node); if (ret) return ret; diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 246d485b24c6..7975b10e21e8 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -1029,24 +1029,6 @@ static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, return 0; } -static int pci_dma_range_parser_init(struct of_pci_range_parser *parser, - struct device_node *node) -{ - const int na = 3, ns = 2; - int rlen; - - parser->node = node; - parser->pna = of_n_addr_cells(node); - parser->np = parser->pna + na + ns; - - parser->range = of_get_property(node, "dma-ranges", &rlen); - if (!parser->range) - return -ENOENT; - - parser->end = parser->range + rlen / sizeof(__be32); - return 0; -} - static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie, struct device_node *np) { @@ -1055,7 +1037,7 @@ static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie, int index = 0; int err; - if (pci_dma_range_parser_init(&parser, np)) + if (of_pci_dma_range_parser_init(&parser, np)) return -EINVAL; /* Get the dma-ranges from DT */