Skip to contentSkip to conversation

drivers: firmware: xilinx: Minor fixes

PATCH New Jolly Shah 1 participant 4 messages Sep 10, 2018 Arm/Zynq architecture

lore
Share & tools
lore

Jolly Shah

author
#0 lore raw

cover drivers: firmware: xilinx: Minor fixes

This patchset is created on top of commit bca7067d2d4e91f58162b07d73cd94e20437b4f6 from below git repository:
https://github.com/Xilinx/linux-xlnx.git tags/zynqmp-soc-for-v4.20

It contains 1 pending patch from v11 patchset and 2 patches to fix minor review comments received from Olof Johansson.

Rajan Vaja (3):
firmware: xilinx: Replace init call with probe method
firmware: xilinx: Move declaration of qdata to top of the function
firmware: xilinx: Replace if/else with switch case

 drivers/firmware/xilinx/zynqmp-debug.c | 15 ++++----
 drivers/firmware/xilinx/zynqmp.c       | 63 ++++++++++------------------------
 2 files changed, 26 insertions(+), 52 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/3 firmware: xilinx: Replace init call with probe method

From: Rajan Vaja <[email protected]>

As of all of child of ZynqMP firmware are platform driver, there is no need of init call in firmware driver. Earlier clock driver was init method so firmware driver had to use init call to make sure firmware init is done in early stage.

---
 drivers/firmware/xilinx/zynqmp.c | 63 ++++++++++++----------------------------
 1 file changed, 18 insertions(+), 45 deletions(-)
drivers/firmware/xilinx/zynqmp.c +18 -45
index 7ccedf0..ce6c746 100644
@@ -476,50 +476,17 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_get_eemi_ops);
 static int zynqmp_firmware_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-
-	return of_platform_populate(dev->of_node, NULL, NULL, dev);
-}
-
-static const struct of_device_id zynqmp_firmware_of_match[] = {
-	{.compatible = "xlnx,zynqmp-firmware"},
-	{},
-};
-MODULE_DEVICE_TABLE(of, zynqmp_firmware_of_match);
-
-static struct platform_driver zynqmp_firmware_driver = {
-	.driver = {
-		.name = "zynqmp_firmware",
-		.of_match_table = zynqmp_firmware_of_match,
-	},
-	.probe = zynqmp_firmware_probe,
-};
-module_platform_driver(zynqmp_firmware_driver);
-
-static int __init zynqmp_plat_init(void)
-{
-	int ret;
 	struct device_node *np;
+	int ret;
 
 	np = of_find_compatible_node(NULL, NULL, "xlnx,zynqmp");
 	if (!np)
 		return 0;
 	of_node_put(np);
 
-	/*
-	 * We're running on a ZynqMP machine,
-	 * the zynqmp-firmware node is mandatory.
-	 */
-	np = of_find_compatible_node(NULL, NULL, "xlnx,zynqmp-firmware");
-	if (!np) {
-		pr_warn("%s: zynqmp-firmware node not found\n", __func__);
-		return -ENXIO;
-	}
-
-	ret = get_set_conduit_method(np);
-	if (ret) {
-		of_node_put(np);
+	ret = get_set_conduit_method(dev->of_node);
+	if (ret)
 		return ret;
-	}
 
 	/* Check PM API version number */
 	zynqmp_pm_get_api_version(&pm_api_version);
@@ -547,16 +514,22 @@ static int __init zynqmp_plat_init(void)
 	pr_info("%s Trustzone version v%d.%d\n", __func__,
 		pm_tz_version >> 16, pm_tz_version & 0xFFFF);
 
-	of_node_put(np);
+	zynqmp_pm_api_debugfs_init();
 
-	return ret;
+	return of_platform_populate(dev->of_node, NULL, NULL, dev);
 }
-early_initcall(zynqmp_plat_init);
 
-static int zynqmp_firmware_init(void)
-{
-	zynqmp_pm_api_debugfs_init();
+static const struct of_device_id zynqmp_firmware_of_match[] = {
+	{.compatible = "xlnx,zynqmp-firmware"},
+	{},
+};
+MODULE_DEVICE_TABLE(of, zynqmp_firmware_of_match);
 
-	return 0;
-}
-device_initcall(zynqmp_firmware_init);
+static struct platform_driver zynqmp_firmware_driver = {
+	.driver = {
+		.name = "zynqmp_firmware",
+		.of_match_table = zynqmp_firmware_of_match,
+	},
+	.probe = zynqmp_firmware_probe,
+};
+module_platform_driver(zynqmp_firmware_driver);
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 2/3 firmware: xilinx: Move declaration of qdata to top of the function

In reply to Jolly Shah

From: Rajan Vaja <[email protected]>

Move structure declaration from switch case to the top of function and drop the braces.

---
 drivers/firmware/xilinx/zynqmp-debug.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/firmware/xilinx/zynqmp-debug.c +1 -4
index 4532bd0..ecbd599 100644
@@ -87,6 +87,7 @@ static int process_api_request(u32 pm_id, u64 *pm_api_arg, u32 *pm_api_ret)
 	const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops();
 	u32 pm_api_version;
 	int ret;
+	struct zynqmp_pm_query_data qdata = {0};
 
 	if (!eemi_ops)
 		return -ENXIO;
@@ -107,9 +108,6 @@ static int process_api_request(u32 pm_id, u64 *pm_api_arg, u32 *pm_api_ret)
 				pm_api_ret[1]);
 		break;
 	case PM_QUERY_DATA:
-	{
-		struct zynqmp_pm_query_data qdata = {0};
-
 		qdata.qid = pm_api_arg[0];
 		qdata.arg1 = pm_api_arg[1];
 		qdata.arg2 = pm_api_arg[2];
@@ -131,7 +129,6 @@ static int process_api_request(u32 pm_id, u64 *pm_api_arg, u32 *pm_api_ret)
 				pm_api_ret[0], pm_api_ret[1],
 				pm_api_ret[2], pm_api_ret[3]);
 		break;
-	}
 	default:
 		sprintf(debugfs_buf, "Unsupported PM-API request\n");
 		ret = -EINVAL;
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH 3/3 firmware: xilinx: Replace if/else with switch case

In reply to Jolly Shah

From: Rajan Vaja <[email protected]>

There will be more query IDs in future so it is better to use switch case than if/else to avoid unnecessary condition checks.

---
 drivers/firmware/xilinx/zynqmp-debug.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/firmware/xilinx/zynqmp-debug.c +7 -3
index ecbd599..f12dabf 100644
@@ -117,17 +117,21 @@ static int process_api_request(u32 pm_id, u64 *pm_api_arg, u32 *pm_api_ret)
 		if (ret)
 			break;
 
-		if (qdata.qid == PM_QID_CLOCK_GET_NAME)
+		switch (qdata.qid) {
+		case PM_QID_CLOCK_GET_NAME:
 			sprintf(debugfs_buf, "Clock name = %s\n",
 				(char *)pm_api_ret);
-		else if (qdata.qid == PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS)
+			break;
+		case PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS:
 			sprintf(debugfs_buf, "Multiplier = %d, Divider = %d\n",
 				pm_api_ret[1], pm_api_ret[2]);
-		else
+			break;
+		default:
 			sprintf(debugfs_buf,
 				"data[0] = 0x%08x\ndata[1] = 0x%08x\n data[2] = 0x%08x\ndata[3] = 0x%08x\n",
 				pm_api_ret[0], pm_api_ret[1],
 				pm_api_ret[2], pm_api_ret[3]);
+		}
 		break;
 	default:
 		sprintf(debugfs_buf, "Unsupported PM-API request\n");
Signature · 1 line
2.7.4