aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/Kconfig4
-rw-r--r--drivers/of/address.c8
-rw-r--r--drivers/of/base.c41
-rw-r--r--drivers/of/of_net.c11
4 files changed, 42 insertions, 22 deletions
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index c6973f101a3e..ffdcb11f75fb 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -44,6 +44,10 @@ config OF_DYNAMIC
44config OF_ADDRESS 44config OF_ADDRESS
45 def_bool y 45 def_bool y
46 depends on !SPARC 46 depends on !SPARC
47 select OF_ADDRESS_PCI if PCI
48
49config OF_ADDRESS_PCI
50 bool
47 51
48config OF_IRQ 52config OF_IRQ
49 def_bool y 53 def_bool y
diff --git a/drivers/of/address.c b/drivers/of/address.c
index 1a54f1ffaadb..cb4242a69cd5 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -91,7 +91,7 @@ static unsigned int of_bus_default_get_flags(const __be32 *addr)
91 return IORESOURCE_MEM; 91 return IORESOURCE_MEM;
92} 92}
93 93
94#ifdef CONFIG_PCI 94#ifdef CONFIG_OF_ADDRESS_PCI
95/* 95/*
96 * PCI bus specific translator 96 * PCI bus specific translator
97 */ 97 */
@@ -166,7 +166,9 @@ static int of_bus_pci_translate(__be32 *addr, u64 offset, int na)
166{ 166{
167 return of_bus_default_translate(addr + 1, offset, na - 1); 167 return of_bus_default_translate(addr + 1, offset, na - 1);
168} 168}
169#endif /* CONFIG_OF_ADDRESS_PCI */
169 170
171#ifdef CONFIG_PCI
170const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, 172const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
171 unsigned int *flags) 173 unsigned int *flags)
172{ 174{
@@ -356,7 +358,7 @@ static unsigned int of_bus_isa_get_flags(const __be32 *addr)
356 */ 358 */
357 359
358static struct of_bus of_busses[] = { 360static struct of_bus of_busses[] = {
359#ifdef CONFIG_PCI 361#ifdef CONFIG_OF_ADDRESS_PCI
360 /* PCI */ 362 /* PCI */
361 { 363 {
362 .name = "pci", 364 .name = "pci",
@@ -367,7 +369,7 @@ static struct of_bus of_busses[] = {
367 .translate = of_bus_pci_translate, 369 .translate = of_bus_pci_translate,
368 .get_flags = of_bus_pci_get_flags, 370 .get_flags = of_bus_pci_get_flags,
369 }, 371 },
370#endif /* CONFIG_PCI */ 372#endif /* CONFIG_OF_ADDRESS_PCI */
371 /* ISA */ 373 /* ISA */
372 { 374 {
373 .name = "isa", 375 .name = "isa",
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 89e888a78899..48594f334151 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1511,11 +1511,31 @@ static int of_property_notify(int action, struct device_node *np,
1511#endif 1511#endif
1512 1512
1513/** 1513/**
1514 * __of_add_property - Add a property to a node without lock operations
1515 */
1516static int __of_add_property(struct device_node *np, struct property *prop)
1517{
1518 struct property **next;
1519
1520 prop->next = NULL;
1521 next = &np->properties;
1522 while (*next) {
1523 if (strcmp(prop->name, (*next)->name) == 0)
1524 /* duplicate ! don't insert it */
1525 return -EEXIST;
1526
1527 next = &(*next)->next;
1528 }
1529 *next = prop;
1530
1531 return 0;
1532}
1533
1534/**
1514 * of_add_property - Add a property to a node 1535 * of_add_property - Add a property to a node
1515 */ 1536 */
1516int of_add_property(struct device_node *np, struct property *prop) 1537int of_add_property(struct device_node *np, struct property *prop)
1517{ 1538{
1518 struct property **next;
1519 unsigned long flags; 1539 unsigned long flags;
1520 int rc; 1540 int rc;
1521 1541
@@ -1523,27 +1543,17 @@ int of_add_property(struct device_node *np, struct property *prop)
1523 if (rc) 1543 if (rc)
1524 return rc; 1544 return rc;
1525 1545
1526 prop->next = NULL;
1527 raw_spin_lock_irqsave(&devtree_lock, flags); 1546 raw_spin_lock_irqsave(&devtree_lock, flags);
1528 next = &np->properties; 1547 rc = __of_add_property(np, prop);
1529 while (*next) {
1530 if (strcmp(prop->name, (*next)->name) == 0) {
1531 /* duplicate ! don't insert it */
1532 raw_spin_unlock_irqrestore(&devtree_lock, flags);
1533 return -1;
1534 }
1535 next = &(*next)->next;
1536 }
1537 *next = prop;
1538 raw_spin_unlock_irqrestore(&devtree_lock, flags); 1548 raw_spin_unlock_irqrestore(&devtree_lock, flags);
1539 1549
1540#ifdef CONFIG_PROC_DEVICETREE 1550#ifdef CONFIG_PROC_DEVICETREE
1541 /* try to add to proc as well if it was initialized */ 1551 /* try to add to proc as well if it was initialized */
1542 if (np->pde) 1552 if (!rc && np->pde)
1543 proc_device_tree_add_prop(np->pde, prop); 1553 proc_device_tree_add_prop(np->pde, prop);
1544#endif /* CONFIG_PROC_DEVICETREE */ 1554#endif /* CONFIG_PROC_DEVICETREE */
1545 1555
1546 return 0; 1556 return rc;
1547} 1557}
1548 1558
1549/** 1559/**
@@ -1639,7 +1649,7 @@ int of_update_property(struct device_node *np, struct property *newprop)
1639 1649
1640#ifdef CONFIG_PROC_DEVICETREE 1650#ifdef CONFIG_PROC_DEVICETREE
1641 /* try to add to proc as well if it was initialized */ 1651 /* try to add to proc as well if it was initialized */
1642 if (np->pde) 1652 if (!rc && np->pde)
1643 proc_device_tree_update_prop(np->pde, newprop, oldprop); 1653 proc_device_tree_update_prop(np->pde, newprop, oldprop);
1644#endif /* CONFIG_PROC_DEVICETREE */ 1654#endif /* CONFIG_PROC_DEVICETREE */
1645 1655
@@ -1710,6 +1720,7 @@ int of_attach_node(struct device_node *np)
1710 np->allnext = of_allnodes; 1720 np->allnext = of_allnodes;
1711 np->parent->child = np; 1721 np->parent->child = np;
1712 of_allnodes = np; 1722 of_allnodes = np;
1723 of_node_clear_flag(np, OF_DETACHED);
1713 raw_spin_unlock_irqrestore(&devtree_lock, flags); 1724 raw_spin_unlock_irqrestore(&devtree_lock, flags);
1714 1725
1715 of_add_proc_dt_entry(np); 1726 of_add_proc_dt_entry(np);
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index a208a457558c..a3df3428dac6 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -13,8 +13,8 @@
13 13
14/** 14/**
15 * It maps 'enum phy_interface_t' found in include/linux/phy.h 15 * It maps 'enum phy_interface_t' found in include/linux/phy.h
16 * into the device tree binding of 'phy-mode', so that Ethernet 16 * into the device tree binding of 'phy-mode' or 'phy-connection-type',
17 * device driver can get phy interface from device tree. 17 * so that Ethernet device driver can get phy interface from device tree.
18 */ 18 */
19static const char *phy_modes[] = { 19static const char *phy_modes[] = {
20 [PHY_INTERFACE_MODE_NA] = "", 20 [PHY_INTERFACE_MODE_NA] = "",
@@ -37,8 +37,9 @@ static const char *phy_modes[] = {
37 * of_get_phy_mode - Get phy mode for given device_node 37 * of_get_phy_mode - Get phy mode for given device_node
38 * @np: Pointer to the given device_node 38 * @np: Pointer to the given device_node
39 * 39 *
40 * The function gets phy interface string from property 'phy-mode', 40 * The function gets phy interface string from property 'phy-mode' or
41 * and return its index in phy_modes table, or errno in error case. 41 * 'phy-connection-type', and return its index in phy_modes table, or errno in
42 * error case.
42 */ 43 */
43int of_get_phy_mode(struct device_node *np) 44int of_get_phy_mode(struct device_node *np)
44{ 45{
@@ -47,6 +48,8 @@ int of_get_phy_mode(struct device_node *np)
47 48
48 err = of_property_read_string(np, "phy-mode", &pm); 49 err = of_property_read_string(np, "phy-mode", &pm);
49 if (err < 0) 50 if (err < 0)
51 err = of_property_read_string(np, "phy-connection-type", &pm);
52 if (err < 0)
50 return err; 53 return err;
51 54
52 for (i = 0; i < ARRAY_SIZE(phy_modes); i++) 55 for (i = 0; i < ARRAY_SIZE(phy_modes); i++)