Skip to contentSkip to conversation

OCC: Fixup occ, occ-hwmon, and dts

PATCH In review Eddie James 2 participants 5 messages Feb 20, 2018 – Feb 23, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover OCC: Fixup occ, occ-hwmon, and dts

This series includes a couple of minor fixes to the get OCC driver stack working correctly in the 4.13 tree.

Eddie James (2):
Revert "ARM: dts: power9-cfam: Update OCC hwmon compatible"
drivers: occ: Create hwmon platform device directly

 arch/arm/boot/dts/ibm-power9-cfam.dtsi |  5 +++--
 drivers/fsi/fsi-occ.c                  | 29 ++++++++++++-----------------
 drivers/hwmon/occ/p9_sbe.c             |  6 ------
 3 files changed, 15 insertions(+), 25 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/2 Revert "ARM: dts: power9-cfam: Update OCC hwmon compatible"

This reverts commit f370fa626a127aec50801dafcd595a2b5a47e482. The dts properties were correct for the OCC driver.

---
 arch/arm/boot/dts/ibm-power9-cfam.dtsi | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/boot/dts/ibm-power9-cfam.dtsi +3 -2
index e0e738f..c110417 100644
@@ -113,7 +113,7 @@
 			#size-cells = <0>;
 
 			occ@1 {
-				compatible = "ibm,p9-occ-hwmon";
+				compatible = "ibm,p9-occ";
 				reg = <1>;
 			};
 		};
@@ -205,7 +205,8 @@
 					#size-cells = <0>;
 
 					occ@2 {
-						compatible = "ibm,p9-occ-hwmon";
+						compatible =
+							"ibm,p9-occ";
 						reg = <2>;
 					};
 				};
Signature · 1 line
1.8.3.1
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH linux dev-4.13 1/2] Revert "ARM: dts: power9-cfam: Update OCC hwmon compatible"

Quoted 21 lines · Eddie James

This reverts commit f370fa626a127aec50801dafcd595a2b5a47e482. The dts properties were correct for the OCC driver.

---
 arch/arm/boot/dts/ibm-power9-cfam.dtsi | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/boot/dts/ renamed from arch/arm/boot/dts/ibm-power9-cfam.dtsi +0 -0

ibm-power9-cfam.dtsi
index e0e738f..c110417 100644

arch/arm/boot/dts/ibm-power9-cfam.dtsi +1 -1
@@ -113,7 +113,7 @@
 			#size-cells = <0>;
 
 			occ@1 {
-				compatible = "ibm,p9-occ-hwmon";
+				compatible = "ibm,p9-occ";
 				reg = <1>;
 			};
 		};

arch/arm/boot/dts/ibm-power9-cfam.dtsi line 209

Quoted 6 lines
arch/arm/boot/dts/ibm-power9-cfam.dtsi +2 -1
@@ -205,7 +205,8 @@
 					#size-cells = <0>;
 
 					occ@2 {
-						compatible = "ibm,p9-occ-hwmon";
+						compatible =
+							"ibm,p9-occ";

A bit petty, but can we fix the whitespace here? Maybe Joel can fix it when it's applied.

Otherwise,

Cheers,

Andrew

Quoted 6 lines
arch/arm/boot/dts/ibm-power9-cfam.dtsi +0 -0
 						reg = <2>;
 					};
 				};
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 2/2 drivers: occ: Create hwmon platform device directly

In reply to Eddie James

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.

---
 drivers/fsi/fsi-occ.c      | 29 ++++++++++++-----------------
 drivers/hwmon/occ/p9_sbe.c |  6 ------
 2 files changed, 12 insertions(+), 23 deletions(-)
drivers/fsi/fsi-occ.c +12 -17
index 1713550..8a1d0a1 100644
@@ -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);
 
drivers/hwmon/occ/p9_sbe.c +0 -6
index 7dbe4d5..451a393 100644
@@ -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,
Signature · 1 line
1.8.3.1
Acked-by on v1 2/2
#4 lore raw

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

Quoted 7 lines · Eddie James

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.

This reduces our dependence on bad devicetree practices, so:

Quoted 92 lines
---
 drivers/fsi/fsi-occ.c      | 29 ++++++++++++-----------------
 drivers/hwmon/occ/p9_sbe.c |  6 ------
 2 files changed, 12 insertions(+), 23 deletions(-)
drivers/fsi/fsi-occ.c +12 -17
index 1713550..8a1d0a1 100644
@@ -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);
 
drivers/hwmon/occ/p9_sbe.c +0 -6
index 7dbe4d5..451a393 100644
@@ -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,
Signature · 1 line
1.8.3.1
Signature · 2 lines
  Andrew Jeffery
  [email protected]