linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] cfg80211: add PM hooks
@ 2008-12-15  3:50 Bob Copeland
  2008-12-17 15:35 ` John W. Linville
  0 siblings, 1 reply; 5+ messages in thread
From: Bob Copeland @ 2008-12-15  3:50 UTC (permalink / raw)
  To: linux-wireless; +Cc: johannes, mabbaswireless, Bob Copeland

From: Johannes Berg <johannes@sipsolutions.net>

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>
---
 include/net/cfg80211.h |    6 ++++++
 net/wireless/sysfs.c   |   30 ++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 23c0ab7..0432eb6 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -450,6 +450,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.
  *
@@ -499,6 +502,9 @@ struct ieee80211_channel;
  * @set_channel: Set channel
  */
 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);
diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c
index 29f820e..021cda6 100644
--- a/net/wireless/sysfs.c
+++ b/net/wireless/sysfs.c
@@ -60,6 +60,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,
@@ -68,6 +96,8 @@ struct class ieee80211_class = {
 #ifdef CONFIG_HOTPLUG
 	.dev_uevent = wiphy_uevent,
 #endif
+	.suspend = wiphy_suspend,
+	.resume = wiphy_resume,
 };
 
 int wiphy_sysfs_init(void)
-- 
1.6.0.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/3] cfg80211: add PM hooks
  2008-12-15  3:50 [PATCH v2 1/3] cfg80211: add PM hooks Bob Copeland
@ 2008-12-17 15:35 ` John W. Linville
  2008-12-17 18:10   ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: John W. Linville @ 2008-12-17 15:35 UTC (permalink / raw)
  To: Bob Copeland; +Cc: linux-wireless, johannes, mabbaswireless

On Sun, Dec 14, 2008 at 10:50:37PM -0500, Bob Copeland wrote:
> From: Johannes Berg <johannes@sipsolutions.net>
> 
> 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>

Is cfg80211 the right place for these?  Is it likely that any
non-mac80211 users of cfg80211 will ever want to use these hooks?

John
-- 
John W. Linville		Linux should be at the core
linville@tuxdriver.com			of your literate lifestyle.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/3] cfg80211: add PM hooks
  2008-12-17 15:35 ` John W. Linville
@ 2008-12-17 18:10   ` Johannes Berg
  2008-12-18 15:30     ` John W. Linville
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2008-12-17 18:10 UTC (permalink / raw)
  To: John W. Linville; +Cc: Bob Copeland, linux-wireless, mabbaswireless

On Wed, 2008-12-17 at 10:35 -0500, John W. Linville wrote:
> On Sun, Dec 14, 2008 at 10:50:37PM -0500, Bob Copeland wrote:
> > From: Johannes Berg <johannes@sipsolutions.net>
> > 
> > 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>
> 
> Is cfg80211 the right place for these?  Is it likely that any
> non-mac80211 users of cfg80211 will ever want to use these hooks?

That's a good question. But even if non-mac80211 won't use this, I don't
see how to get notifications in mac80211 w/o involving cfg80211, since
mac80211 doesn't really have a way to get at the ops there without this,
does it?

johannes


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/3] cfg80211: add PM hooks
  2008-12-17 18:10   ` Johannes Berg
@ 2008-12-18 15:30     ` John W. Linville
  2008-12-18 17:52       ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: John W. Linville @ 2008-12-18 15:30 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Bob Copeland, linux-wireless, mabbaswireless

On Wed, Dec 17, 2008 at 07:10:49PM +0100, Johannes Berg wrote:
> On Wed, 2008-12-17 at 10:35 -0500, John W. Linville wrote:
> > On Sun, Dec 14, 2008 at 10:50:37PM -0500, Bob Copeland wrote:
> > > From: Johannes Berg <johannes@sipsolutions.net>
> > > 
> > > 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>
> > 
> > Is cfg80211 the right place for these?  Is it likely that any
> > non-mac80211 users of cfg80211 will ever want to use these hooks?
> 
> That's a good question. But even if non-mac80211 won't use this, I don't
> see how to get notifications in mac80211 w/o involving cfg80211, since
> mac80211 doesn't really have a way to get at the ops there without this,
> does it?

No, I suppose not.

I'm not too familiar with the internals of the PM stuff.  Is there
any guarantee that the cfg80211 suspend stuff will run before the
bus-specific suspend stuff?  Is this a concern?

John
-- 
John W. Linville		Linux should be at the core
linville@tuxdriver.com			of your literate lifestyle.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/3] cfg80211: add PM hooks
  2008-12-18 15:30     ` John W. Linville
@ 2008-12-18 17:52       ` Johannes Berg
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Berg @ 2008-12-18 17:52 UTC (permalink / raw)
  To: John W. Linville; +Cc: Bob Copeland, linux-wireless, mabbaswireless

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]

On Thu, 2008-12-18 at 10:30 -0500, John W. Linville wrote:

> I'm not too familiar with the internals of the PM stuff.  Is there
> any guarantee that the cfg80211 suspend stuff will run before the
> bus-specific suspend stuff?  Is this a concern?

Yes, it is a concern, but yes, it is guaranteed that the suspend() runs
before the hw suspend, and resume() afterward the hw resume.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-12-18 17:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-15  3:50 [PATCH v2 1/3] cfg80211: add PM hooks Bob Copeland
2008-12-17 15:35 ` John W. Linville
2008-12-17 18:10   ` Johannes Berg
2008-12-18 15:30     ` John W. Linville
2008-12-18 17:52       ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).