devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Strange location and name for platform  devices when device-tree is used.
@ 2013-11-01  3:59 NeilBrown
  2013-11-01  4:22 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 20+ messages in thread
From: NeilBrown @ 2013-11-01  3:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Grant Likely, Rob Herring,
	Benjamin Herrenschmidt
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, lkml

[-- Attachment #1: Type: text/plain, Size: 2560 bytes --]



My ARM board has a collection of "platform devices".

When I build a kernel using a board file, these platform devices are named
with exactly the names I give them, and they appear in sysfs under
   /sys/devices/platform

all as you might expect.

When I build a kernel using device-tree (and trying to follow the established
patterns for the dts file),  these platform devices appear directly in
"/sys/devices" (not in the "platform" subdirectory) and  they don't have the
names I give them, but instead a sequential number is appended.

The former makes /sys/devices look very untidy.  It can presumably be fixed by
changing of_platform_populate() to replace a parent for 'NULL' with
'platform_bus' as the patch below demonstrates.  Is there any chance that is
correct? (It seems to work, but for all I know it might break something else).


The latter is caused by of_device_make_bus_id():

	/*
	 * No BusID, use the node name and add a globally incremented
	 * counter (and pray...)
	 */
	magic = atomic_add_return(1, &bus_no_reg_magic);
	dev_set_name(dev, "%s.%d", node->name, magic - 1);


This call to prayer dates back to:

commit 9309180f11f0107c9858a61a1ac2b04518a91080
Author: Benjamin Herrenschmidt <benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
Date:   Tue Nov 21 14:56:37 2006 +1100

    [POWERPC] powerpc: Workaround for of_platform without "reg" nor "dcr-reg"

and I wonder how relevant it still is in this context.  As platform devices
are all in the root of the device-tree and hence are siblings, they must have
unique names in the device-tree and  so the platform devices created from
them will also have unique names -- won't they?

Any help understanding and/or fixing this discrepancy greatly appreciated.

The change of name is particularly annoying to me because one of my platform
devices is a pwm_bl.c backlight.  With a boardfile I
get /sys/class/pwm_backlight.  With devicetree the best I can get
is /sys/class/pwm_backlight.23 (or similar).  It would be really nice to have
a more stable and sensible name here.

Thanks,
NeilBrown

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 9b439ac63d8e..af3ef3513cb0 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -476,6 +476,9 @@ int of_platform_populate(struct device_node *root,
 	struct device_node *child;
 	int rc = 0;
 
+	if (parent == NULL)
+		parent = &platform_bus;
+
 	root = root ? of_node_get(root) : of_find_node_by_path("/");
 	if (!root)
 		return -EINVAL;

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2013-11-15  7:44 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-01  3:59 Strange location and name for platform devices when device-tree is used NeilBrown
2013-11-01  4:22 ` Benjamin Herrenschmidt
2013-11-01  4:27   ` Benjamin Herrenschmidt
2013-11-01  5:03     ` NeilBrown
2013-11-01  5:08       ` Benjamin Herrenschmidt
2013-11-01 18:04         ` Grant Likely
2013-11-01 20:33           ` Benjamin Herrenschmidt
2013-11-15  7:37             ` Grant Likely
     [not found]           ` <20131101180459.81793C40A28-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-11-01 20:48             ` Greg Kroah-Hartman
2013-11-01 20:47         ` Greg Kroah-Hartman
     [not found]           ` <20131101204749.GA19662-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2013-11-01 23:09             ` Benjamin Herrenschmidt
2013-11-02 15:58               ` Greg Kroah-Hartman
     [not found]                 ` <20131102155824.GG23938-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2013-11-02 20:22                   ` Benjamin Herrenschmidt
2013-11-02 20:40                     ` Greg Kroah-Hartman
     [not found]                       ` <20131102204021.GA13994-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2013-11-03 21:12                         ` Benjamin Herrenschmidt
2013-11-03 21:09                 ` NeilBrown
2013-11-01 23:10             ` Benjamin Herrenschmidt
2013-11-01 23:45               ` NeilBrown
     [not found]                 ` <20131102104505.34105cbb-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2013-11-04  8:56                   ` Thierry Reding
2013-11-15  7:44                 ` Grant Likely

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