iwlagn: move iwl_suspend / iwl_resume to the transport layer
[pandora-kernel.git] / drivers / net / wireless / iwlwifi / iwl-core.c
index 2aeafa1..d77af69 100644 (file)
@@ -121,7 +121,7 @@ int iwl_init_geos(struct iwl_priv *priv)
        if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates ||
            priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) {
                IWL_DEBUG_INFO(priv, "Geography modes already initialized.\n");
-               set_bit(STATUS_GEO_CONFIGURED, &priv->status);
+               set_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status);
                return 0;
        }
 
@@ -221,7 +221,7 @@ int iwl_init_geos(struct iwl_priv *priv)
                   priv->bands[IEEE80211_BAND_2GHZ].n_channels,
                   priv->bands[IEEE80211_BAND_5GHZ].n_channels);
 
-       set_bit(STATUS_GEO_CONFIGURED, &priv->status);
+       set_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status);
 
        return 0;
 }
@@ -233,7 +233,7 @@ void iwl_free_geos(struct iwl_priv *priv)
 {
        kfree(priv->ieee_channels);
        kfree(priv->ieee_rates);
-       clear_bit(STATUS_GEO_CONFIGURED, &priv->status);
+       clear_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status);
 }
 
 static bool iwl_is_channel_extension(struct iwl_priv *priv,
@@ -325,7 +325,7 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
 
        conf = ieee80211_get_hw_conf(priv->hw);
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd));
 
@@ -378,7 +378,7 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
                        le32_to_cpu(ctx->timing.beacon_init_val),
                        le16_to_cpu(ctx->timing.atim_window));
 
-       return trans_send_cmd_pdu(&priv->trans, ctx->rxon_timing_cmd,
+       return iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_timing_cmd,
                                CMD_SYNC, sizeof(ctx->timing), &ctx->timing);
 }
 
@@ -808,10 +808,11 @@ void iwl_chswitch_done(struct iwl_priv *priv, bool is_success)
         */
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
-       if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status))
+       if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING,
+                               &priv->shrd->status))
                ieee80211_chswitch_done(ctx->vif, is_success);
 }
 
@@ -856,16 +857,16 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand)
        unsigned long reload_jiffies;
 
        /* Set the FW error flag -- cleared on iwl_down */
-       set_bit(STATUS_FW_ERROR, &priv->status);
+       set_bit(STATUS_FW_ERROR, &priv->shrd->status);
 
        /* Cancel currently queued command. */
-       clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
+       clear_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status);
 
        iwlagn_abort_notification_waits(priv);
 
        /* Keep the restart process from trying to send host
         * commands by clearing the ready bit */
-       clear_bit(STATUS_READY, &priv->status);
+       clear_bit(STATUS_READY, &priv->shrd->status);
 
        wake_up_interruptible(&priv->wait_command_queue);
 
@@ -890,13 +891,13 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand)
                        priv->reload_count = 0;
        }
 
-       if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) {
+       if (!test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) {
                if (iwlagn_mod_params.restart_fw) {
-                       IWL_DEBUG(priv, IWL_DL_FW_ERRORS,
+                       IWL_DEBUG_FW_ERRORS(priv,
                                  "Restarting adapter due to uCode error.\n");
-                       queue_work(priv->workqueue, &priv->restart);
+                       queue_work(priv->shrd->workqueue, &priv->restart);
                } else
-                       IWL_DEBUG(priv, IWL_DL_FW_ERRORS,
+                       IWL_DEBUG_FW_ERRORS(priv,
                                  "Detected FW error, but not restarting\n");
        }
 }
@@ -916,8 +917,8 @@ void iwl_irq_handle_error(struct iwl_priv *priv)
                 * Keep the restart process from trying to send host
                 * commands by clearing the ready bit.
                 */
-               clear_bit(STATUS_READY, &priv->status);
-               clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
+               clear_bit(STATUS_READY, &priv->shrd->status);
+               clear_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status);
                wake_up_interruptible(&priv->wait_command_queue);
                IWL_ERR(priv, "RF is used by WiMAX\n");
                return;
@@ -960,7 +961,7 @@ void iwl_apm_stop(struct iwl_priv *priv)
 {
        IWL_DEBUG_INFO(priv, "Stop card, put in low power state\n");
 
-       clear_bit(STATUS_DEVICE_ENABLED, &priv->status);
+       clear_bit(STATUS_DEVICE_ENABLED, &priv->shrd->status);
 
        /* Stop device's DMA activity */
        iwl_apm_stop_master(priv);
@@ -1054,7 +1055,7 @@ int iwl_apm_init(struct iwl_priv *priv)
        iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG,
                          APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
 
-       set_bit(STATUS_DEVICE_ENABLED, &priv->status);
+       set_bit(STATUS_DEVICE_ENABLED, &priv->shrd->status);
 
 out:
        return ret;
@@ -1068,7 +1069,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
        bool defer;
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        if (priv->tx_power_user_lmt == tx_power && !force)
                return 0;
@@ -1096,7 +1097,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
        priv->tx_power_next = tx_power;
 
        /* do not set tx power when scanning or channel changing */
-       defer = test_bit(STATUS_SCANNING, &priv->status) ||
+       defer = test_bit(STATUS_SCANNING, &priv->shrd->status) ||
                memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging));
        if (defer && !force) {
                IWL_DEBUG_INFO(priv, "Deferring tx power set\n");
@@ -1134,7 +1135,7 @@ void iwl_send_bt_config(struct iwl_priv *priv)
        IWL_DEBUG_INFO(priv, "BT coex %s\n",
                (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active");
 
-       if (trans_send_cmd_pdu(&priv->trans, REPLY_BT_CONFIG,
+       if (iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_CONFIG,
                             CMD_SYNC, sizeof(struct iwl_bt_cmd), &bt_cmd))
                IWL_ERR(priv, "failed to send BT Coex Config\n");
 }
@@ -1147,12 +1148,12 @@ int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear)
        };
 
        if (flags & CMD_ASYNC)
-               return trans_send_cmd_pdu(&priv->trans, REPLY_STATISTICS_CMD,
+               return iwl_trans_send_cmd_pdu(trans(priv), REPLY_STATISTICS_CMD,
                                              CMD_ASYNC,
                                               sizeof(struct iwl_statistics_cmd),
                                               &statistics_cmd);
        else
-               return trans_send_cmd_pdu(&priv->trans, REPLY_STATISTICS_CMD,
+               return iwl_trans_send_cmd_pdu(trans(priv), REPLY_STATISTICS_CMD,
                                        CMD_SYNC,
                                        sizeof(struct iwl_statistics_cmd),
                                        &statistics_cmd);
@@ -1185,7 +1186,7 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
 
        q = AC_NUM - 1 - queue;
 
-       spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irqsave(&priv->shrd->lock, flags);
 
        /*
         * MULTI-FIXME
@@ -1203,7 +1204,7 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
                ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0;
        }
 
-       spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->shrd->lock, flags);
 
        IWL_DEBUG_MAC80211(priv, "leave\n");
        return 0;
@@ -1231,7 +1232,7 @@ static int iwl_setup_interface(struct iwl_priv *priv,
        struct ieee80211_vif *vif = ctx->vif;
        int err;
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        /*
         * This variable will be correct only when there's just
@@ -1275,7 +1276,7 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 
        cancel_delayed_work_sync(&priv->hw_roc_disable_work);
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
        iwlagn_disable_roc(priv);
 
@@ -1322,7 +1323,7 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
        ctx->vif = NULL;
        priv->iw_mode = NL80211_IFTYPE_STATION;
  out:
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 
        IWL_DEBUG_MAC80211(priv, "leave\n");
        return err;
@@ -1334,7 +1335,7 @@ static void iwl_teardown_interface(struct iwl_priv *priv,
 {
        struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        if (priv->scan_vif == vif) {
                iwl_scan_cancel_timeout(priv, 200);
@@ -1366,14 +1367,14 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
        WARN_ON(ctx->vif != vif);
        ctx->vif = NULL;
 
        iwl_teardown_interface(priv, vif, false);
 
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
@@ -1613,7 +1614,7 @@ void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len)
 
 static void iwl_force_rf_reset(struct iwl_priv *priv)
 {
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
        if (!iwl_is_any_associated(priv)) {
@@ -1638,7 +1639,7 @@ int iwl_force_reset(struct iwl_priv *priv, int mode, bool external)
 {
        struct iwl_force_reset *force_reset;
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return -EINVAL;
 
        if (mode >= IWL_MAX_FORCE_RESET) {
@@ -1697,7 +1698,7 @@ int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 
        newtype = ieee80211_iftype_p2p(newtype, newp2p);
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
        if (!ctx->vif || !iwl_is_ready_rf(priv)) {
                /*
@@ -1761,7 +1762,7 @@ int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
        err = 0;
 
  out:
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
        return err;
 }
 
@@ -1810,7 +1811,7 @@ void iwl_bg_watchdog(unsigned long data)
        int cnt;
        unsigned long timeout;
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
        timeout = priv->cfg->base_params->wd_timeout;
@@ -1818,14 +1819,14 @@ void iwl_bg_watchdog(unsigned long data)
                return;
 
        /* monitor and check for stuck cmd queue */
-       if (iwl_check_stuck_queue(priv, priv->cmd_queue))
+       if (iwl_check_stuck_queue(priv, priv->shrd->cmd_queue))
                return;
 
        /* monitor and check for other stuck queues */
        if (iwl_is_any_associated(priv)) {
                for (cnt = 0; cnt < hw_params(priv).max_txq_num; cnt++) {
                        /* skip as we already checked the command queue */
-                       if (cnt == priv->cmd_queue)
+                       if (cnt == priv->shrd->cmd_queue)
                                continue;
                        if (iwl_check_stuck_queue(priv, cnt))
                                return;
@@ -1899,44 +1900,3 @@ __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
        return cpu_to_le32(res);
 }
 
-#ifdef CONFIG_PM
-
-int iwl_suspend(struct iwl_priv *priv)
-{
-       /*
-        * This function is called when system goes into suspend state
-        * mac80211 will call iwl_mac_stop() from the mac80211 suspend function
-        * first but since iwl_mac_stop() has no knowledge of who the caller is,
-        * it will not call apm_ops.stop() to stop the DMA operation.
-        * Calling apm_ops.stop here to make sure we stop the DMA.
-        *
-        * But of course ... if we have configured WoWLAN then we did other
-        * things already :-)
-        */
-       if (!priv->wowlan)
-               iwl_apm_stop(priv);
-
-       return 0;
-}
-
-int iwl_resume(struct iwl_priv *priv)
-{
-       bool hw_rfkill = false;
-
-       iwl_enable_interrupts(priv);
-
-       if (!(iwl_read32(priv, CSR_GP_CNTRL) &
-                               CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))
-               hw_rfkill = true;
-
-       if (hw_rfkill)
-               set_bit(STATUS_RF_KILL_HW, &priv->status);
-       else
-               clear_bit(STATUS_RF_KILL_HW, &priv->status);
-
-       wiphy_rfkill_set_hw_state(priv->hw->wiphy, hw_rfkill);
-
-       return 0;
-}
-
-#endif /* CONFIG_PM */