iwlwifi: 3945 extract flow handler definitions into iwl-3945-fh.h
[cascardo/linux.git] / drivers / net / wireless / iwlwifi / iwl3945-base.c
index f883006..fee3e93 100644 (file)
@@ -48,6 +48,7 @@
 
 #include "iwl-3945-core.h"
 #include "iwl-3945.h"
+#include "iwl-3945-fh.h"
 #include "iwl-helpers.h"
 
 #ifdef CONFIG_IWL3945_DEBUG
@@ -65,7 +66,7 @@ static int iwl3945_tx_queue_update_write_ptr(struct iwl3945_priv *priv,
 
 /* module parameters */
 static int iwl3945_param_disable_hw_scan; /* def: 0 = use 3945's h/w scan */
-static int iwl3945_param_debug;    /* def: 0 = minimal debug log messages */
+static u32 iwl3945_param_debug;    /* def: 0 = minimal debug log messages */
 static int iwl3945_param_disable;  /* def: 0 = enable radio */
 static int iwl3945_param_antenna;  /* def: 0 = both antennas (use diversity) */
 int iwl3945_param_hwcrypto;        /* def: 0 = use software encryption */
@@ -93,12 +94,13 @@ int iwl3945_param_queues_num = IWL39_MAX_NUM_QUEUES; /* def: 8 Tx queues */
 
 #define IWLWIFI_VERSION "1.2.26k" VD VS
 #define DRV_COPYRIGHT  "Copyright(c) 2003-2008 Intel Corporation"
+#define DRV_AUTHOR     "<ilw@linux.intel.com>"
 #define DRV_VERSION     IWLWIFI_VERSION
 
 
 MODULE_DESCRIPTION(DRV_DESCRIPTION);
 MODULE_VERSION(DRV_VERSION);
-MODULE_AUTHOR(DRV_COPYRIGHT);
+MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR);
 MODULE_LICENSE("GPL");
 
 static const struct ieee80211_supported_band *iwl3945_get_band(
@@ -744,7 +746,7 @@ static int iwl3945_send_cmd_sync(struct iwl3945_priv *priv, struct iwl3945_host_
                IWL_ERROR("Error: Response NULL in '%s'\n",
                          get_cmd_string(cmd->id));
                ret = -EIO;
-               goto out;
+               goto cancel;
        }
 
        ret = 0;
@@ -1401,7 +1403,7 @@ static void iwl3945_free_frame(struct iwl3945_priv *priv, struct iwl3945_frame *
 
 unsigned int iwl3945_fill_beacon_frame(struct iwl3945_priv *priv,
                                struct ieee80211_hdr *hdr,
-                               const u8 *dest, int left)
+                               int left)
 {
 
        if (!iwl3945_is_associated(priv) || !priv->ibss_beacon ||
@@ -1504,10 +1506,8 @@ int iwl3945_eeprom_init(struct iwl3945_priv *priv)
 {
        u16 *e = (u16 *)&priv->eeprom;
        u32 gp = iwl3945_read32(priv, CSR_EEPROM_GP);
-       u32 r;
        int sz = sizeof(priv->eeprom);
-       int rc;
-       int i;
+       int ret;
        u16 addr;
 
        /* The EEPROM structure has several padding buffers within it
@@ -1522,29 +1522,28 @@ int iwl3945_eeprom_init(struct iwl3945_priv *priv)
        }
 
        /* Make sure driver (instead of uCode) is allowed to read EEPROM */
-       rc = iwl3945_eeprom_acquire_semaphore(priv);
-       if (rc < 0) {
+       ret = iwl3945_eeprom_acquire_semaphore(priv);
+       if (ret < 0) {
                IWL_ERROR("Failed to acquire EEPROM semaphore.\n");
                return -ENOENT;
        }
 
        /* eeprom is an array of 16bit values */
        for (addr = 0; addr < sz; addr += sizeof(u16)) {
-               _iwl3945_write32(priv, CSR_EEPROM_REG, addr << 1);
-               _iwl3945_clear_bit(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_BIT_CMD);
+               u32 r;
 
-               for (i = 0; i < IWL_EEPROM_ACCESS_TIMEOUT;
-                                       i += IWL_EEPROM_ACCESS_DELAY) {
-                       r = _iwl3945_read_direct32(priv, CSR_EEPROM_REG);
-                       if (r & CSR_EEPROM_REG_READ_VALID_MSK)
-                               break;
-                       udelay(IWL_EEPROM_ACCESS_DELAY);
-               }
-
-               if (!(r & CSR_EEPROM_REG_READ_VALID_MSK)) {
+               _iwl3945_write32(priv, CSR_EEPROM_REG,
+                                CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
+               _iwl3945_clear_bit(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_BIT_CMD);
+               ret = iwl3945_poll_direct_bit(priv, CSR_EEPROM_REG,
+                                             CSR_EEPROM_REG_READ_VALID_MSK,
+                                             IWL_EEPROM_ACCESS_TIMEOUT);
+               if (ret < 0) {
                        IWL_ERROR("Time out reading EEPROM[%d]\n", addr);
-                       return -ETIMEDOUT;
+                       return ret;
                }
+
+               r = _iwl3945_read_direct32(priv, CSR_EEPROM_REG);
                e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16));
        }
 
@@ -3481,14 +3480,14 @@ int iwl3945_rx_queue_update_write_ptr(struct iwl3945_priv *priv, struct iwl3945_
                        goto exit_unlock;
 
                /* Device expects a multiple of 8 */
-               iwl3945_write_direct32(priv, FH_RSCSR_CHNL0_WPTR,
+               iwl3945_write_direct32(priv, FH39_RSCSR_CHNL0_WPTR,
                                     q->write & ~0x7);
                iwl3945_release_nic_access(priv);
 
        /* Else device is assumed to be awake */
        } else
                /* Device expects a multiple of 8 */
-               iwl3945_write32(priv, FH_RSCSR_CHNL0_WPTR, q->write & ~0x7);
+               iwl3945_write32(priv, FH39_RSCSR_CHNL0_WPTR, q->write & ~0x7);
 
 
        q->need_update = 0;
@@ -4341,9 +4340,8 @@ static void iwl3945_irq_tasklet(struct iwl3945_priv *priv)
 
                iwl3945_write32(priv, CSR_FH_INT_STATUS, (1 << 6));
                if (!iwl3945_grab_nic_access(priv)) {
-                       iwl3945_write_direct32(priv,
-                                            FH_TCSR_CREDIT
-                                            (ALM_FH_SRVC_CHNL), 0x0);
+                       iwl3945_write_direct32(priv, FH39_TCSR_CREDIT
+                                            (FH39_SRVC_CHNL), 0x0);
                        iwl3945_release_nic_access(priv);
                }
                handled |= CSR_INT_BIT_FH_TX;
@@ -6540,7 +6538,7 @@ static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
                dev_kfree_skb_any(skb);
 
        IWL_DEBUG_MAC80211("leave\n");
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static int iwl3945_mac_add_interface(struct ieee80211_hw *hw,
@@ -8345,7 +8343,7 @@ MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])");
 module_param_named(hwcrypto, iwl3945_param_hwcrypto, int, 0444);
 MODULE_PARM_DESC(hwcrypto,
                 "using hardware crypto engine (default 0 [software])\n");
-module_param_named(debug, iwl3945_param_debug, int, 0444);
+module_param_named(debug, iwl3945_param_debug, uint, 0444);
 MODULE_PARM_DESC(debug, "debug output mask");
 module_param_named(disable_hw_scan, iwl3945_param_disable_hw_scan, int, 0444);
 MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 0)");