[PATCH] libertas: indirect all hardware access via hw_XXXX functions
authorHolger Schurig <hs4233@mail.mn-solutions.de>
Fri, 25 May 2007 16:17:06 +0000 (12:17 -0400)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 11 Jun 2007 18:28:39 +0000 (14:28 -0400)
This functions makes all libertas_sbi_XXX functions static to the
if_usb.c file and renames them to if_usb_XXXX(). The get called from
other places of the source code via priv->hw_XXXX().

Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/libertas/cmd.c
drivers/net/wireless/libertas/cmdresp.c
drivers/net/wireless/libertas/decl.h
drivers/net/wireless/libertas/defs.h
drivers/net/wireless/libertas/dev.h
drivers/net/wireless/libertas/ethtool.c
drivers/net/wireless/libertas/fw.c
drivers/net/wireless/libertas/if_usb.c
drivers/net/wireless/libertas/main.c
drivers/net/wireless/libertas/sbi.h [deleted file]
drivers/net/wireless/libertas/tx.c

index c1d9902cac5da0e6a812f4f9a822c9bfcc949834..899b115f4c14575b8f31b15108a4008bb80a73ef 100644 (file)
@@ -6,7 +6,6 @@
 #include <net/iw_handler.h>
 #include "host.h"
 #include "hostcmd.h"
-#include "sbi.h"
 #include "decl.h"
 #include "defs.h"
 #include "dev.h"
