[PATCH linux dev-4.13 2/2] drivers: occ: Create hwmon platform device directly

Eddie James eajames at linux.vnet.ibm.com
Wed Feb 21 08:27:39 AEDT 2018


Previously, the OCC driver parses the device tree and creates platform
devices for each child node found there. This was used to probe the
OCC hwmon devices. However, this doesn't make sense since hmwon isn't a
device. Therefore, just directly create a platform device for each OCC
for the hwmon driver to probe.

Signed-off-by: Eddie James <eajames at linux.vnet.ibm.com>
---
 drivers/fsi/fsi-occ.c      | 29 ++++++++++++-----------------
 drivers/hwmon/occ/p9_sbe.c |  6 ------
 2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c
index 1713550..8a1d0a1 100644
--- a/drivers/fsi/fsi-occ.c
+++ b/drivers/fsi/fsi-occ.c
@@ -21,7 +21,6 @@
 #include <linux/mutex.h>
 #include <linux/fsi-occ.h>
 #include <linux/of.h>
-#include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
@@ -737,24 +736,24 @@ void occ_drv_release(struct occ_client *client)
 
 static int occ_unregister_child(struct device *dev, void *data)
 {
-	struct platform_device *child = to_platform_device(dev);
+	struct platform_device *hwmon_dev = to_platform_device(dev);
 
-	of_device_unregister(child);
-	if (dev->of_node)
-		of_node_clear_flag(dev->of_node, OF_POPULATED);
+	platform_device_unregister(hwmon_dev);
 
 	return 0;
 }
 
 static int occ_probe(struct platform_device *pdev)
 {
-	int rc, child_idx = 0;
+	int rc;
 	u32 reg;
 	struct occ *occ;
-	struct device_node *np;
-	struct platform_device *child;
+	struct platform_device *hwmon_dev;
 	struct device *dev = &pdev->dev;
-	char child_name[32];
+	struct platform_device_info hwmon_dev_info = {
+		.parent = dev,
+		.name = "occ-hwmon",
+	};
 
 	occ = devm_kzalloc(dev, sizeof(*occ), GFP_KERNEL);
 	if (!occ)
@@ -796,14 +795,10 @@ static int occ_probe(struct platform_device *pdev)
 		return rc;
 	}
 
-	/* create platform devs for dts child nodes (hwmon, etc) */
-	for_each_available_child_of_node(dev->of_node, np) {
-		snprintf(child_name, sizeof(child_name), "occ%d-dev%d",
-			 occ->idx, child_idx++);
-		child = of_platform_device_create(np, child_name, dev);
-		if (!child)
-			dev_warn(dev, "failed to create child node dev\n");
-	}
+	hwmon_dev_info.id = occ->idx;
+	hwmon_dev = platform_device_register_full(&hwmon_dev_info);
+	if (!hwmon_dev)
+		dev_warn(dev, "failed to create hwmon device\n");
 
 	platform_set_drvdata(pdev, occ);
 
diff --git a/drivers/hwmon/occ/p9_sbe.c b/drivers/hwmon/occ/p9_sbe.c
index 7dbe4d5..451a393 100644
--- a/drivers/hwmon/occ/p9_sbe.c
+++ b/drivers/hwmon/occ/p9_sbe.c
@@ -140,15 +140,9 @@ static int p9_sbe_occ_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct of_device_id p9_sbe_occ_of_match[] = {
-	{ .compatible = "ibm,p9-occ-hwmon" },
-	{ },
-};
-
 static struct platform_driver p9_sbe_occ_driver = {
 	.driver = {
 		.name = "occ-hwmon",
-		.of_match_table	= p9_sbe_occ_of_match,
 	},
 	.probe	= p9_sbe_occ_probe,
 	.remove = p9_sbe_occ_remove,
-- 
1.8.3.1



More information about the openbmc mailing list