linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev list <linuxppc-dev@ozlabs.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
Subject: [PATCH] powerpc: Workaround for of_platform without "reg" nor "dcr-reg"
Date: Tue, 21 Nov 2006 14:56:37 +1100	[thread overview]
Message-ID: <1164081397.8207.8.camel@localhost.localdomain> (raw)

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>
---

Paul: This is 2.6.20 material, not 2.6.19

Index: linux-cell/arch/powerpc/kernel/of_platform.c
===================================================================
--- linux-cell.orig/arch/powerpc/kernel/of_platform.c	2006-11-21 11:01:12.000000000 +1100
+++ linux-cell/arch/powerpc/kernel/of_platform.c	2006-11-21 14:07:06.000000000 +1100
@@ -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_bu
 	{},
 };
 
+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(stru
 	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(stru
 	}
 
 	/*
-	 * 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,

                 reply	other threads:[~2006-11-21  3:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1164081397.8207.8.camel@localhost.localdomain \
    --to=benh@kernel.crashing.org \
    --cc=Jens.Osterkamp@de.ibm.com \
    --cc=arnd@arndb.de \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).