@@ -1014,7 +1013,7 @@ static int DownloadcommandToStation(wlan_private * priv,
        cmdnode->cmdwaitqwoken = 0;
        cmdsize = cpu_to_le16(cmdsize);
 
-       ret = libertas_sbi_host_to_card(priv, MVMS_CMD, (u8 *) cmdptr, cmdsize);
+       ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmdptr, cmdsize);
 
        if (ret != 0) {
                lbs_deb_cmd("DNLD_CMD: Host to Card failed\n");
@@ -1841,7 +1840,7 @@ static int sendconfirmsleep(wlan_private * priv, u8 * cmdptr, u16 size)
 
        lbs_dbg_hex("SEND_SLEEPC_CMD: Sleep confirm command", cmdptr, size);
 
-       ret = libertas_sbi_host_to_card(priv, MVMS_CMD, cmdptr, size);
+       ret = priv->hw_host_to_card(priv, MVMS_CMD, cmdptr, size);
        priv->wlan_dev.dnld_sent = DNLD_RES_RECEIVED;
 
        spin_lock_irqsave(&adapter->driver_lock, flags);
index c8fce7bf6682d5c725eef52cbe3734980c08d0ec..1efdc4beb7f0b88622d7f2b919dce25373fe7f21 100644 (file)
@@ -9,7 +9,6 @@
 #include <net/iw_handler.h>
 
 #include "host.h"
-#include "sbi.h"
 #include "decl.h"
 #include "defs.h"
 #include "dev.h"
index 96d22b1f25d850382864e345eb5741dcf07ea7c2..4967005adfef4e4aeb311df0347b43435e4cbc6d 100644 (file)
@@ -82,4 +82,9 @@ int wlan_remove_card(wlan_private *priv);
 int wlan_add_mesh(wlan_private *priv);
 void wlan_remove_mesh(wlan_private *priv);
 
+/* preliminary here */
+int if_usb_register(void);
+void if_usb_unregister(void);
+
+
 #endif                         /* _WLAN_DECL_H_ */
index 7e8e7ac2178677381c1ef858204e72e8b47b0689..c081813410fd674700fc063a1088eccbac24e487 100644 (file)
@@ -155,6 +155,13 @@ static inline void lbs_dbg_hex(char *prompt, u8 * buf, int len)
 #define MRVDRV_MAX_BEACON_INTERVAL             1000
 #define MRVDRV_BEACON_INTERVAL                 100
 
+/** INT status Bit Definition*/
+#define his_cmddnldrdy                 0x01
+#define his_cardevent                  0x02
+#define his_cmdupldrdy                 0x04
+
+#define SBI_EVENT_CAUSE_SHIFT          3
+
 /** TxPD status */
 
 /*     Station firmware use TxPD status field to report final Tx transmit
index d7673c91f480bebecdfda4f85af6b20d7ae1394e..32e2077617bb64bf09eece44dbba7f98d96559a1 100644 (file)
@@ -162,6 +162,14 @@ struct _wlan_private {
 
        struct delayed_work assoc_work;
        struct workqueue_struct *assoc_thread;
+
+       /** Hardware access */
+       int (*hw_register_dev) (wlan_private * priv);
+       int (*hw_unregister_dev) (wlan_private *);
+       int (*hw_prog_firmware) (wlan_private *);
+       int (*hw_host_to_card) (wlan_private * priv, u8 type, u8 * payload, u16 nb);
+       int (*hw_get_int_status) (wlan_private * priv, u8 *);
+       int (*hw_read_event_cause) (wlan_private *);
 };
 
 /** Association request
index c3a26fce02ca00c2670cab8bafd44defd4616fc2..2be1815e2878c682b9732c40c9f5659082036edf 100644 (file)
@@ -1,10 +1,8 @@
-
 #include <linux/netdevice.h>
 #include <linux/ethtool.h>
 #include <linux/delay.h>
 
 #include "host.h"
-#include "sbi.h"
 #include "decl.h"
 #include "defs.h"
 #include "dev.h"
index 2c965b5341d4c1a8d0bef6d2636f6b145b6a2958..dc3d48aefd68cecae25b5a6d9dff2eebcd7233a0 100644 (file)
@@ -5,7 +5,6 @@
 #include <linux/firmware.h>
 
 #include "host.h"
-#include "sbi.h"
 #include "defs.h"
 #include "decl.h"
 #include "dev.h"
@@ -89,7 +88,7 @@ static int wlan_setup_station_hw(wlan_private * priv)
                goto done;
        }
 
-       ret = libertas_sbi_prog_firmware(priv);
+       ret = priv->hw_prog_firmware(priv);
 
        release_firmware(priv->firmware);
 
index d4db8e668e784ec5a37d16091a30a845fbde1f8b..5b0e0f76f4045e349c82298e8da0581148d90ff3 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/usb.h>
 
 #include "host.h"
-#include "sbi.h"
 #include "decl.h"
 #include "defs.h"
 #include "dev.h"
@@ -33,6 +32,12 @@ MODULE_DEVICE_TABLE(usb, if_usb_table);
 static void if_usb_receive(struct urb *urb);
 static void if_usb_receive_fwload(struct urb *urb);
 static int reset_device(wlan_private *priv);
+static int if_usb_register_dev(wlan_private * priv);
+static int if_usb_unregister_dev(wlan_private *);
+static int if_usb_prog_firmware(wlan_private *);
+static int if_usb_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 nb);
+static int if_usb_get_int_status(wlan_private * priv, u8 *);
+static int if_usb_read_event_cause(wlan_private *);
 
 /**
  *  @brief  call back function to handle the status of the URB
@@ -192,7 +197,7 @@ static int if_usb_probe(struct usb_interface *intf,
 
        /* At this point wlan_add_card() will be called.  Don't worry
         * about keeping pwlanpriv around since it will be set on our
-        * usb device data in -> add() -> libertas_sbi_register_dev().
+        * usb device data in -> add() -> hw_register_dev() -> if_usb_register_dev.
         */
        if (!(priv = wlan_add_card(usb_cardp)))
                goto dealloc;
