Skip to contentSkip to conversation

brcm80211: smac: remove firmware requests from init_module syscall

RFC Larry Finger 1 participant 1 message Feb 20, 2012 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 10 lines · Arend van Spriel

As indicated in [1] on netdev mailing list drivers should not block on the init_module() syscall. This patch defers the actual driver registration to a workqueue so the init_module() syscall can complete without delay.

[1] http://article.gmane.org/gmane.linux.network/217729/

Quoted 6 lines

---
Here is the patch I came up with to avoid udev blocking on init_module(). It is pretty straightforward, but maybe I am overlooking things here. So feel free to comment.

Gr. AvS

Arend,

Despite the simplicity, this patch looks right to me. As a side benefit, I learned about the DECLARE_WORK macro. Handy for this purpose.

Larry

Quoted 40 lines
---
  .../net/wireless/brcm80211/brcmsmac/mac80211_if.c  |   17 ++++++++++-------
  1 files changed, 10 insertions(+), 7 deletions(-)
drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +10 -7
index fec0f10..fe73451 100644
@@ -1173,21 +1173,24 @@ static struct bcma_driver brcms_bcma_driver = {
   * and if so, performs a brcms_attach() on it.
   *
   */
-static int __init brcms_module_init(void)
+static void brcms_driver_init(struct work_struct *work)
  {
  	int error = -ENODEV;
 
+	error = bcma_driver_register(&brcms_bcma_driver);
+	pr_err("%s: register returned %d\n", __func__, error);
+}
+
+DECLARE_WORK(brcms_driver_work, brcms_driver_init);
+
+static int __init brcms_module_init(void)
+{
  #ifdef DEBUG
  	if (msglevel != 0xdeadbeef)
  		brcm_msg_level = msglevel;
  #endif				/* DEBUG */
 
-	error = bcma_driver_register(&brcms_bcma_driver);
-	pr_err("%s: register returned %d\n", __func__, error);
-	if (!error)
-		return 0;
-
-	return error;
+	return schedule_work(&brcms_driver_work);
  }
 
  /**