ath9k: Fix wow init/deinit
authorSujith Manoharan <c_manoha@qca.qualcomm.com>
Fri, 30 Jan 2015 13:35:26 +0000 (19:05 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 3 Feb 2015 13:31:03 +0000 (15:31 +0200)
Registering the card as a wakeup source needs to
be done once, during initialization. When the WOW
configuration changes, the card's status as wakeup
source needs to be changed too and this is done
via the set_wakeup() callback. Also, make sure
the device is removed properly using ath9k_deinit_wow().

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/ath/ath9k/init.c
drivers/net/wireless/ath/ath9k/wow.c

index e84b576..4209d7b 100644 (file)
@@ -838,6 +838,7 @@ struct ath9k_wow_pattern {
 
 #ifdef CONFIG_ATH9K_WOW
 void ath9k_init_wow(struct ieee80211_hw *hw);
+void ath9k_deinit_wow(struct ieee80211_hw *hw);
 int ath9k_suspend(struct ieee80211_hw *hw,
                  struct cfg80211_wowlan *wowlan);
 int ath9k_resume(struct ieee80211_hw *hw);
@@ -846,6 +847,9 @@ void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled);
 static inline void ath9k_init_wow(struct ieee80211_hw *hw)
 {
 }
+static inline void ath9k_deinit_wow(struct ieee80211_hw *hw)
+{
+}
 static inline int ath9k_suspend(struct ieee80211_hw *hw,
                                struct cfg80211_wowlan *wowlan)
 {
index 2aef14e..6c6e884 100644 (file)
@@ -996,6 +996,7 @@ void ath9k_deinit_device(struct ath_softc *sc)
        ath9k_ps_restore(sc);
 
        ath9k_deinit_debug(sc);
+       ath9k_deinit_wow(hw);
        ieee80211_unregister_hw(hw);
        ath_rx_cleanup(sc);
        ath9k_deinit_softc(sc);
index 1b005c6..8bcbaa9 100644 (file)
@@ -336,20 +336,34 @@ int ath9k_resume(struct ieee80211_hw *hw)
 void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled)
 {
        struct ath_softc *sc = hw->priv;
+       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 
        mutex_lock(&sc->mutex);
-       device_init_wakeup(sc->dev, 1);
        device_set_wakeup_enable(sc->dev, enabled);
        mutex_unlock(&sc->mutex);
+
+       ath_dbg(common, WOW, "WoW wakeup source is %s\n",
+               (enabled) ? "enabled" : "disabled");
 }
 
 void ath9k_init_wow(struct ieee80211_hw *hw)
 {
        struct ath_softc *sc = hw->priv;
 
-       if ((sc->driver_data & ATH9K_PCI_WOW) && device_can_wakeup(sc->dev))
+       if (sc->driver_data & ATH9K_PCI_WOW) {
                hw->wiphy->wowlan = &ath9k_wowlan_support;
 
-       atomic_set(&sc->wow_sleep_proc_intr, -1);
-       atomic_set(&sc->wow_got_bmiss_intr, -1);
+               atomic_set(&sc->wow_sleep_proc_intr, -1);
+               atomic_set(&sc->wow_got_bmiss_intr, -1);
+
+               device_init_wakeup(sc->dev, 1);
+       }
+}
+
+void ath9k_deinit_wow(struct ieee80211_hw *hw)
+{
+       struct ath_softc *sc = hw->priv;
+
+       if (sc->driver_data & ATH9K_PCI_WOW)
+               device_init_wakeup(sc->dev, 0);
 }