aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 14:30:41 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 14:30:41 -0500
commitb58ed041a360ed051fab17e4d9b0f451c6fedba7 (patch)
treec21db4bc5042821cae320213652b2dbec880a58d /drivers
parent259cdbee2094d28b72f0f3d77bc9203d682994ff (diff)
parent58fea354d887fddddd342a8d14b02069161ca904 (diff)
Merge tag 'devicetree-for-linus' of git://git.secretlab.ca/git/linux-2.6
Pull device tree changes from Grant Likely: "Here are the DT changes I've got queued up for v3.8. As described below, there are a lot of bug fixes here and documentation updates but nothing major: Bug fixes, little cleanups, and documentation changes. The most invasive thing here touches a bunch of the arch directories to use a common build rule for .dtb files. There are no major changes to functionality here other than a few new helper functions." * tag 'devicetree-for-linus' of git://git.secretlab.ca/git/linux-2.6: (34 commits) arm64: Fix the dtbs target building mtd: nand: davinci: fix the binding documentation rtc: rtc-mv: Add the device tree binding documentation devicetree/bindings: Move gpio-leds binding into leds directory of/vendor-prefixes: add Imagination Technologies microblaze: use new common dtc rule c6x: use new common dtc rule openrisc: use new common dtc rule arm64: Add dtbs target for building all the enabled dtb files arm64: use new common dtc rule ARM: dt: change .dtb build rules to build in dts directory kbuild: centralize .dts->.dtb rule Fix build when CONFIG_W1_MASTER_GPIO=m b exporting "allnodes" of/spi: Honour "status=disabled" property of device of_mdio: Honour "status=disabled" property of device of_i2c: Honour "status=disabled" property of device powerpc: Fix fallout from device_node->name constification of: add 'const' for of_parse_phandle parameter *np Documentation: correct of_platform_populate() argument list script: dtc: clean generated files ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/busses/i2c-ocores.c4
-rw-r--r--drivers/of/base.c128
-rw-r--r--drivers/of/fdt.c18
-rw-r--r--drivers/of/of_i2c.c2
-rw-r--r--drivers/of/of_mdio.c2
-rw-r--r--drivers/of/pdt.c12
-rw-r--r--drivers/spi/spi.c2
7 files changed, 126 insertions, 42 deletions
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index bffd5501ac2d..15da1ac7cf9e 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -9,10 +9,6 @@
9 * kind, whether express or implied. 9 * kind, whether express or implied.
10 */ 10 */
11 11
12/*
13 * This driver can be used from the device tree, see
14 * Documentation/devicetree/bindings/i2c/ocore-i2c.txt
15 */
16#include <linux/kernel.h> 12#include <linux/kernel.h>
17#include <linux/module.h> 13#include <linux/module.h>
18#include <linux/init.h> 14#include <linux/init.h>
diff --git a/drivers/of/base.c b/drivers/of/base.c
index af3b22ac7627..538e3cfad23e 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -45,7 +45,8 @@ struct alias_prop {
45 45
46static LIST_HEAD(aliases_lookup); 46static LIST_HEAD(aliases_lookup);
47 47
48struct device_node *allnodes; 48struct device_node *of_allnodes;
49EXPORT_SYMBOL(of_allnodes);
49struct device_node *of_chosen; 50struct device_node *of_chosen;
50struct device_node *of_aliases; 51struct device_node *of_aliases;
51 52
@@ -199,7 +200,7 @@ struct device_node *of_find_all_nodes(struct device_node *prev)
199 struct device_node *np; 200 struct device_node *np;
200 201
201 read_lock(&devtree_lock); 202 read_lock(&devtree_lock);
202 np = prev ? prev->allnext : allnodes; 203 np = prev ? prev->allnext : of_allnodes;
203 for (; np != NULL; np = np->allnext) 204 for (; np != NULL; np = np->allnext)
204 if (of_node_get(np)) 205 if (of_node_get(np))
205 break; 206 break;
@@ -422,7 +423,7 @@ EXPORT_SYMBOL(of_get_child_by_name);
422 */ 423 */
423struct device_node *of_find_node_by_path(const char *path) 424struct device_node *of_find_node_by_path(const char *path)
424{ 425{
425 struct device_node *np = allnodes; 426 struct device_node *np = of_allnodes;
426 427
427 read_lock(&devtree_lock); 428 read_lock(&devtree_lock);
428 for (; np; np = np->allnext) { 429 for (; np; np = np->allnext) {
@@ -452,7 +453,7 @@ struct device_node *of_find_node_by_name(struct device_node *from,
452 struct device_node *np; 453 struct device_node *np;
453 454
454 read_lock(&devtree_lock); 455 read_lock(&devtree_lock);
455 np = from ? from->allnext : allnodes; 456 np = from ? from->allnext : of_allnodes;
456 for (; np; np = np->allnext) 457 for (; np; np = np->allnext)
457 if (np->name && (of_node_cmp(np->name, name) == 0) 458 if (np->name && (of_node_cmp(np->name, name) == 0)
458 && of_node_get(np)) 459 && of_node_get(np))
@@ -481,7 +482,7 @@ struct device_node *of_find_node_by_type(struct device_node *from,
481 struct device_node *np; 482 struct device_node *np;
482 483
483 read_lock(&devtree_lock); 484 read_lock(&devtree_lock);
484 np = from ? from->allnext : allnodes; 485 np = from ? from->allnext : of_allnodes;
485 for (; np; np = np->allnext) 486 for (; np; np = np->allnext)
486 if (np->type && (of_node_cmp(np->type, type) == 0) 487 if (np->type && (of_node_cmp(np->type, type) == 0)
487 && of_node_get(np)) 488 && of_node_get(np))
@@ -512,7 +513,7 @@ struct device_node *of_find_compatible_node(struct device_node *from,
512 struct device_node *np; 513 struct device_node *np;
513 514
514 read_lock(&devtree_lock); 515 read_lock(&devtree_lock);
515 np = from ? from->allnext : allnodes; 516 np = from ? from->allnext : of_allnodes;
516 for (; np; np = np->allnext) { 517 for (; np; np = np->allnext) {
517 if (type 518 if (type
518 && !(np->type && (of_node_cmp(np->type, type) == 0))) 519 && !(np->type && (of_node_cmp(np->type, type) == 0)))
@@ -545,7 +546,7 @@ struct device_node *of_find_node_with_property(struct device_node *from,
545 struct property *pp; 546 struct property *pp;
546 547
547 read_lock(&devtree_lock); 548 read_lock(&devtree_lock);
548 np = from ? from->allnext : allnodes; 549 np = from ? from->allnext : of_allnodes;
549 for (; np; np = np->allnext) { 550 for (; np; np = np->allnext) {
550 for (pp = np->properties; pp; pp = pp->next) { 551 for (pp = np->properties; pp; pp = pp->next) {
551 if (of_prop_cmp(pp->name, prop_name) == 0) { 552 if (of_prop_cmp(pp->name, prop_name) == 0) {
@@ -594,27 +595,35 @@ const struct of_device_id *of_match_node(const struct of_device_id *matches,
594EXPORT_SYMBOL(of_match_node); 595EXPORT_SYMBOL(of_match_node);
595 596
596/** 597/**
597 * of_find_matching_node - Find a node based on an of_device_id match 598 * of_find_matching_node_and_match - Find a node based on an of_device_id
598 * table. 599 * match table.
599 * @from: The node to start searching from or NULL, the node 600 * @from: The node to start searching from or NULL, the node
600 * you pass will not be searched, only the next one 601 * you pass will not be searched, only the next one
601 * will; typically, you pass what the previous call 602 * will; typically, you pass what the previous call
602 * returned. of_node_put() will be called on it 603 * returned. of_node_put() will be called on it
603 * @matches: array of of device match structures to search in 604 * @matches: array of of device match structures to search in
605 * @match Updated to point at the matches entry which matched
604 * 606 *
605 * Returns a node pointer with refcount incremented, use 607 * Returns a node pointer with refcount incremented, use
606 * of_node_put() on it when done. 608 * of_node_put() on it when done.
607 */ 609 */
608struct device_node *of_find_matching_node(struct device_node *from, 610struct device_node *of_find_matching_node_and_match(struct device_node *from,
609 const struct of_device_id *matches) 611 const struct of_device_id *matches,
612 const struct of_device_id **match)
610{ 613{
611 struct device_node *np; 614 struct device_node *np;
612 615
616 if (match)
617 *match = NULL;
618
613 read_lock(&devtree_lock); 619 read_lock(&devtree_lock);
614 np = from ? from->allnext : allnodes; 620 np = from ? from->allnext : of_allnodes;
615 for (; np; np = np->allnext) { 621 for (; np; np = np->allnext) {
616 if (of_match_node(matches, np) && of_node_get(np)) 622 if (of_match_node(matches, np) && of_node_get(np)) {
623 if (match)
624 *match = matches;
617 break; 625 break;
626 }
618 } 627 }
619 of_node_put(from); 628 of_node_put(from);
620 read_unlock(&devtree_lock); 629 read_unlock(&devtree_lock);
@@ -661,7 +670,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
661 struct device_node *np; 670 struct device_node *np;
662 671
663 read_lock(&devtree_lock); 672 read_lock(&devtree_lock);
664 for (np = allnodes; np; np = np->allnext) 673 for (np = of_allnodes; np; np = np->allnext)
665 if (np->phandle == handle) 674 if (np->phandle == handle)
666 break; 675 break;
667 of_node_get(np); 676 of_node_get(np);
@@ -671,12 +680,89 @@ struct device_node *of_find_node_by_phandle(phandle handle)
671EXPORT_SYMBOL(of_find_node_by_phandle); 680EXPORT_SYMBOL(of_find_node_by_phandle);
672 681
673/** 682/**
683 * of_property_read_u8_array - Find and read an array of u8 from a property.
684 *
685 * @np: device node from which the property value is to be read.
686 * @propname: name of the property to be searched.
687 * @out_value: pointer to return value, modified only if return value is 0.
688 * @sz: number of array elements to read
689 *
690 * Search for a property in a device node and read 8-bit value(s) from
691 * it. Returns 0 on success, -EINVAL if the property does not exist,
692 * -ENODATA if property does not have a value, and -EOVERFLOW if the
693 * property data isn't large enough.
694 *
695 * dts entry of array should be like:
696 * property = /bits/ 8 <0x50 0x60 0x70>;
697 *
698 * The out_value is modified only if a valid u8 value can be decoded.
699 */
700int of_property_read_u8_array(const struct device_node *np,
701 const char *propname, u8 *out_values, size_t sz)
702{
703 struct property *prop = of_find_property(np, propname, NULL);
704 const u8 *val;
705
706 if (!prop)
707 return -EINVAL;
708 if (!prop->value)
709 return -ENODATA;
710 if ((sz * sizeof(*out_values)) > prop->length)
711 return -EOVERFLOW;
712
713 val = prop->value;
714 while (sz--)
715 *out_values++ = *val++;
716 return 0;
717}
718EXPORT_SYMBOL_GPL(of_property_read_u8_array);
719
720/**
721 * of_property_read_u16_array - Find and read an array of u16 from a property.
722 *
723 * @np: device node from which the property value is to be read.
724 * @propname: name of the property to be searched.
725 * @out_value: pointer to return value, modified only if return value is 0.
726 * @sz: number of array elements to read
727 *
728 * Search for a property in a device node and read 16-bit value(s) from
729 * it. Returns 0 on success, -EINVAL if the property does not exist,
730 * -ENODATA if property does not have a value, and -EOVERFLOW if the
731 * property data isn't large enough.
732 *
733 * dts entry of array should be like:
734 * property = /bits/ 16 <0x5000 0x6000 0x7000>;
735 *
736 * The out_value is modified only if a valid u16 value can be decoded.
737 */
738int of_property_read_u16_array(const struct device_node *np,
739 const char *propname, u16 *out_values, size_t sz)
740{
741 struct property *prop = of_find_property(np, propname, NULL);
742 const __be16 *val;
743
744 if (!prop)
745 return -EINVAL;
746 if (!prop->value)
747 return -ENODATA;
748 if ((sz * sizeof(*out_values)) > prop->length)
749 return -EOVERFLOW;
750
751 val = prop->value;
752 while (sz--)
753 *out_values++ = be16_to_cpup(val++);
754 return 0;
755}
756EXPORT_SYMBOL_GPL(of_property_read_u16_array);
757
758/**
674 * of_property_read_u32_array - Find and read an array of 32 bit integers 759 * of_property_read_u32_array - Find and read an array of 32 bit integers
675 * from a property. 760 * from a property.
676 * 761 *
677 * @np: device node from which the property value is to be read. 762 * @np: device node from which the property value is to be read.
678 * @propname: name of the property to be searched. 763 * @propname: name of the property to be searched.
679 * @out_value: pointer to return value, modified only if return value is 0. 764 * @out_value: pointer to return value, modified only if return value is 0.
765 * @sz: number of array elements to read
680 * 766 *
681 * Search for a property in a device node and read 32-bit value(s) from 767 * Search for a property in a device node and read 32-bit value(s) from
682 * it. Returns 0 on success, -EINVAL if the property does not exist, 768 * it. Returns 0 on success, -EINVAL if the property does not exist,
@@ -893,8 +979,8 @@ EXPORT_SYMBOL_GPL(of_property_count_strings);
893 * Returns the device_node pointer with refcount incremented. Use 979 * Returns the device_node pointer with refcount incremented. Use
894 * of_node_put() on it when done. 980 * of_node_put() on it when done.
895 */ 981 */
896struct device_node * 982struct device_node *of_parse_phandle(const struct device_node *np,
897of_parse_phandle(struct device_node *np, const char *phandle_name, int index) 983 const char *phandle_name, int index)
898{ 984{
899 const __be32 *phandle; 985 const __be32 *phandle;
900 int size; 986 int size;
@@ -1169,9 +1255,9 @@ void of_attach_node(struct device_node *np)
1169 1255
1170 write_lock_irqsave(&devtree_lock, flags); 1256 write_lock_irqsave(&devtree_lock, flags);
1171 np->sibling = np->parent->child; 1257 np->sibling = np->parent->child;
1172 np->allnext = allnodes; 1258 np->allnext = of_allnodes;
1173 np->parent->child = np; 1259 np->parent->child = np;
1174 allnodes = np; 1260 of_allnodes = np;
1175 write_unlock_irqrestore(&devtree_lock, flags); 1261 write_unlock_irqrestore(&devtree_lock, flags);
1176} 1262}
1177 1263
@@ -1192,11 +1278,11 @@ void of_detach_node(struct device_node *np)
1192 if (!parent) 1278 if (!parent)
1193 goto out_unlock; 1279 goto out_unlock;
1194 1280
1195 if (allnodes == np) 1281 if (of_allnodes == np)
1196 allnodes = np->allnext; 1282 of_allnodes = np->allnext;
1197 else { 1283 else {
1198 struct device_node *prev; 1284 struct device_node *prev;
1199 for (prev = allnodes; 1285 for (prev = of_allnodes;
1200 prev->allnext != np; 1286 prev->allnext != np;
1201 prev = prev->allnext) 1287 prev = prev->allnext)
1202 ; 1288 ;
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 91a375fb6ae6..a65c39c473bf 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -186,6 +186,8 @@ static unsigned long unflatten_dt_node(struct boot_param_header *blob,
186 */ 186 */
187 fpsize = 1; 187 fpsize = 1;
188 allocl = 2; 188 allocl = 2;
189 l = 1;
190 *pathp = '\0';
189 } else { 191 } else {
190 /* account for '/' and path size minus terminal 0 192 /* account for '/' and path size minus terminal 0
191 * already in 'l' 193 * already in 'l'
@@ -198,10 +200,10 @@ static unsigned long unflatten_dt_node(struct boot_param_header *blob,
198 np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl, 200 np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,
199 __alignof__(struct device_node)); 201 __alignof__(struct device_node));
200 if (allnextpp) { 202 if (allnextpp) {
203 char *fn;
201 memset(np, 0, sizeof(*np)); 204 memset(np, 0, sizeof(*np));
202 np->full_name = ((char *)np) + sizeof(struct device_node); 205 np->full_name = fn = ((char *)np) + sizeof(*np);
203 if (new_format) { 206 if (new_format) {
204 char *fn = np->full_name;
205 /* rebuild full path for new format */ 207 /* rebuild full path for new format */
206 if (dad && dad->parent) { 208 if (dad && dad->parent) {
207 strcpy(fn, dad->full_name); 209 strcpy(fn, dad->full_name);
@@ -215,9 +217,9 @@ static unsigned long unflatten_dt_node(struct boot_param_header *blob,
215 fn += strlen(fn); 217 fn += strlen(fn);
216 } 218 }
217 *(fn++) = '/'; 219 *(fn++) = '/';
218 memcpy(fn, pathp, l); 220 }
219 } else 221 memcpy(fn, pathp, l);
220 memcpy(np->full_name, pathp, l); 222
221 prev_pp = &np->properties; 223 prev_pp = &np->properties;
222 **allnextpp = np; 224 **allnextpp = np;
223 *allnextpp = &np->allnext; 225 *allnextpp = &np->allnext;
@@ -459,7 +461,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
459 461
460 do { 462 do {
461 u32 tag = be32_to_cpup((__be32 *)p); 463 u32 tag = be32_to_cpup((__be32 *)p);
462 char *pathp; 464 const char *pathp;
463 465
464 p += 4; 466 p += 4;
465 if (tag == OF_DT_END_NODE) { 467 if (tag == OF_DT_END_NODE) {
@@ -487,7 +489,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
487 pathp = (char *)p; 489 pathp = (char *)p;
488 p = ALIGN(p + strlen(pathp) + 1, 4); 490 p = ALIGN(p + strlen(pathp) + 1, 4);
489 if ((*pathp) == '/') { 491 if ((*pathp) == '/') {
490 char *lp, *np; 492 const char *lp, *np;
491 for (lp = NULL, np = pathp; *np; np++) 493 for (lp = NULL, np = pathp; *np; np++)
492 if ((*np) == '/') 494 if ((*np) == '/')
493 lp = np+1; 495 lp = np+1;
@@ -710,7 +712,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
710 */ 712 */
711void __init unflatten_device_tree(void) 713void __init unflatten_device_tree(void)
712{ 714{
713 __unflatten_device_tree(initial_boot_params, &allnodes, 715 __unflatten_device_tree(initial_boot_params, &of_allnodes,
714 early_init_dt_alloc_memory_arch); 716 early_init_dt_alloc_memory_arch);
715 717
716 /* Get pointer to "/chosen" and "/aliasas" nodes for use everywhere */ 718 /* Get pointer to "/chosen" and "/aliasas" nodes for use everywhere */
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
index 3550f3bf4f92..b667264222cc 100644
--- a/drivers/of/of_i2c.c
+++ b/drivers/of/of_i2c.c
@@ -29,7 +29,7 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
29 29
30 dev_dbg(&adap->dev, "of_i2c: walking child nodes\n"); 30 dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
31 31
32 for_each_child_of_node(adap->dev.of_node, node) { 32 for_each_available_child_of_node(adap->dev.of_node, node) {
33 struct i2c_board_info info = {}; 33 struct i2c_board_info info = {};
34 struct dev_archdata dev_ad = {}; 34 struct dev_archdata dev_ad = {};
35 const __be32 *addr; 35 const __be32 *addr;
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 8e6c25f35040..83ca06f4312b 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -53,7 +53,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
53 return rc; 53 return rc;
54 54
55 /* Loop over the child nodes and register a phy_device for each one */ 55 /* Loop over the child nodes and register a phy_device for each one */
56 for_each_child_of_node(np, child) { 56 for_each_available_child_of_node(np, child) {
57 const __be32 *paddr; 57 const __be32 *paddr;
58 u32 addr; 58 u32 addr;
59 int len; 59 int len;
diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c
index 07cc1d678e4d..37b56fd716e6 100644
--- a/drivers/of/pdt.c
+++ b/drivers/of/pdt.c
@@ -241,15 +241,15 @@ void __init of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops)
241 BUG_ON(!ops); 241 BUG_ON(!ops);
242 of_pdt_prom_ops = ops; 242 of_pdt_prom_ops = ops;
243 243
244 allnodes = of_pdt_create_node(root_node, NULL); 244 of_allnodes = of_pdt_create_node(root_node, NULL);
245#if defined(CONFIG_SPARC) 245#if defined(CONFIG_SPARC)
246 allnodes->path_component_name = ""; 246 of_allnodes->path_component_name = "";
247#endif 247#endif
248 allnodes->full_name = "/"; 248 of_allnodes->full_name = "/";
249 249
250 nextp = &allnodes->allnext; 250 nextp = &of_allnodes->allnext;
251 allnodes->child = of_pdt_build_tree(allnodes, 251 of_allnodes->child = of_pdt_build_tree(of_allnodes,
252 of_pdt_prom_ops->getchild(allnodes->phandle), &nextp); 252 of_pdt_prom_ops->getchild(of_allnodes->phandle), &nextp);
253 253
254 /* Get pointer to "/chosen" and "/aliasas" nodes for use everywhere */ 254 /* Get pointer to "/chosen" and "/aliasas" nodes for use everywhere */
255 of_alias_scan(kernel_tree_alloc); 255 of_alias_scan(kernel_tree_alloc);
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 84c2861d6f4d..d3e64080c409 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -819,7 +819,7 @@ static void of_register_spi_devices(struct spi_master *master)
819 if (!master->dev.of_node) 819 if (!master->dev.of_node)
820 return; 820 return;
821 821
822 for_each_child_of_node(master->dev.of_node, nc) { 822 for_each_available_child_of_node(master->dev.of_node, nc) {
823 /* Alloc an spi_device */ 823 /* Alloc an spi_device */
824 spi = spi_alloc_device(master); 824 spi = spi_alloc_device(master);
825 if (!spi) { 825 if (!spi) {