iwlagn: move all iwl_is_XXX helpers to iwl-shared.h
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Fri, 26 Aug 2011 06:11:04 +0000 (23:11 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 29 Aug 2011 19:25:35 +0000 (15:25 -0400)
Logic move after all priv->status moved to struct iwl_shared

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
14 files changed:
drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
drivers/net/wireless/iwlwifi/iwl-agn-sta.c
drivers/net/wireless/iwlwifi/iwl-agn-tt.c
drivers/net/wireless/iwlwifi/iwl-agn-tx.c
drivers/net/wireless/iwlwifi/iwl-agn.c
drivers/net/wireless/iwlwifi/iwl-core.c
drivers/net/wireless/iwlwifi/iwl-core.h
drivers/net/wireless/iwlwifi/iwl-debugfs.c
drivers/net/wireless/iwlwifi/iwl-power.c
drivers/net/wireless/iwlwifi/iwl-scan.c
drivers/net/wireless/iwlwifi/iwl-shared.h
drivers/net/wireless/iwlwifi/iwl-sta.c
drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c
drivers/net/wireless/iwlwifi/iwl-trans.c

index 991977e2e1b03791dc60e3e93ddc679c8c0bbe1b..7ce56ff4a52511d859091831c262abbca053e6dd 100644 (file)
@@ -426,7 +426,7 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
        if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return -EINVAL;
 
-       if (!iwl_is_alive(priv))
+       if (!iwl_is_alive(priv->shrd))
                return -EBUSY;
 
        /* This function hardcodes a bunch of dual-mode assumptions */
@@ -544,7 +544,7 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
                goto out;
        }
 
-       if (!iwl_is_ready(priv)) {
+       if (!iwl_is_ready(priv->shrd)) {
                IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
                goto out;
        }
@@ -794,7 +794,7 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
 
        mutex_lock(&priv->shrd->mutex);
 
-       if (unlikely(!iwl_is_ready(priv))) {
+       if (unlikely(!iwl_is_ready(priv->shrd))) {
                IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
                mutex_unlock(&priv->shrd->mutex);
                return;
index 4d02c328c3776d6c6d7069b57d91d83f1269a6dd..8f0b86de1863f75df092290c1914f2383710f4eb 100644 (file)
@@ -214,7 +214,7 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv,
                      keyconf->keyidx);
 
        memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0]));
