[PATCH] Addressed some issues related to multiple cards with one driver

Brian Cavagnolo brian at cozybit.com
Thu Jul 13 17:07:22 EDT 2006


Made remove_card function use per-card wlan_private struct instead of
single global one.

Made one proc entry per card instead of one global proc entry.

P.S.  I'm an engineer for cozybit helping with the libertas
integration.  Please let me know if I'm following the right procedure
to submit patches.

Signed-off-by: Brian Cavagnolo <brian at cozybit.com>
---
 drivers/net/wireless/libertas/if_usb.c    |   11 +++++++
 drivers/net/wireless/libertas/sbi.h       |    1 +
 drivers/net/wireless/libertas/wlan_decl.h |    2 +
 drivers/net/wireless/libertas/wlan_main.c |   24 +++++++++------
 drivers/net/wireless/libertas/wlan_proc.c |   45 ++++++++++++++++++++++++-----
 5 files changed, 66 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/libertas/if_usb.c
b/drivers/net/wireless/libertas/if_usb.c
index b815569..23c5fd5 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -1026,6 +1026,17 @@ int libertas_sbi_disable_host_int(wlan_p
 	return WLAN_STATUS_SUCCESS;
 }

+/**
+ *  @brief Given a usb_card_rec return its wlan_private
+ *  @param card		pointer to a usb_card_rec
+ *  @return 	   	pointer to wlan_private
+ */
+wlan_private *libertas_sbi_get_priv(void *card)
+{
+	struct usb_card_rec *cardp = (struct usb_card_rec *)card;
+	return (wlan_private *)cardp->priv;
+}
+
 #ifdef ENABLE_PM
 /**
  *  @brief This is a dummy function
diff --git a/drivers/net/wireless/libertas/sbi.h
b/drivers/net/wireless/libertas/sbi.h
index 4ad7aaf..8c8c3f8 100644
--- a/drivers/net/wireless/libertas/sbi.h
+++ b/drivers/net/wireless/libertas/sbi.h
@@ -104,6 +104,7 @@ int libertas_sbi_read_event_cause(wlan_p
 int libertas_sbi_reenable_host_interrupt(wlan_private *, u8);
 int libertas_sbi_host_to_card(wlan_private * priv, u8 type, u8 *
payload, u16 nb);
 int libertas_sbi_enable_host_int(wlan_private *);
+wlan_private *libertas_sbi_get_priv(void *card);

 #ifdef ENABLE_PM
 int libertas_sbi_suspend(wlan_private *);
diff --git a/drivers/net/wireless/libertas/wlan_decl.h
b/drivers/net/wireless/libertas/wlan_decl.h
index b3f42f8..6af060d 100644
--- a/drivers/net/wireless/libertas/wlan_decl.h
+++ b/drivers/net/wireless/libertas/wlan_decl.h
@@ -73,6 +73,8 @@ void libertas_get_version(wlan_adapter *
 int libertas_upload_rx_packet(wlan_private * priv, struct sk_buff *skb);

 /** The proc fs interface */
+void libertas_proc_init(void);
+void libertas_proc_cleanup(void);
 void libertas_proc_entry(wlan_private * priv, struct net_device *dev);
 void libertas_proc_remove(wlan_private * priv);
 void libertas_debug_entry(wlan_private * priv, struct net_device *dev);
diff --git a/drivers/net/wireless/libertas/wlan_main.c
b/drivers/net/wireless/libertas/wlan_main.c
index 5083697..2a680e3 100644
--- a/drivers/net/wireless/libertas/wlan_main.c
+++ b/drivers/net/wireless/libertas/wlan_main.c
@@ -867,15 +867,6 @@ #endif				/* REASSOCIATION */
 		goto err_registerdev;
 	}

-	PRINTM(WARN, "%s: Marvell Wlan 802.11 Adapter "
-	       "revision 0x%02X at IRQ %i\n", dev->name,
-	       priv->adapter->chip_rev, dev->irq);
-
-	libertas_proc_entry(priv, dev);
-#ifdef PROC_DEBUG
-	libertas_debug_entry(priv, dev);
-#endif
-
 	/* Get the CIS Table */
 	libertas_sbi_get_cis_info(priv);

