diff for duplicates of <20121212163749.GA17371@arm.com> diff --git a/a/1.txt b/N1/1.txt index a0be6e8..ec0171f 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -1,34 +1,41 @@ DT bindings for PCI host bridges often use the ranges property to describe -memory and IO ranges - this binding tends to be the same across architectures +memory and IO ranges - this binding tends to be the same across architectur= +es yet several parsing implementations exist, e.g. arch/mips/pci/pci.c, arch/powerpc/kernel/pci-common.c, arch/sparc/kernel/pci.c and arch/microblaze/pci/pci-common.c (clone of PPC). Some of these duplicate functionality provided by drivers/of/address.c. -This patch provides a common iterator-based parser for the ranges property, it -is hoped this will reduce DT representation differences between architectures +This patch provides a common iterator-based parser for the ranges property,= + it +is hoped this will reduce DT representation differences between architectur= +es and that architectures will migrate in part to this new parser. It is also hoped (and the motativation for the patch) that this patch will -reduce duplication of code when writing host bridge drivers that are supported +reduce duplication of code when writing host bridge drivers that are suppor= +ted by multiple architectures. This patch provides struct resources from a device tree node, e.g.: - u32 *last = NULL; - struct resource res; - while ((last = of_pci_process_ranges(np, res, last))) { - //do something with res - } +=09u32 *last =3D NULL; +=09struct resource res; +=09while ((last =3D of_pci_process_ranges(np, res, last))) { +=09=09//do something with res +=09} -Platforms with quirks can then do what they like with the resource or migrate -common quirk handling to the parser. In an ideal world drivers can just request +Platforms with quirks can then do what they like with the resource or migra= +te +common quirk handling to the parser. In an ideal world drivers can just req= +uest the obtained resources and pass them on (e.g. pci_add_resource_offset). Signed-off-by: Andrew Murray <Andrew.Murray@arm.com> Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com> --- - drivers/of/address.c | 53 +++++++++++++++++++++++++++++++++++++++++++- + drivers/of/address.c | 53 ++++++++++++++++++++++++++++++++++++++++= ++++- include/linux/of_address.h | 7 +++++ 2 files changed, 59 insertions(+), 1 deletions(-) @@ -36,97 +43,102 @@ diff --git a/drivers/of/address.c b/drivers/of/address.c index 7e262a6..03bfe61 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c -@@ -219,6 +219,57 @@ int of_pci_address_to_resource(struct device_node *dev, int bar, - return __of_address_to_resource(dev, addrp, size, flags, NULL, r); +@@ -219,6 +219,57 @@ int of_pci_address_to_resource(struct device_node *dev= +, int bar, + =09return __of_address_to_resource(dev, addrp, size, flags, NULL, r); } EXPORT_SYMBOL_GPL(of_pci_address_to_resource); + +const __be32 *of_pci_process_ranges(struct device_node *node, -+ struct resource *res, const __be32 *from) ++=09=09=09=09 struct resource *res, const __be32 *from) +{ -+ const __be32 *start, *end; -+ int na, ns, np, pna; -+ int rlen; -+ struct of_bus *bus; -+ WARN_ON(!res); ++=09const __be32 *start, *end; ++=09int na, ns, np, pna; ++=09int rlen; ++=09struct of_bus *bus; ++=09WARN_ON(!res); + -+ bus = of_match_bus(node); -+ bus->count_cells(node, &na, &ns); -+ if (!OF_CHECK_COUNTS(na, ns)) { -+ pr_err("Bad cell count for %s\n", node->full_name); -+ return NULL; -+ } ++=09bus =3D of_match_bus(node); ++=09bus->count_cells(node, &na, &ns); ++=09if (!OF_CHECK_COUNTS(na, ns)) { ++=09=09pr_err("Bad cell count for %s\n", node->full_name); ++=09=09return NULL; ++=09} + -+ pna = of_n_addr_cells(node); -+ np = pna + na + ns; ++=09pna =3D of_n_addr_cells(node); ++=09np =3D pna + na + ns; + -+ start = of_get_property(node, "ranges", &rlen); -+ if (start == NULL) -+ return NULL; ++=09start =3D of_get_property(node, "ranges", &rlen); ++=09if (start =3D=3D NULL) ++=09=09return NULL; + -+ end = start + rlen; ++=09end =3D start + rlen; + -+ if (!from) -+ from = start; ++=09if (!from) ++=09=09from =3D start; + -+ while (from + np <= end) { -+ u64 cpu_addr, size; ++=09while (from + np <=3D end) { ++=09=09u64 cpu_addr, size; + -+ cpu_addr = of_translate_address(node, from + na); -+ size = of_read_number(from + na + pna, ns); -+ res->flags = bus->get_flags(from); -+ from += np; ++=09=09cpu_addr =3D of_translate_address(node, from + na); ++=09=09size =3D of_read_number(from + na + pna, ns); ++=09=09res->flags =3D bus->get_flags(from); ++=09=09from +=3D np; + -+ if (cpu_addr == OF_BAD_ADDR || size == 0) -+ continue; ++=09=09if (cpu_addr =3D=3D OF_BAD_ADDR || size =3D=3D 0) ++=09=09=09continue; + -+ res->name = node->full_name; -+ res->start = cpu_addr; -+ res->end = res->start + size - 1; -+ res->parent = res->child = res->sibling = NULL; -+ return from; -+ } ++=09=09res->name =3D node->full_name; ++=09=09res->start =3D cpu_addr; ++=09=09res->end =3D res->start + size - 1; ++=09=09res->parent =3D res->child =3D res->sibling =3D NULL; ++=09=09return from; ++=09} + -+ return NULL; ++=09return NULL; +} +EXPORT_SYMBOL_GPL(of_pci_process_ranges); + #endif /* CONFIG_PCI */ - +=20 /* -@@ -421,7 +472,7 @@ u64 __of_translate_address(struct device_node *dev, const __be32 *in_addr, - goto bail; - bus = of_match_bus(parent); - -- /* Cound address cells & copy address locally */ -+ /* Count address cells & copy address locally */ - bus->count_cells(dev, &na, &ns); - if (!OF_CHECK_COUNTS(na, ns)) { - printk(KERN_ERR "prom_parse: Bad cell count for %s\n", +@@ -421,7 +472,7 @@ u64 __of_translate_address(struct device_node *dev, con= +st __be32 *in_addr, + =09=09goto bail; + =09bus =3D of_match_bus(parent); +=20 +-=09/* Cound address cells & copy address locally */ ++=09/* Count address cells & copy address locally */ + =09bus->count_cells(dev, &na, &ns); + =09if (!OF_CHECK_COUNTS(na, ns)) { + =09=09printk(KERN_ERR "prom_parse: Bad cell count for %s\n", diff --git a/include/linux/of_address.h b/include/linux/of_address.h index 01b925a..4582b20 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h -@@ -26,6 +26,8 @@ static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; } +@@ -26,6 +26,8 @@ static inline unsigned long pci_address_to_pio(phys_addr_= +t addr) { return -1; } #define pci_address_to_pio pci_address_to_pio #endif - +=20 +const __be32 *of_pci_process_ranges(struct device_node *node, -+ struct resource *res, const __be32 *from); ++=09=09=09=09 struct resource *res, const __be32 *from); #else /* CONFIG_OF_ADDRESS */ - static inline int of_address_to_resource(struct device_node *dev, int index, - struct resource *r) -@@ -48,6 +50,11 @@ static inline const u32 *of_get_address(struct device_node *dev, int index, + static inline int of_address_to_resource(struct device_node *dev, int inde= +x, + =09=09=09=09=09 struct resource *r) +@@ -48,6 +50,11 @@ static inline const u32 *of_get_address(struct device_no= +de *dev, int index, { - return NULL; + =09return NULL; } +const __be32 *of_pci_process_ranges(struct device_node *node, -+ struct resource *res, const __be32 *from) ++=09=09=09=09 struct resource *res, const __be32 *from) +{ -+ return NULL; ++=09return NULL; +} #endif /* CONFIG_OF_ADDRESS */ - - --- +=20 +=20 +--=20 1.7.0.4 diff --git a/a/content_digest b/N1/content_digest index aab2a8e..865f0dc 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -2,48 +2,53 @@ "Subject\0[PATCH] pci: Provide support for parsing PCI DT ranges property\0" "Date\0Wed, 12 Dec 2012 16:37:50 +0000\0" "To\0linux-pci@vger.kernel.org\0" - "Cc\0Thierry Reding <thierry.reding@avionic-design.de>" - Grant Likely <grant.likely@secretlab.ca> - Michal Simek <monstr@monstr.eu> - Rob Herring <robherring2@gmail.com> + "Cc\0Michal Simek <monstr@monstr.eu>" devicetree-discuss <devicetree-discuss@lists.ozlabs.org> + Thierry Reding <thierry.reding@avionic-design.de> + Liviu Dudau <liviu.dudau@arm.com> Rob Herring <rob.herring@calxeda.com> - linuxppc-dev <linuxppc-dev@lists.ozlabs.org> - Benjamin Herrenschmidt <benh@kernel.crashing.org> - " Liviu Dudau <liviu.dudau@arm.com>\0" + Rob Herring <robherring2@gmail.com> + " linuxppc-dev <linuxppc-dev@lists.ozlabs.org>\0" "\00:1\0" "b\0" "DT bindings for PCI host bridges often use the ranges property to describe\n" - "memory and IO ranges - this binding tends to be the same across architectures\n" + "memory and IO ranges - this binding tends to be the same across architectur=\n" + "es\n" "yet several parsing implementations exist, e.g. arch/mips/pci/pci.c,\n" "arch/powerpc/kernel/pci-common.c, arch/sparc/kernel/pci.c and\n" "arch/microblaze/pci/pci-common.c (clone of PPC). Some of these duplicate\n" "functionality provided by drivers/of/address.c.\n" "\n" - "This patch provides a common iterator-based parser for the ranges property, it\n" - "is hoped this will reduce DT representation differences between architectures\n" + "This patch provides a common iterator-based parser for the ranges property,=\n" + " it\n" + "is hoped this will reduce DT representation differences between architectur=\n" + "es\n" "and that architectures will migrate in part to this new parser.\n" "\n" "It is also hoped (and the motativation for the patch) that this patch will\n" - "reduce duplication of code when writing host bridge drivers that are supported\n" + "reduce duplication of code when writing host bridge drivers that are suppor=\n" + "ted\n" "by multiple architectures.\n" "\n" "This patch provides struct resources from a device tree node, e.g.:\n" "\n" - "\tu32 *last = NULL;\n" - "\tstruct resource res;\n" - "\twhile ((last = of_pci_process_ranges(np, res, last))) {\n" - "\t\t//do something with res\n" - "\t}\n" + "=09u32 *last =3D NULL;\n" + "=09struct resource res;\n" + "=09while ((last =3D of_pci_process_ranges(np, res, last))) {\n" + "=09=09//do something with res\n" + "=09}\n" "\n" - "Platforms with quirks can then do what they like with the resource or migrate\n" - "common quirk handling to the parser. In an ideal world drivers can just request\n" + "Platforms with quirks can then do what they like with the resource or migra=\n" + "te\n" + "common quirk handling to the parser. In an ideal world drivers can just req=\n" + "uest\n" "the obtained resources and pass them on (e.g. pci_add_resource_offset).\n" "\n" "Signed-off-by: Andrew Murray <Andrew.Murray@arm.com>\n" "Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>\n" "---\n" - " drivers/of/address.c | 53 +++++++++++++++++++++++++++++++++++++++++++-\n" + " drivers/of/address.c | 53 ++++++++++++++++++++++++++++++++++++++++=\n" + "+++-\n" " include/linux/of_address.h | 7 +++++\n" " 2 files changed, 59 insertions(+), 1 deletions(-)\n" "\n" @@ -51,99 +56,104 @@ "index 7e262a6..03bfe61 100644\n" "--- a/drivers/of/address.c\n" "+++ b/drivers/of/address.c\n" - "@@ -219,6 +219,57 @@ int of_pci_address_to_resource(struct device_node *dev, int bar,\n" - " \treturn __of_address_to_resource(dev, addrp, size, flags, NULL, r);\n" + "@@ -219,6 +219,57 @@ int of_pci_address_to_resource(struct device_node *dev=\n" + ", int bar,\n" + " =09return __of_address_to_resource(dev, addrp, size, flags, NULL, r);\n" " }\n" " EXPORT_SYMBOL_GPL(of_pci_address_to_resource);\n" "+\n" "+const __be32 *of_pci_process_ranges(struct device_node *node,\n" - "+\t\t\t\t struct resource *res, const __be32 *from)\n" + "+=09=09=09=09 struct resource *res, const __be32 *from)\n" "+{\n" - "+\tconst __be32 *start, *end;\n" - "+\tint na, ns, np, pna;\n" - "+\tint rlen;\n" - "+\tstruct of_bus *bus;\n" - "+\tWARN_ON(!res);\n" + "+=09const __be32 *start, *end;\n" + "+=09int na, ns, np, pna;\n" + "+=09int rlen;\n" + "+=09struct of_bus *bus;\n" + "+=09WARN_ON(!res);\n" "+\n" - "+\tbus = of_match_bus(node);\n" - "+\tbus->count_cells(node, &na, &ns);\n" - "+\tif (!OF_CHECK_COUNTS(na, ns)) {\n" - "+\t\tpr_err(\"Bad cell count for %s\\n\", node->full_name);\n" - "+\t\treturn NULL;\n" - "+\t}\n" + "+=09bus =3D of_match_bus(node);\n" + "+=09bus->count_cells(node, &na, &ns);\n" + "+=09if (!OF_CHECK_COUNTS(na, ns)) {\n" + "+=09=09pr_err(\"Bad cell count for %s\\n\", node->full_name);\n" + "+=09=09return NULL;\n" + "+=09}\n" "+\n" - "+\tpna = of_n_addr_cells(node);\n" - "+\tnp = pna + na + ns;\n" + "+=09pna =3D of_n_addr_cells(node);\n" + "+=09np =3D pna + na + ns;\n" "+\n" - "+\tstart = of_get_property(node, \"ranges\", &rlen);\n" - "+\tif (start == NULL)\n" - "+\t\treturn NULL;\n" + "+=09start =3D of_get_property(node, \"ranges\", &rlen);\n" + "+=09if (start =3D=3D NULL)\n" + "+=09=09return NULL;\n" "+\n" - "+\tend = start + rlen;\n" + "+=09end =3D start + rlen;\n" "+\n" - "+\tif (!from)\n" - "+\t\tfrom = start;\n" + "+=09if (!from)\n" + "+=09=09from =3D start;\n" "+\n" - "+\twhile (from + np <= end) {\n" - "+\t\tu64 cpu_addr, size;\n" + "+=09while (from + np <=3D end) {\n" + "+=09=09u64 cpu_addr, size;\n" "+\n" - "+\t\tcpu_addr = of_translate_address(node, from + na);\n" - "+\t\tsize = of_read_number(from + na + pna, ns);\n" - "+\t\tres->flags = bus->get_flags(from);\n" - "+\t\tfrom += np;\n" + "+=09=09cpu_addr =3D of_translate_address(node, from + na);\n" + "+=09=09size =3D of_read_number(from + na + pna, ns);\n" + "+=09=09res->flags =3D bus->get_flags(from);\n" + "+=09=09from +=3D np;\n" "+\n" - "+\t\tif (cpu_addr == OF_BAD_ADDR || size == 0)\n" - "+\t\t\tcontinue;\n" + "+=09=09if (cpu_addr =3D=3D OF_BAD_ADDR || size =3D=3D 0)\n" + "+=09=09=09continue;\n" "+\n" - "+\t\tres->name = node->full_name;\n" - "+\t\tres->start = cpu_addr;\n" - "+\t\tres->end = res->start + size - 1;\n" - "+\t\tres->parent = res->child = res->sibling = NULL;\n" - "+\t\treturn from;\n" - "+\t}\n" + "+=09=09res->name =3D node->full_name;\n" + "+=09=09res->start =3D cpu_addr;\n" + "+=09=09res->end =3D res->start + size - 1;\n" + "+=09=09res->parent =3D res->child =3D res->sibling =3D NULL;\n" + "+=09=09return from;\n" + "+=09}\n" "+\n" - "+\treturn NULL;\n" + "+=09return NULL;\n" "+}\n" "+EXPORT_SYMBOL_GPL(of_pci_process_ranges);\n" "+\n" " #endif /* CONFIG_PCI */\n" - " \n" + "=20\n" " /*\n" - "@@ -421,7 +472,7 @@ u64 __of_translate_address(struct device_node *dev, const __be32 *in_addr,\n" - " \t\tgoto bail;\n" - " \tbus = of_match_bus(parent);\n" - " \n" - "-\t/* Cound address cells & copy address locally */\n" - "+\t/* Count address cells & copy address locally */\n" - " \tbus->count_cells(dev, &na, &ns);\n" - " \tif (!OF_CHECK_COUNTS(na, ns)) {\n" - " \t\tprintk(KERN_ERR \"prom_parse: Bad cell count for %s\\n\",\n" + "@@ -421,7 +472,7 @@ u64 __of_translate_address(struct device_node *dev, con=\n" + "st __be32 *in_addr,\n" + " =09=09goto bail;\n" + " =09bus =3D of_match_bus(parent);\n" + "=20\n" + "-=09/* Cound address cells & copy address locally */\n" + "+=09/* Count address cells & copy address locally */\n" + " =09bus->count_cells(dev, &na, &ns);\n" + " =09if (!OF_CHECK_COUNTS(na, ns)) {\n" + " =09=09printk(KERN_ERR \"prom_parse: Bad cell count for %s\\n\",\n" "diff --git a/include/linux/of_address.h b/include/linux/of_address.h\n" "index 01b925a..4582b20 100644\n" "--- a/include/linux/of_address.h\n" "+++ b/include/linux/of_address.h\n" - "@@ -26,6 +26,8 @@ static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }\n" + "@@ -26,6 +26,8 @@ static inline unsigned long pci_address_to_pio(phys_addr_=\n" + "t addr) { return -1; }\n" " #define pci_address_to_pio pci_address_to_pio\n" " #endif\n" - " \n" + "=20\n" "+const __be32 *of_pci_process_ranges(struct device_node *node,\n" - "+\t\t\t\t struct resource *res, const __be32 *from);\n" + "+=09=09=09=09 struct resource *res, const __be32 *from);\n" " #else /* CONFIG_OF_ADDRESS */\n" - " static inline int of_address_to_resource(struct device_node *dev, int index,\n" - " \t\t\t\t\t struct resource *r)\n" - "@@ -48,6 +50,11 @@ static inline const u32 *of_get_address(struct device_node *dev, int index,\n" + " static inline int of_address_to_resource(struct device_node *dev, int inde=\n" + "x,\n" + " =09=09=09=09=09 struct resource *r)\n" + "@@ -48,6 +50,11 @@ static inline const u32 *of_get_address(struct device_no=\n" + "de *dev, int index,\n" " {\n" - " \treturn NULL;\n" + " =09return NULL;\n" " }\n" "+const __be32 *of_pci_process_ranges(struct device_node *node,\n" - "+\t\t\t\t struct resource *res, const __be32 *from)\n" + "+=09=09=09=09 struct resource *res, const __be32 *from)\n" "+{\n" - "+\treturn NULL;\n" + "+=09return NULL;\n" "+}\n" " #endif /* CONFIG_OF_ADDRESS */\n" - " \n" - " \n" - "-- \n" + "=20\n" + "=20\n" + "--=20\n" 1.7.0.4 -863e1254212e9c8d72200915a2c587762184e63cf75848b2fd02ed0f3f6b6dde +8f0c75b108e5cb963bf99d4d1c8f962c67db1857506811f3763cc7d921674dd7
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.