@@ -200,6 +205,13 @@ static int if_usb_probe(struct usb_interface *intf,
        if (wlan_add_mesh(priv))
                goto err_add_mesh;
 
+       priv->hw_register_dev = if_usb_register_dev;
+       priv->hw_unregister_dev = if_usb_unregister_dev;
+       priv->hw_prog_firmware = if_usb_prog_firmware;
+       priv->hw_host_to_card = if_usb_host_to_card;
+       priv->hw_get_int_status = if_usb_get_int_status;
+       priv->hw_read_event_cause = if_usb_read_event_cause;
+
        if (libertas_activate_card(priv))
                goto err_activate_card;
 
@@ -702,7 +714,7 @@ rx_exit:
  *  @param len         number of bytes
  *  @return            0 or -1
  */
-int libertas_sbi_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 nb)
+static int if_usb_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 nb)
 {
        int ret = -1;
        u32 tmp;
@@ -733,7 +745,7 @@ int libertas_sbi_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 nb
 }
 
 /* called with adapter->driver_lock held */
-int libertas_sbi_get_int_status(wlan_private * priv, u8 * ireg)
+static int if_usb_get_int_status(wlan_private * priv, u8 * ireg)
 {
        struct usb_card_rec *cardp = priv->wlan_dev.card;
 
@@ -745,7 +757,7 @@ int libertas_sbi_get_int_status(wlan_private * priv, u8 * ireg)
        return 0;
 }
 
-int libertas_sbi_read_event_cause(wlan_private * priv)
+static int if_usb_read_event_cause(wlan_private * priv)
 {
        struct usb_card_rec *cardp = priv->wlan_dev.card;
        priv->adapter->eventcause = cardp->usb_event_cause;
@@ -767,7 +779,7 @@ static int reset_device(wlan_private *priv)
        return ret;
 }
 
