Messages in this thread Patch in this message |  | | Date | Fri, 1 Nov 2013 14:59:25 +1100 | From | NeilBrown <> | Subject | Strange location and name for platform devices when device-tree is used. |
| |
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@kernel.crashing.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;[unhandled content-type:application/pgp-signature]
|  |