summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/of_platform.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2006-11-21 14:56:37 +1100
committerPaul Mackerras <paulus@samba.org>2006-12-04 20:40:17 +1100
commit9309180f11f0107c9858a61a1ac2b04518a91080 (patch)
tree626a5250c1d337788b2b6a2a051897b06b71483f /arch/powerpc/kernel/of_platform.c
parent974a76f51355d22f4f63d83d6bb1ccecd019ec58 (diff)
[POWERPC] powerpc: Workaround for of_platform without "reg" nor "dcr-reg"
Devices with no "reg" nor "dcr-reg" property are given a bus_id which is the node name alone. This means that if more than one such device with the same names are present in the system, sysfs will have collisions when creating the symlinks and will fail registering the devices. This works around that problem by assigning successive numbers to such devices. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/of_platform.c')
-rw-r--r--arch/powerpc/kernel/of_platform.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c
index 6029543c1b5..b3189d0161b 100644
--- a/arch/powerpc/kernel/of_platform.c
+++ b/arch/powerpc/kernel/of_platform.c
@@ -27,6 +27,8 @@
#include <asm/topology.h>
#include <asm/pci-bridge.h>
#include <asm/ppc-pci.h>
+#include <asm/atomic.h>
+
/*
* The list of OF IDs below is used for matching bus types in the
@@ -51,6 +53,8 @@ static struct of_device_id of_default_bus_ids[] = {
{},
};
+static atomic_t bus_no_reg_magic;
+
/*
*
* OF platform device type definition & base infrastructure
@@ -165,6 +169,7 @@ static void of_platform_make_bus_id(struct of_device *dev)
char *name = dev->dev.bus_id;
const u32 *reg;
u64 addr;
+ long magic;
/*
* If it's a DCR based device, use 'd' for native DCRs
@@ -203,9 +208,11 @@ static void of_platform_make_bus_id(struct of_device *dev)
}
/*
- * No BusID, use the node name and pray
+ * No BusID, use the node name and add a globally incremented
+ * counter (and pray...)
*/
- snprintf(name, BUS_ID_SIZE, "%s", node->name);
+ magic = atomic_add_return(1, &bus_no_reg_magic);
+ snprintf(name, BUS_ID_SIZE, "%s.%d", node->name, magic - 1);
}
struct of_device* of_platform_device_create(struct device_node *np,