-int libertas_sbi_unregister_dev(wlan_private * priv)
+static int if_usb_unregister_dev(wlan_private * priv)
 {
        int ret = 0;
 
@@ -787,7 +799,7 @@ int libertas_sbi_unregister_dev(wlan_private * priv)
  *  @param             priv pointer to wlan_private
  *  @return            0 or -1
  */
-int libertas_sbi_register_dev(wlan_private * priv)
+static int if_usb_register_dev(wlan_private * priv)
 {
        struct usb_card_rec *cardp = (struct usb_card_rec *)priv->wlan_dev.card;
 
@@ -809,7 +821,7 @@ int libertas_sbi_register_dev(wlan_private * priv)
 
 
 
-int libertas_sbi_prog_firmware(wlan_private * priv)
+static int if_usb_prog_firmware(wlan_private * priv)
 {
        struct usb_card_rec *cardp = priv->wlan_dev.card;
        int i = 0;
@@ -959,7 +971,7 @@ static struct usb_driver if_usb_driver = {
  *  @param arg         pointer to call back function parameter
  *  @return            dummy success variable
  */
-int libertas_sbi_register(void)
+int if_usb_register(void)
 {
        /*
         * API registers the Marvell USB driver
@@ -975,7 +987,7 @@ int libertas_sbi_register(void)
  *  @brief This function removes usb driver.
  *  @return            N/A
  */
-void libertas_sbi_unregister(void)
+void if_usb_unregister(void)
 {
        int i;
 
index 5c58c50b430d2ff49bb799f7c78780d24308251e..33294dd0eeeceab756dcf9565bdd2f6bc25e600d 100644 (file)
@@ -15,7 +15,6 @@
 #include <net/ieee80211.h>
 
 #include "host.h"
-#include "sbi.h"
 #include "decl.h"
 #include "dev.h"
 #include "fw.h"
@@ -661,7 +660,7 @@ static int wlan_service_main_thread(void *data)
                if (adapter->intcounter) {
                        u8 int_status;
                        adapter->intcounter = 0;
-                       int_status = libertas_sbi_get_int_status(priv, &ireg);
+                       int_status = priv->hw_get_int_status(priv, &ireg);
 
                        if (int_status) {
                                lbs_deb_thread(
@@ -693,9 +692,9 @@ static int wlan_service_main_thread(void *data)
 
                        adapter->hisregcpy &= ~his_cardevent;
 
-                       if (libertas_sbi_read_event_cause(priv)) {
+                       if (priv->hw_read_event_cause(priv)) {
                                lbs_pr_alert(
-                                      "main-thread: libertas_sbi_read_event_cause failed\n");
+                                      "main-thread: hw_read_event_cause failed\n");
                                spin_unlock_irq(&adapter->driver_lock);
                                continue;
                        }
@@ -850,7 +849,7 @@ int libertas_activate_card(wlan_private *priv)
         * relevant information from the card and request for the required
         * IRQ.
         */
-       if (libertas_sbi_register_dev(priv) < 0) {
+       if (priv->hw_register_dev(priv) < 0) {
                lbs_pr_err("failed to register WLAN device\n");
                goto err_registerdev;
        }
@@ -874,7 +873,7 @@ int libertas_activate_card(wlan_private *priv)
        goto done;
 
 err_init_fw:
-       libertas_sbi_unregister_dev(priv);
+       priv->hw_unregister_dev(priv);
 err_registerdev:
        destroy_workqueue(priv->assoc_thread);
        /* Stop the thread servicing the interrupts */
@@ -1156,7 +1155,7 @@ static int wlan_init_module(void)
 
        libertas_debugfs_init();
 
-       if (libertas_sbi_register()) {
+       if (if_usb_register()) {
                ret = -1;
                libertas_debugfs_remove();
        }
@@ -1169,7 +1168,7 @@ static void wlan_cleanup_module(void)
 {
        lbs_deb_enter(LBS_DEB_MAIN);
 
-       libertas_sbi_unregister();
+       if_usb_unregister();
        libertas_debugfs_remove();
 
        lbs_deb_leave(LBS_DEB_MAIN);
diff --git a/drivers/net/wireless/libertas/sbi.h b/drivers/net/wireless/libertas/sbi.h
deleted file mode 100644 (file)
index d999078..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
-  * This file contains IF layer definitions.
-  */
-
-#ifndef        _SBI_H_
-#define        _SBI_H_
-
-#include <linux/interrupt.h>
-
-#include "defs.h"
-
-/** INT status Bit Definition*/
-#define his_cmddnldrdy                 0x01
-#define his_cardevent                  0x02
-#define his_cmdupldrdy                 0x04
-
-#define SBI_EVENT_CAUSE_SHIFT          3
-
-/* Probe and Check if the card is present*/
-int libertas_sbi_register_dev(wlan_private * priv);
-int libertas_sbi_unregister_dev(wlan_private *);
-int libertas_sbi_get_int_status(wlan_private * priv, u8 *);
-int libertas_sbi_register(void);
-void libertas_sbi_unregister(void);
-int libertas_sbi_prog_firmware(wlan_private *);
-
-int libertas_sbi_read_event_cause(wlan_private *);
-int libertas_sbi_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 nb);
-
-#endif                         /* _SBI_H */
index e61729f0645a8b4bdfb2da67ddc333978c1507fe..1993e8e79c454a691ea61e8adf1a2db3627a7d7f 100644 (file)
@@ -5,7 +5,6 @@
 
 #include "hostcmd.h"
 #include "radiotap.h"
-#include "sbi.h"
 #include "decl.h"
 #include "defs.h"
 #include "dev.h"
@@ -132,13 +131,13 @@ static int SendSinglePacket(wlan_private * priv, struct sk_buff *skb)
 
        lbs_dbg_hex("Tx Data", (u8 *) p802x_hdr, plocaltxpd->tx_packet_length);
        memcpy(ptr, p802x_hdr, plocaltxpd->tx_packet_length);
-       ret = libertas_sbi_host_to_card(priv, MVMS_DAT,
-                              priv->adapter->tmptxbuf,
-                              plocaltxpd->tx_packet_length +
-                              sizeof(struct txpd));
+       ret = priv->hw_host_to_card(priv, MVMS_DAT,
+               priv->adapter->tmptxbuf,
+               plocaltxpd->tx_packet_length +
+               sizeof(struct txpd));
 
        if (ret) {
-               lbs_deb_tx("tx err: libertas_sbi_host_to_card returned 0x%X\n", ret);
+               lbs_deb_tx("tx err: hw_host_to_card returned 0x%X\n", ret);
                goto done;
        }