From patchwork Sat Mar 23 04:05:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingoo Han X-Patchwork-Id: 2324101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id BF17B400E6 for ; Sat, 23 Mar 2013 04:10:59 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UJFiV-0001lQ-GS; Sat, 23 Mar 2013 04:06:03 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UJFiS-0001kr-2G for linux-arm-kernel@lists.infradead.org; Sat, 23 Mar 2013 04:06:01 +0000 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MK300821I1SXY80@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Sat, 23 Mar 2013 13:05:57 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.49]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id D0.B6.20872.52A2D415; Sat, 23 Mar 2013 13:05:57 +0900 (KST) X-AuditID: cbfee68d-b7f786d000005188-9d-514d2a25e64f Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id A0.6A.17838.52A2D415; Sat, 23 Mar 2013 13:05:57 +0900 (KST) Received: from DOJG1HAN02 ([12.23.120.99]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MK300G9JI1XAT10@mmp2.samsung.com>; Sat, 23 Mar 2013 13:05:57 +0900 (KST) From: Jingoo Han To: 'Kukjin Kim' , 'Bjorn Helgaas' References: <00c001ce277b$92b26ab0$b8174010$%han@samsung.com> In-reply-to: <00c001ce277b$92b26ab0$b8174010$%han@samsung.com> Subject: [PATCH 2/6] of/pci: Add of_pci_parse_bus_range() function Date: Sat, 23 Mar 2013 13:05:56 +0900 Message-id: <00c101ce277b$b8835b00$298a1100$%han@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac4ne5IlJNJTIxgLT4K5aVV6JypTrgAAAt+Q Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBKsWRmVeSWpSXmKPExsVy+t8zQ11VLd9Ag+UzxC2a/29ntVjSlGFx YPZDVotXZzayWVxeeInV4vsNU4veBVfZLDY9vsZqcXnXHDaLs/OOs1nMOL+PyWJF01ZGi8UX lzNb7F65hMXi2IwljBZPHzQxOQh4rJm3htGjb8pVNo8nmy4yeizYVOpx59oeNo/NS+o9zs9Y yOjxfUcvUMGWVYweP1/qeHzeJBfAHcVlk5Kak1mWWqRvl8CVMWPTCtaCX3wVm1dsYGlg3M/T xcjJISFgIvFv/wwWCFtM4sK99WwgtpDAMkaJrwsqYGpa+xcB1XABxaczSqw/eg7K+cUo8WH9 dCaQKjYBNYkvXw6zg9giAv4S1662ghUxC3xmkVg++Qw7xFhbibsn5zKD2JwCdhKPW1vBVgsL OEnM2D8TbBCLgKpE//7VjCA2L1D910ePmSFsQYkfk++B1TMLaEms33mcCcKWl9i85i1QDQfQ qeoSj/7qQtxgJPHyRzs7RImIxL4X7xhB7pEQuMIhcfbKRxaIXQIS3yYfYoHolZXYdIAZ4mNJ iYMrbrBMYJSYhWTzLCSbZyHZPAvJigWMLKsYRVMLkguKk9KLDPWKE3OLS/PS9ZLzczcxQlJJ 7w7G2wesDzEmA62fyCwlmpwPTEV5JfGGxmZGFqYmpsZG5pZmpAkrifOqtVgHCgm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SWp2ampBalFMFuYODilGhjlClPv+76s+rBhY1J29z7GFL3436K1 zB0ad19MEGWbsalKRo/revbWid3uS+pKuL6wuhXEfH71+MWin392buat3H86YfPKpod+kfK9 zH0MLksfuEitmN7xOjXCzciu0G5V0ryn6lUVH5z35qV8Oqx16d/Ev6e2JP3+NTt+4pmdn18/ bdFk2GipxFKckWioxVxUnAgApAixTpkDAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130323_000600_395448_F1760A67 X-CRM114-Status: UNSURE ( 9.69 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -8.9 (--------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-8.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.24 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -2.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.5 HDRS_LCASE_1K Odd capitalization of message headers + long header Cc: 'Thomas Petazzoni' , 'Jason Gunthorpe' , linux-samsung-soc@vger.kernel.org, 'Siva Reddy Kallam' , linux-pci@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, 'Thierry Reding' , linux-kernel@vger.kernel.org, 'Grant Likely' , 'Surendranath Gurivireddy Balla' , 'Thomas Abraham' , 'Jingoo Han' , 'Andrew Murray' , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Thierry Reding This function can be used to parse a bus-range property as specified by device nodes representing PCI bridges. Signed-off-by: Thierry Reding Signed-off-by: Jingoo Han --- drivers/of/of_pci.c | 25 +++++++++++++++++++++++++ include/linux/of_pci.h | 1 + 2 files changed, 26 insertions(+), 0 deletions(-) diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index 13e37e2..4ca7837 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c @@ -40,3 +40,28 @@ struct device_node *of_pci_find_child_device(struct device_node *parent, return NULL; } EXPORT_SYMBOL_GPL(of_pci_find_child_device); + +/** + * 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 bb115de..178a5cc 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h @@ -10,5 +10,6 @@ int of_irq_map_pci(const struct pci_dev *pdev, struct of_irq *out_irq); struct device_node; struct device_node *of_pci_find_child_device(struct device_node *parent, unsigned int devfn); +int of_pci_parse_bus_range(struct device_node *node, struct resource *res); #endif