From patchwork Wed Jan 9 20:43:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 1955401 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 0943DDF2EB for ; Wed, 9 Jan 2013 20:48:40 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tt2WO-0004Yv-An; Wed, 09 Jan 2013 20:45:12 +0000 Received: from moutng.kundenserver.de ([212.227.126.186]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Tt2Uy-00045Q-I9 for linux-arm-kernel@lists.infradead.org; Wed, 09 Jan 2013 20:43:47 +0000 Received: from mailbox.adnet.avionic-design.de (mailbox.avionic-design.de [109.75.18.3]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0LpRtB-1TMi1H1V0X-00enVG; Wed, 09 Jan 2013 21:43:23 +0100 Received: from localhost (localhost [127.0.0.1]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id 7BC6F2A28148; Wed, 9 Jan 2013 21:43:21 +0100 (CET) X-Virus-Scanned: amavisd-new at avionic-design.de Received: from mailbox.adnet.avionic-design.de ([127.0.0.1]) by localhost (mailbox.avionic-design.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8l+lXjX1FWYd; Wed, 9 Jan 2013 21:43:20 +0100 (CET) Received: from mailman.adnet.avionic-design.de (mailman.adnet.avionic-design.de [172.20.31.172]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id ABE142A28146; Wed, 9 Jan 2013 21:43:15 +0100 (CET) Received: from localhost (avionic-0098.adnet.avionic-design.de [172.20.31.233]) by mailman.adnet.avionic-design.de (Postfix) with ESMTP id D13D41007F7; Wed, 9 Jan 2013 21:43:11 +0100 (CET) From: Thierry Reding To: linux-tegra@vger.kernel.org Subject: [PATCH 04/14] of/pci: Add of_pci_parse_bus_range() function Date: Wed, 9 Jan 2013 21:43:04 +0100 Message-Id: <1357764194-12677-5-git-send-email-thierry.reding@avionic-design.de> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1357764194-12677-1-git-send-email-thierry.reding@avionic-design.de> References: <1357764194-12677-1-git-send-email-thierry.reding@avionic-design.de> X-Provags-ID: V02:K0:XS/VmoTbj2DxOgAWE10p9seqyytR4mQi7deBWRAZMd7 S9FgFKjARJ2Rv+4TfgiFPVXAJPn+4vu42pT32qfdIPwXrQ6Tss lq0gmq2z4nk2jHceszXXbhHWZdOi7Py9qDc87hSw5Hwgqiw7d/ fZ04nM0qiMgPDlPl305W74LMLPr0/D/vDufh9u+PgiC+EfblUV Cfh96+YS5c3PQHS6Rt/x7iKDDjQUeBMGuyG8LozFJe87NWUmMo WSXcG/jXoZnYZYiaPvD0L0VsDGpcJrwMoDowvGUCF1sWch1Ve0 S8CZ5/YuVCYP2s3/2hPJpbXlCP9GS7ThnjKDUAvIU1eWnQI122 6Bsl7SM3gHmtoHKwaG26kZFGMRs7E9KUF4/vNkfZ9i+cysgKsI ZV6YwEJAvo2xevuncMYG/GMsC6exFyk11PlfeF3o8bx3pLoxBq y9+Kd X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130109_154345_206078_1E168798 X-CRM114-Status: GOOD ( 10.92 ) X-Spam-Score: 1.1 (+) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.126.186 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Thomas Petazzoni , Jason Gunthorpe , Russell King , Arnd Bergmann , Stephen Warren , linux-pci@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, linux-kernel@vger.kernel.org, Rob Herring , Grant Likely , Bjorn Helgaas , Andrew Murray , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This function can be used to parse a bus-range property as specified by device nodes representing PCI bridges. Signed-off-by: Thierry Reding --- drivers/of/of_pci.c | 25 +++++++++++++++++++++++++ include/linux/of_pci.h | 1 + 2 files changed, 26 insertions(+) diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index 7d5d2c3..c311166 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c @@ -85,3 +85,28 @@ int of_pci_get_devfn(struct device_node *np) return (be32_to_cpup(reg) >> 8) & 0xff; } EXPORT_SYMBOL_GPL(of_pci_get_devfn); + +/** + * of_pci_parse_bus_range() - parse the bus-range property of a PCI device + * @node: device node + * @res: address to a struct resource to return the bus-range + * + * Returns 0 on success or a negative error-code on failure. + */ +int of_pci_parse_bus_range(struct device_node *node, struct resource *res) +{ + const __be32 *values; + int len; + + values = of_get_property(node, "bus-range", &len); + if (!values || len < sizeof(*values) * 2) + return -EINVAL; + + res->name = node->name; + res->start = be32_to_cpup(values++); + res->end = be32_to_cpup(values); + res->flags = IORESOURCE_BUS; + + return 0; +} +EXPORT_SYMBOL_GPL(of_pci_parse_bus_range); diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index 9118321..fb6e95e 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h @@ -12,5 +12,6 @@ struct device_node *of_pci_find_child_device(struct device_node *parent, unsigned int devfn); int of_pci_get_bus(struct device_node *np); int of_pci_get_devfn(struct device_node *np); +int of_pci_parse_bus_range(struct device_node *node, struct resource *res); #endif