kirkwood: add linux 3.10 support
[openwrt/svn-archive/archive.git] / target / linux / kirkwood / patches-3.10 / 0003-of-pci-Add-of_pci_parse_bus_range-function.patch
1 From 6275a8e0bacac9702350b6a003470a9ce67c9139 Mon Sep 17 00:00:00 2001
2 From: Thierry Reding <thierry.reding@avionic-design.de>
3 Date: Mon, 11 Feb 2013 09:22:20 +0100
4 Subject: [PATCH 03/29] of/pci: Add of_pci_parse_bus_range() function
5
6 This function can be used to parse a bus-range property as specified by
7 device nodes representing PCI bridges.
8
9 Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
10 ---
11 drivers/of/of_pci.c | 25 +++++++++++++++++++++++++
12 include/linux/of_pci.h | 1 +
13 2 files changed, 26 insertions(+)
14
15 diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
16 index 4dd7b9b..42c687a 100644
17 --- a/drivers/of/of_pci.c
18 +++ b/drivers/of/of_pci.c
19 @@ -64,3 +64,28 @@ int of_pci_get_devfn(struct device_node *np)
20 return (be32_to_cpup(reg) >> 8) & 0xff;
21 }
22 EXPORT_SYMBOL_GPL(of_pci_get_devfn);
23 +
24 +/**
25 + * of_pci_parse_bus_range() - parse the bus-range property of a PCI device
26 + * @node: device node
27 + * @res: address to a struct resource to return the bus-range
28 + *
29 + * Returns 0 on success or a negative error-code on failure.
30 + */
31 +int of_pci_parse_bus_range(struct device_node *node, struct resource *res)
32 +{
33 + const __be32 *values;
34 + int len;
35 +
36 + values = of_get_property(node, "bus-range", &len);
37 + if (!values || len < sizeof(*values) * 2)
38 + return -EINVAL;
39 +
40 + res->name = node->name;
41 + res->start = be32_to_cpup(values++);
42 + res->end = be32_to_cpup(values);
43 + res->flags = IORESOURCE_BUS;
44 +
45 + return 0;
46 +}
47 +EXPORT_SYMBOL_GPL(of_pci_parse_bus_range);
48 diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h
49 index 91ec484..7a04826 100644
50 --- a/include/linux/of_pci.h
51 +++ b/include/linux/of_pci.h
52 @@ -11,5 +11,6 @@ struct device_node;
53 struct device_node *of_pci_find_child_device(struct device_node *parent,
54 unsigned int devfn);
55 int of_pci_get_devfn(struct device_node *np);
56 +int of_pci_parse_bus_range(struct device_node *node, struct resource *res);
57
58 #endif
59 --
60 1.8.4.rc1
61