cfg80211: add PM hooks
authorJohannes Berg <johannes@sipsolutions.net>
Mon, 19 Jan 2009 16:20:52 +0000 (11:20 -0500)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 29 Jan 2009 21:00:51 +0000 (16:00 -0500)
This should help implement suspend/resume in mac80211, these
hooks will be run before the device is suspended and after it
resumes. Therefore, they can touch the hardware as much as
they want to.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
include/net/cfg80211.h
net/wireless/sysfs.c

index c7da88f..f19c3e1 100644 (file)
@@ -472,6 +472,9 @@ struct ieee80211_channel;
  * wireless extensions but this is subject to reevaluation as soon as this
  * code is used more widely and we have a first user without wext.
  *
+ * @suspend: wiphy device needs to be suspended
+ * @resume: wiphy device needs to be resumed
+ *
  * @add_virtual_intf: create a new virtual interface with the given name,
  *     must set the struct wireless_dev's iftype.
  *
@@ -525,6 +528,9 @@ struct ieee80211_channel;
  * @set_mgmt_extra_ie: Set extra IE data for management frames
  */
 struct cfg80211_ops {
+       int     (*suspend)(struct wiphy *wiphy);
+       int     (*resume)(struct wiphy *wiphy);
+
        int     (*add_virtual_intf)(struct wiphy *wiphy, char *name,
                                    enum nl80211_iftype type, u32 *flags,
                                    struct vif_params *params);
index 79a3828..26a72b0 100644 (file)
@@ -55,6 +55,34 @@ static int wiphy_uevent(struct device *dev, struct kobj_uevent_env *env)
 }
 #endif
 
+static int wiphy_suspend(struct device *dev, pm_message_t state)
+{
+       struct cfg80211_registered_device *rdev = dev_to_rdev(dev);
+       int ret = 0;
+
+       if (rdev->ops->suspend) {
+               rtnl_lock();
+               ret = rdev->ops->suspend(&rdev->wiphy);
+               rtnl_unlock();
+       }
+
+       return ret;
+}
+
+static int wiphy_resume(struct device *dev)
+{
+       struct cfg80211_registered_device *rdev = dev_to_rdev(dev);
+       int ret = 0;
+
+       if (rdev->ops->resume) {
+               rtnl_lock();
+               ret = rdev->ops->resume(&rdev->wiphy);
+               rtnl_unlock();
+       }
+
+       return ret;
+}
+
 struct class ieee80211_class = {
        .name = "ieee80211",
        .owner = THIS_MODULE,
@@ -63,6 +91,8 @@ struct class ieee80211_class = {
 #ifdef CONFIG_HOTPLUG
        .dev_uevent = wiphy_uevent,
 #endif
+       .suspend = wiphy_suspend,
+       .resume = wiphy_resume,
 };
 
 int wiphy_sysfs_init(void)