From: NeilBrown <neilb-l3A5Bk7waGM@public.gmane.org>
To: Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Grant Likely
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
Benjamin Herrenschmidt
<benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
lkml <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Strange location and name for platform devices when device-tree is used.
Date: Fri, 1 Nov 2013 14:59:25 +1100 [thread overview]
Message-ID: <20131101145925.66e22f73@notabene.brown> (raw)
[-- 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 --]
next reply other threads:[~2013-11-01 3:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-01 3:59 NeilBrown [this message]
2013-11-01 4:22 ` Strange location and name for platform devices when device-tree is used 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
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=20131101145925.66e22f73@notabene.brown \
--to=neilb-l3a5bk7wagm@public.gmane.org \
--cc=benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.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).