iwlwifi: clean up (wowlan) suspend flow

In the WoWLAN suspend flow, instead of accessing
registers directly, ask the transport to do the
required setup at the end of suspend. If the
transport doesn't implement this, don't tell the
stack we support WoWLAN.

When the device suspends w/o WoWLAN, mac80211
will have stopped it already, which has already
called iwl_apm_stop() via stop_hw(). Thus, it
isn't necessary to call it again in pcie_suspend
and we can simply do nothing there.

This unifies the regular and WoWLAN suspend.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h
index e2f21cf..83f04c9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.h
@@ -210,6 +210,9 @@
  * @wake_any_queue: wake all the queues of a specfic context IWL_RXON_CTX_*
  * @stop_device:stops the whole device (embedded CPU put to reset)
  *	May sleep
+ * @wowlan_suspend: put the device into the correct mode for WoWLAN during
+ *	suspend. This is optional, if not implemented WoWLAN will not be
+ *	supported. This callback may sleep.
  * @send_cmd:send a host command
  *	May sleep only if CMD_SYNC is set
  * @tx: send an skb
@@ -247,6 +250,8 @@
 	void (*fw_alive)(struct iwl_trans *trans);
 	void (*stop_device)(struct iwl_trans *trans);
 
+	void (*wowlan_suspend)(struct iwl_trans *trans);
+
 	void (*wake_any_queue)(struct iwl_trans *trans,
 			       enum iwl_rxon_context_id ctx,
 			       const char *msg);
@@ -396,6 +401,12 @@
 	trans->state = IWL_TRANS_NO_FW;
 }
 
+static inline void iwl_trans_wowlan_suspend(struct iwl_trans *trans)
+{
+	might_sleep();
+	trans->ops->wowlan_suspend(trans);
+}
+
 static inline void iwl_trans_wake_any_queue(struct iwl_trans *trans,
 					    enum iwl_rxon_context_id ctx,
 					    const char *msg)