-       if (iwl_is_rfkill(priv)) {
+       if (iwl_is_rfkill(priv->shrd)) {
                IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n");
                /* but keys in device are clear anyway so return success */
                return 0;
index 03d8389d8ef8ab6107398b526a864cb472f15134..1a39aafb3b0513449747e4cd3c0d1ee3f6beddde 100644 (file)
@@ -511,7 +511,7 @@ static void iwl_bg_ct_enter(struct work_struct *work)
        if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
-       if (!iwl_is_ready(priv))
+       if (!iwl_is_ready(priv->shrd))
                return;
 
        if (tt->state != IWL_TI_CT_KILL) {
@@ -540,7 +540,7 @@ static void iwl_bg_ct_exit(struct work_struct *work)
        if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
-       if (!iwl_is_ready(priv))
+       if (!iwl_is_ready(priv->shrd))
                return;
 
        /* stop ct_kill_exit_tm timer */
index e95f9c61f95a568984a83d157094149182b493d1..97d03a85d579377b85cf794df007b03a800b0554 100644 (file)
@@ -338,7 +338,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
                ctx = iwl_rxon_ctx_from_vif(info->control.vif);
 
        spin_lock_irqsave(&priv->shrd->lock, flags);
-       if (iwl_is_rfkill(priv)) {
+       if (iwl_is_rfkill(priv->shrd)) {
                IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n");
                goto drop_unlock_priv;
        }
index a79ee7a451d14bc120b17138e286f5801c6568ef..f559c6362a00a7cd5bc800d6247d4affa6be97c3 100644 (file)
@@ -251,7 +251,7 @@ static void iwl_bg_bt_runtime_config(struct work_struct *work)
                return;
 
        /* dont send host command if rf-kill is on */
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                return;
        iwlagn_send_advance_bt_config(priv);
 }
@@ -268,7 +268,7 @@ static void iwl_bg_bt_full_concurrency(struct work_struct *work)
                goto out;
 
        /* dont send host command if rf-kill is on */
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                goto out;
 
        IWL_DEBUG_INFO(priv, "BT coex in %s mode\n",
@@ -307,7 +307,7 @@ static void iwl_bg_statistics_periodic(unsigned long data)
                return;
 
        /* dont send host command if rf-kill is on */
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                return;
 
        iwl_send_statistics_request(priv, CMD_ASYNC, false);
@@ -444,7 +444,7 @@ static void iwl_bg_tx_flush(struct work_struct *work)
                return;
 
        /* do nothing if rf-kill is on */
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                return;
 
        IWL_DEBUG_INFO(priv, "device request: flush all tx frames\n");
@@ -510,7 +510,7 @@ static ssize_t show_temperature(struct device *d,
        struct iwl_shared *shrd = dev_get_drvdata(d);
        struct iwl_priv *priv = shrd->priv;
 
-       if (!iwl_is_alive(priv))
+       if (!iwl_is_alive(priv->shrd))
                return -EAGAIN;
 
        return sprintf(buf, "%d\n", priv->temperature);
@@ -523,7 +523,7 @@ static ssize_t show_tx_power(struct device *d,
 {
        struct iwl_priv *priv = dev_get_drvdata(d);
 
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                return sprintf(buf, "off\n");
        else
                return sprintf(buf, "%d\n", priv->tx_power_user_lmt);
@@ -1412,7 +1412,7 @@ int iwl_alive_start(struct iwl_priv *priv)
        /* Enable watchdog to monitor the driver tx queues */
        iwl_setup_watchdog(priv);
 
-       if (iwl_is_rfkill(priv))
+       if (iwl_is_rfkill(priv->shrd))
                return -ERFKILL;
 
        /* download priority table before any calibration request */
@@ -2701,7 +2701,7 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
 
        mutex_lock(&priv->shrd->mutex);
 
-       if (iwl_is_rfkill(priv))
+       if (iwl_is_rfkill(priv->shrd))
                goto out;
 
        if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) ||
@@ -2836,7 +2836,7 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop)
                IWL_DEBUG_TX(priv, "Aborting flush due to device shutdown\n");
                goto done;
        }
-       if (iwl_is_rfkill(priv)) {
+       if (iwl_is_rfkill(priv->shrd)) {
                IWL_DEBUG_TX(priv, "Aborting flush due to RF Kill\n");
                goto done;
        }
index 347cbec935b987354f7c9f421f19adaf0930e999..cfc23c25e979a33be7aa13bf13327fa205782239 100644 (file)
@@ -1051,7 +1051,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
                return -EINVAL;
        }
 
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                return -EIO;
 
        /* scan complete and commit_rxon use tx_power_next value,
@@ -1131,7 +1131,7 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
 
-       if (!iwl_is_ready_rf(priv)) {
+       if (!iwl_is_ready_rf(priv->shrd)) {
                IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
                return -EIO;
        }
@@ -1237,7 +1237,7 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 
        iwlagn_disable_roc(priv);
 
-       if (!iwl_is_ready_rf(priv)) {
+       if (!iwl_is_ready_rf(priv->shrd)) {
                IWL_WARN(priv, "Try to add interface when device not ready\n");
                err = -EINVAL;
                goto out;
@@ -1657,7 +1657,7 @@ int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 
        mutex_lock(&priv->shrd->mutex);
 
-       if (!ctx->vif || !iwl_is_ready_rf(priv)) {
+       if (!ctx->vif || !iwl_is_ready_rf(priv->shrd)) {
                /*
                 * Huh? But wait ... this can maybe happen when
                 * we're in the middle of a firmware restart!
index 110ffaea0949af511c2aeeb63bf7436d86bc5cd1..e5b3c356b3928c59f27bdba6116e2acfb27dceab 100644 (file)
@@ -393,72 +393,6 @@ static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv,
 int iwl_init_geos(struct iwl_priv *priv);
 void iwl_free_geos(struct iwl_priv *priv);
 
-/*************** DRIVER STATUS FUNCTIONS   *****/
-
-#define STATUS_HCMD_ACTIVE     0       /* host command in progress */
-/* 1 is unused (used to be STATUS_HCMD_SYNC_ACTIVE) */
-#define STATUS_INT_ENABLED     2
-#define STATUS_RF_KILL_HW      3
-#define STATUS_CT_KILL         4
-#define STATUS_INIT            5
-#define STATUS_ALIVE           6
-#define STATUS_READY           7
-#define STATUS_TEMPERATURE     8
-#define STATUS_GEO_CONFIGURED  9
-#define STATUS_EXIT_PENDING    10
-#define STATUS_STATISTICS      12
-#define STATUS_SCANNING                13
-#define STATUS_SCAN_ABORTING   14
-#define STATUS_SCAN_HW         15
-#define STATUS_POWER_PMI       16
-#define STATUS_FW_ERROR                17
-#define STATUS_DEVICE_ENABLED  18
-#define STATUS_CHANNEL_SWITCH_PENDING 19
-
-
-static inline int iwl_is_ready(struct iwl_priv *priv)
-{
-       /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are
-        * set but EXIT_PENDING is not */
-       return test_bit(STATUS_READY, &priv->shrd->status) &&
-              test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status) &&
-              !test_bit(STATUS_EXIT_PENDING, &priv->shrd->status);
-}
-
-static inline int iwl_is_alive(struct iwl_priv *priv)
-{
-       return test_bit(STATUS_ALIVE, &priv->shrd->status);
-}
-
-static inline int iwl_is_init(struct iwl_priv *priv)
-{
-       return test_bit(STATUS_INIT, &priv->shrd->status);
-}
-
-static inline int iwl_is_rfkill_hw(struct iwl_priv *priv)
-{
-       return test_bit(STATUS_RF_KILL_HW, &priv->shrd->status);
-}
-
-static inline int iwl_is_rfkill(struct iwl_priv *priv)
-{
-       return iwl_is_rfkill_hw(priv);
-}
-
-static inline int iwl_is_ctkill(struct iwl_priv *priv)
-{
-       return test_bit(STATUS_CT_KILL, &priv->shrd->status);
-}
-
-static inline int iwl_is_ready_rf(struct iwl_priv *priv)
-{
-
-       if (iwl_is_rfkill(priv))
-               return 0;
-
-       return iwl_is_ready(priv);
-}
-
 extern void iwl_send_bt_config(struct iwl_priv *priv);
 extern int iwl_send_statistics_request(struct iwl_priv *priv,
                                       u8 flags, bool clear);
index 787dae5fec99a86de309bf755d81d08c1c8e5d00..9ca429c23ad13ea2defa7ffad3db3fedb498912f 100644 (file)
@@ -740,7 +740,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
        if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
                return -EINVAL;
 
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                return -EAGAIN;
 
        priv->power_data.debug_sleep_level_override = value;
@@ -851,7 +851,7 @@ static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
        struct statistics_rx_non_phy *delta_general, *max_general;
        struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
 
-       if (!iwl_is_alive(priv))
+       if (!iwl_is_alive(priv->shrd))
                return -EAGAIN;
 
        buf = kzalloc(bufsz, GFP_KERNEL);
@@ -1277,7 +1277,7 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
        ssize_t ret;
        struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
 
-       if (!iwl_is_alive(priv))
+       if (!iwl_is_alive(priv->shrd))
                return -EAGAIN;
 
        buf = kzalloc(bufsz, GFP_KERNEL);
@@ -1471,7 +1471,7 @@ static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
        struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
        struct statistics_div *div, *accum_div, *delta_div, *max_div;
 
-       if (!iwl_is_alive(priv))
+       if (!iwl_is_alive(priv->shrd))
                return -EAGAIN;
 
        buf = kzalloc(bufsz, GFP_KERNEL);
@@ -1584,7 +1584,7 @@ static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
        ssize_t ret;
        struct statistics_bt_activity *bt, *accum_bt;
 
-       if (!iwl_is_alive(priv))
+       if (!iwl_is_alive(priv->shrd))
                return -EAGAIN;
 
        if (!priv->bt_enable_flag)
@@ -1672,7 +1672,7 @@ static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
                (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200;
        ssize_t ret;
 
-       if (!iwl_is_alive(priv))
+       if (!iwl_is_alive(priv->shrd))
                return -EAGAIN;
 
        buf = kzalloc(bufsz, GFP_KERNEL);
@@ -2259,7 +2259,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
        if (sscanf(buf, "%d", &flush) != 1)
                return -EINVAL;
 
-       if (iwl_is_rfkill(priv))
+       if (iwl_is_rfkill(priv->shrd))
                return -EFAULT;
 
        iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL);
index 9f0e620fc3a12b15b8a7553e8a90bf7140a4433f..2c91a48b8010f34519f679f76129bbc3f5e5ffcc 100644 (file)
@@ -392,7 +392,7 @@ int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd,
        if (!memcmp(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force)
                return 0;
 
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                return -EIO;
 
        /* scan complete use sleep_power_next, need to be updated */
index 1a0cb66d7baefc2bbe465b79d62e500cafbbb96f..2bb94f7351c974503b3dca72149dd3f251fae81f 100644 (file)
@@ -362,7 +362,7 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv,
 
        cancel_delayed_work(&priv->scan_check);
 
-       if (!iwl_is_ready_rf(priv)) {
+       if (!iwl_is_ready_rf(priv->shrd)) {
                IWL_WARN(priv, "Request scan called when driver not ready.\n");
                return -EIO;
        }
@@ -606,7 +606,7 @@ out_complete:
 
 out_settings:
        /* Can we still talk to firmware ? */
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                goto out;
 
        iwlagn_post_scan(priv);
index fd9a9224edfc9ae18e96881c72652c0fe951524d..ff4c04fee4296e0e4c5e6357189bf39b15c1e026 100644 (file)
@@ -246,4 +246,69 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops,
                struct iwl_cfg *cfg);
 void __devexit iwl_remove(struct iwl_priv * priv);
 
+/*****************************************************
+* DRIVER STATUS FUNCTIONS
+******************************************************/
+#define STATUS_HCMD_ACTIVE     0       /* host command in progress */
+/* 1 is unused (used to be STATUS_HCMD_SYNC_ACTIVE) */
+#define STATUS_INT_ENABLED     2
+#define STATUS_RF_KILL_HW      3
+#define STATUS_CT_KILL         4
+#define STATUS_INIT            5
+#define STATUS_ALIVE           6
+#define STATUS_READY           7
+#define STATUS_TEMPERATURE     8
+#define STATUS_GEO_CONFIGURED  9
+#define STATUS_EXIT_PENDING    10
+#define STATUS_STATISTICS      12
+#define STATUS_SCANNING                13
+#define STATUS_SCAN_ABORTING   14
+#define STATUS_SCAN_HW         15
+#define STATUS_POWER_PMI       16
+#define STATUS_FW_ERROR                17
+#define STATUS_DEVICE_ENABLED  18
+#define STATUS_CHANNEL_SWITCH_PENDING 19
+
+static inline int iwl_is_ready(struct iwl_shared *shrd)
+{
+       /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are
+        * set but EXIT_PENDING is not */
+       return test_bit(STATUS_READY, &shrd->status) &&
+              test_bit(STATUS_GEO_CONFIGURED, &shrd->status) &&
+              !test_bit(STATUS_EXIT_PENDING, &shrd->status);
+}
+
+static inline int iwl_is_alive(struct iwl_shared *shrd)
+{
+       return test_bit(STATUS_ALIVE, &shrd->status);
+}
+
+static inline int iwl_is_init(struct iwl_shared *shrd)
+{
+       return test_bit(STATUS_INIT, &shrd->status);
+}
+
+static inline int iwl_is_rfkill_hw(struct iwl_shared *shrd)
+{
+       return test_bit(STATUS_RF_KILL_HW, &shrd->status);
+}
+
+static inline int iwl_is_rfkill(struct iwl_shared *shrd)
+{
+       return iwl_is_rfkill_hw(shrd);
+}
+
+static inline int iwl_is_ctkill(struct iwl_shared *shrd)
+{
+       return test_bit(STATUS_CT_KILL, &shrd->status);
+}
+
+static inline int iwl_is_ready_rf(struct iwl_shared *shrd)
+{
+       if (iwl_is_rfkill(shrd))
+               return 0;
+
+       return iwl_is_ready(shrd);
+}
+
 #endif /* #__iwl_shared_h__ */
index d4c625c1311923ff40bb7af821ae234c5619e252..1154e48430878fc7c125a1385488a954b600479c 100644 (file)
@@ -468,7 +468,7 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id,
 {
        unsigned long flags;
 
-       if (!iwl_is_ready(priv)) {
+       if (!iwl_is_ready(priv->shrd)) {
                IWL_DEBUG_INFO(priv,
                        "Unable to remove station %pM, device not ready.\n",
                        addr);
@@ -572,7 +572,7 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
        int ret;
        bool send_lq;
 
-       if (!iwl_is_ready(priv)) {
+       if (!iwl_is_ready(priv->shrd)) {
                IWL_DEBUG_INFO(priv, "Not ready yet, not restoring any stations.\n");
                return;
        }
index a462d697a690b1df94e38aadb9ee7b07718b9324..ac2fae12707a07ae2a724a5103e5dd8f7b4e353d 100644 (file)
@@ -599,9 +599,9 @@ static int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
        if (WARN_ON(copy_size > TFD_MAX_PAYLOAD_SIZE))
                return -EINVAL;
 
-       if (iwl_is_rfkill(priv) || iwl_is_ctkill(priv)) {
+       if (iwl_is_rfkill(priv->shrd) || iwl_is_ctkill(priv->shrd)) {
                IWL_WARN(priv, "Not sending command - %s KILL\n",
-                        iwl_is_rfkill(priv) ? "RF" : "CT");
+                        iwl_is_rfkill(priv->shrd) ? "RF" : "CT");
                return -EIO;
        }
 
index a2950a4cc35c4de3067a6f79b5665c00908b056c..b080e69374ea55c74e28eb221bdc1697d9cd3bf3 100644 (file)
@@ -715,7 +715,7 @@ static int iwl_trans_pcie_start_device(struct iwl_priv *priv)
        else
                set_bit(STATUS_RF_KILL_HW, &priv->shrd->status);
 
-       if (iwl_is_rfkill(priv)) {
+       if (iwl_is_rfkill(priv->shrd)) {
                wiphy_rfkill_set_hw_state(priv->hw->wiphy, true);
                iwl_enable_interrupts(trans(priv));
                return -ERFKILL;