[PATCH 1/2] of/platform: dynamic: Use of_platform_bus_create() to create devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



of_platform_notify() requires parents to have OF_POPULATED_BUS to be set
(which is correct way to verify healthy platform bus), but uses
of_platform_device_create() to create devices, which never sets the above
flag. Therefore it's not possible to add platform buses via overlays.

Use of_platform_bus_create(), which is used in non-overlay case to populate
both buses and devices.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@xxxxxxxxx>
Cc: Rob Herring <robh+dt@xxxxxxxxxx>
Cc: Frank Rowand <frowand.list@xxxxxxxxx>
Cc: devicetree@xxxxxxxxxxxxxxx
Cc: Grant Likely <grant.likely@xxxxxxxxxx>
Cc: Pantelis Antoniou <pantelis.antoniou@xxxxxxxxxxxx>
---
 drivers/of/platform.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index b8064bc2b6eb..35de1fc59fa6 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -578,6 +578,7 @@ static int of_platform_notify(struct notifier_block *nb,
 	struct of_reconfig_data *rd = arg;
 	struct platform_device *pdev_parent, *pdev;
 	bool children_left;
+	int ret;
 
 	switch (of_reconfig_get_state_change(action, rd)) {
 	case OF_RECONFIG_CHANGE_ADD:
@@ -591,15 +592,15 @@ static int of_platform_notify(struct notifier_block *nb,
 
 		/* pdev_parent may be NULL when no bus platform device */
 		pdev_parent = of_find_device_by_node(rd->dn->parent);
-		pdev = of_platform_device_create(rd->dn, NULL,
-				pdev_parent ? &pdev_parent->dev : NULL);
+		ret = of_platform_bus_create(rd->dn, of_default_bus_match_table,
+					     NULL, pdev_parent ?
+					     &pdev_parent->dev : NULL, true);
 		of_dev_put(pdev_parent);
 
-		if (pdev == NULL) {
+		if (ret) {
 			pr_err("%s: failed to create for '%s'\n",
 					__func__, rd->dn->full_name);
-			/* of_platform_device_create tosses the error code */
-			return notifier_from_errno(-EINVAL);
+			return notifier_from_errno(ret);
 		}
 		break;
 
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux