Commit bf6a0579f60ae5225280c82cc52b51db1255e7fb

Authored by Juuso Oikarinen
Committed by John W. Linville
1 parent 73b30dfe4f

cfg80211: Fix power save state after interface type change

Currently cfg80211 only configures the PSM state to the driver upon creation
of a new virtual interface, but not after interface type change. The mac80211
on the other hand reinitializes its sdata structure every time the interface
type is changed, losing the PSM configuration.

Hence, if the interface type is changed to, say, ad-hoc and then back to
managed, "iw wlan0 get power_save" will claim that PSM is enabled, when in
fact on mac80211 level it is not.

Fix this in cfg80211 by configuring the PSM state to the driver each time
the interface is brought up instead of just when the interface is created.

Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

Showing 1 changed file with 13 additions and 7 deletions Side-by-side Diff

... ... @@ -718,13 +718,6 @@
718 718 wdev->ps = false;
719 719 /* allow mac80211 to determine the timeout */
720 720 wdev->ps_timeout = -1;
721   - if (rdev->ops->set_power_mgmt)
722   - if (rdev->ops->set_power_mgmt(wdev->wiphy, dev,
723   - wdev->ps,
724   - wdev->ps_timeout)) {
725   - /* assume this means it's off */
726   - wdev->ps = false;
727   - }
728 721  
729 722 if (!dev->ethtool_ops)
730 723 dev->ethtool_ops = &cfg80211_ethtool_ops;
... ... @@ -813,6 +806,19 @@
813 806 rdev->opencount++;
814 807 mutex_unlock(&rdev->devlist_mtx);
815 808 cfg80211_unlock_rdev(rdev);
  809 +
  810 + /*
  811 + * Configure power management to the driver here so that its
  812 + * correctly set also after interface type changes etc.
  813 + */
  814 + if (wdev->iftype == NL80211_IFTYPE_STATION &&
  815 + rdev->ops->set_power_mgmt)
  816 + if (rdev->ops->set_power_mgmt(wdev->wiphy, dev,
  817 + wdev->ps,
  818 + wdev->ps_timeout)) {
  819 + /* assume this means it's off */
  820 + wdev->ps = false;
  821 + }
816 822 break;
817 823 case NETDEV_UNREGISTER:
818 824 /*