Browse Source

icnss2: reject icnss2 driver loading if no matching dt node

On some platforms, those with all of icnss, cnss
and the corresponding wlan drivers being present, but
only one dt node for wlan device, we only need one
platform driver which is compatible with the dt node.

To achieve this, return '-ENODEV' on icnss driver loading
if there is no matching dt node, just as cnss2 does.

This change can also fix the issue as below:
Background: icnss2 returns '-EAGAIN' when wlan driver
register request comes too early, to trigger the retry
mechanism in wlan driver.

Considering a device with drivers and dt node as
mentioned upon, and a wlan driver is trying to
register itself in icnss2 driver. But it will
definitely fail because icnss2 has not been probed
(due to no compatible dt node) and retry for up to
50 times with a 100ms interval due to the return
value '-EAGAIN'. This delays android bootup.

With this fix applied, wlan driver loading will fail
before registering itself to platform driver because
it depends on icnss2 that failed to load.

Change-Id: I8dfe8821c0c8ec45e7e55913de26060a32ffce82
CRs-Fixed: 3867504
Yu Wang 8 months ago
parent
commit
08d917032c
1 changed files with 24 additions and 0 deletions
  1. 24 0
      icnss2/main.c

+ 24 - 0
icnss2/main.c

@@ -5275,8 +5275,32 @@ static struct platform_driver icnss_driver = {
 	},
 };
 
+/**
+ * icnss_has_valid_dt_node() - Check if valid device tree node present
+ *
+ * Valid device tree node means a node with "compatible" property from the
+ * device match table and "status" property is not disabled.
+ *
+ * Return: true if valid device tree node found, false if not found
+ */
+static bool icnss_has_valid_dt_node(void)
+{
+	struct device_node *dn = NULL;
+
+	for_each_matching_node(dn, icnss_dt_match) {
+		if (of_device_is_available(dn))
+			return true;
+	}
+
+	icnss_pr_info("No valid icnss2 dtsi entry\n");
+	return false;
+}
+
 static int __init icnss_initialize(void)
 {
+	if (!icnss_has_valid_dt_node())
+		return -ENODEV;
+
 	icnss_debug_init();
 	return platform_driver_register(&icnss_driver);
 }