kirkwood: update patches and configuration (3.10)
[openwrt/svn-archive/archive.git] / target / linux / kirkwood / patches-3.10 / 0003-of-pci-Add-of_pci_parse_bus_range-function.patch
1 From 389637f9e7f523934acf26c247e4722d761ad966 Mon Sep 17 00:00:00 2001
2 From: Thierry Reding <thierry.reding@avionic-design.de>
3 Date: Thu, 16 May 2013 17:55:19 +0200
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 Signed-off-by: Jason Cooper <jason@lakedaemon.net>
11 ---
12 drivers/of/of_pci.c | 25 +++++++++++++++++++++++++
13 include/linux/of_pci.h | 1 +
14 2 files changed, 26 insertions(+)
15
16 --- a/drivers/of/of_pci.c
17 +++ b/drivers/of/of_pci.c
18 @@ -64,3 +64,28 @@ int of_pci_get_devfn(struct device_node
19 return (be32_to_cpup(reg) >> 8) & 0xff;
20 }
21 EXPORT_SYMBOL_GPL(of_pci_get_devfn);
22 +
23 +/**
24 + * of_pci_parse_bus_range() - parse the bus-range property of a PCI device
25 + * @node: device node
26 + * @res: address to a struct resource to return the bus-range
27 + *
28 + * Returns 0 on success or a negative error-code on failure.
29 + */
30 +int of_pci_parse_bus_range(struct device_node *node, struct resource *res)
31 +{
32 + const __be32 *values;
33 + int len;
34 +
35 + values = of_get_property(node, "bus-range", &len);
36 + if (!values || len < sizeof(*values) * 2)
37 + return -EINVAL;
38 +
39 + res->name = node->name;
40 + res->start = be32_to_cpup(values++);
41 + res->end = be32_to_cpup(values);
42 + res->flags = IORESOURCE_BUS;
43 +
44 + return 0;
45 +}
46 +EXPORT_SYMBOL_GPL(of_pci_parse_bus_range);
47 --- a/include/linux/of_pci.h
48 +++ b/include/linux/of_pci.h
49 @@ -11,5 +11,6 @@ struct device_node;
50 struct device_node *of_pci_find_child_device(struct device_node *parent,
51 unsigned int devfn);
52 int of_pci_get_devfn(struct device_node *np);
53 +int of_pci_parse_bus_range(struct device_node *node, struct resource *res);
54
55 #endif