@@ -890,6 +881,15 @@ #endif
 		goto err_init_fw;
 	}

+	PRINTM(WARN, "%s: Marvell Wlan 802.11 Adapter "
+	       "revision 0x%02X at IRQ %i\n", dev->name,
+	       priv->adapter->chip_rev, dev->irq);
+
+	libertas_proc_entry(priv, dev);
+#ifdef PROC_DEBUG
+	libertas_debug_entry(priv, dev);
+#endif
+
 	LEAVE();
 	return priv;

@@ -922,7 +922,7 @@ #endif				/* REASSOCIATION */
  */
 static int wlan_remove_card(void *card)
 {
-	wlan_private *priv = wlanpriv;
+	wlan_private *priv = libertas_sbi_get_priv(card);
 	wlan_adapter *Adapter;
 	struct net_device *dev;
 	union iwreq_data wrqu;
@@ -1127,6 +1127,8 @@ static int wlan_init_module(void)

 	ENTER();

+	libertas_proc_init();
+
 	if (libertas_fw_name == NULL) {
 		libertas_fw_name = default_fw_name;
 	}
@@ -1153,6 +1155,8 @@ static void wlan_cleanup_module(void)

 	libertas_sbi_unregister();

+	libertas_proc_cleanup();
+
 	LEAVE();
 }

diff --git a/drivers/net/wireless/libertas/wlan_proc.c
b/drivers/net/wireless/libertas/wlan_proc.c
index 282a147..00336e4 100644
--- a/drivers/net/wireless/libertas/wlan_proc.c
+++ b/drivers/net/wireless/libertas/wlan_proc.c
@@ -43,6 +43,8 @@ static char *szStates[] = {
 	"Disconnected"
 };

+static struct proc_dir_entry *libertas_proc_base = NULL;
+
 /**
  *  @brief proc read function
  *
@@ -126,7 +128,36 @@ #endif
 }

 /**
- *  @brief create wlan proc file
+ *  @brief create wlan base dir in /proc/net
+ *
+ *  @return 	   N/A
+ */
+void libertas_proc_init(void)
+{
+#ifdef CONFIG_PROC_FS
+	if (!libertas_proc_base) {
+		PRINTM(INFO, "Creating Proc Base\n");
+		libertas_proc_base = proc_mkdir("wlan", proc_net);
+	}
+#endif
+}
+
+/**
+ *  @brief remove wlan based dir in /proc/net
+ *
+ *  @return 	   N/A
+ */
+void libertas_proc_cleanup(void)
+{
+#ifdef CONFIG_PROC_FS
+	if (libertas_proc_base) {
+		remove_proc_entry("wlan", proc_net);
+	}
+#endif
+}
+
+/**
+ *  @brief add card entry to /proc/net
  *
  *  @param priv	   pointer wlan_private
  *  @param dev     pointer net_device
@@ -135,15 +166,15 @@ #endif
 void libertas_proc_entry(wlan_private * priv, struct net_device *dev)
 {

-#ifdef	CONFIG_PROC_FS
-	PRINTM(INFO, "Creating Proc Interface\n");
+#ifdef	CONFIG_PROC_FS
+	PRINTM(INFO, "Adding Proc Dev Entry For %s\n", dev->name);

 	if (!priv->proc_entry) {
-		priv->proc_entry = proc_mkdir("wlan", proc_net);
+		priv->proc_entry = libertas_proc_base;

 		if (priv->proc_entry) {
 			priv->proc_dev = create_proc_read_entry
-			    ("info", 0, priv->proc_entry, wlan_proc_read, dev);
+			    (dev->name, 0, priv->proc_entry, wlan_proc_read, dev);
 		}
 	}
 #endif
@@ -159,7 +190,7 @@ void libertas_proc_remove(wlan_private *
 {
 #ifdef CONFIG_PROC_FS
 	if (priv->proc_entry)
-		remove_proc_entry("info", priv->proc_entry);
-	remove_proc_entry("wlan", proc_net);
+		remove_proc_entry(priv->wlan_dev.netdev->name,
+				  priv->proc_entry);
 #endif
 }
-- 
1.4.0



More information about the libertas-dev mailing list