linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] nl80211: Avoid checking for empty WoWLAN triggers
@ 2012-07-10 10:07 Mohammed Shafi Shajakhan
  2012-07-10 11:06 ` Johannes Berg
  0 siblings, 1 reply; 10+ messages in thread
From: Mohammed Shafi Shajakhan @ 2012-07-10 10:07 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Mohammed Shafi Shajakhan

From: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

Previously we would check in nl80211 with an empty
cfg80211_wowlan structure to check for 'iw phy phyX wowlan enable'
with empty arguments (or) no triggers and disable WoWLAN.
It would be nice to inform the user that the wowlan enable is
provided with zero arugments in userspace itself rather than
disabling it in nl80211/cfg80211. A correspoding patch
was also proposed for 'iw' tool.

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
---
 net/wireless/nl80211.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 2a5cdb6..fb63f72 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -6363,17 +6363,20 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
 {
 	struct cfg80211_registered_device *rdev = info->user_ptr[0];
 	struct nlattr *tb[NUM_NL80211_WOWLAN_TRIG];
-	struct cfg80211_wowlan no_triggers = {};
 	struct cfg80211_wowlan new_triggers = {};
+	struct cfg80211_wowlan *ntrig;
 	struct wiphy_wowlan_support *wowlan = &rdev->wiphy.wowlan;
 	int err, i;
 	bool prev_enabled = rdev->wowlan;
+	bool wow_disabled = false;
 
 	if (!rdev->wiphy.wowlan.flags && !rdev->wiphy.wowlan.n_patterns)
 		return -EOPNOTSUPP;
 
-	if (!info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS])
+	if (!info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]) {
+		wow_disabled = true;
 		goto no_triggers;
+	}
 
 	err = nla_parse(tb, MAX_NL80211_WOWLAN_TRIG,
 			nla_data(info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]),
@@ -6484,18 +6487,18 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
 		}
 	}
 
-	if (memcmp(&new_triggers, &no_triggers, sizeof(new_triggers))) {
-		struct cfg80211_wowlan *ntrig;
-		ntrig = kmemdup(&new_triggers, sizeof(new_triggers),
-				GFP_KERNEL);
-		if (!ntrig) {
-			err = -ENOMEM;
-			goto error;
-		}
-		cfg80211_rdev_free_wowlan(rdev);
-		rdev->wowlan = ntrig;
-	} else {
- no_triggers:
+	ntrig = kmemdup(&new_triggers, sizeof(new_triggers),
+			GFP_KERNEL);
+	if (!ntrig) {
+		err = -ENOMEM;
+		goto error;
+	}
+	cfg80211_rdev_free_wowlan(rdev);
+	rdev->wowlan = ntrig;
+
+no_triggers:
+
+	if (wow_disabled) {
 		cfg80211_rdev_free_wowlan(rdev);
 		rdev->wowlan = NULL;
 	}
-- 
1.7.0.4


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

end of thread, other threads:[~2012-07-12 15:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-10 10:07 [RFC] nl80211: Avoid checking for empty WoWLAN triggers Mohammed Shafi Shajakhan
2012-07-10 11:06 ` Johannes Berg
2012-07-10 11:16   ` Mohammed Shafi Shajakhan
2012-07-10 11:20     ` Johannes Berg
2012-07-10 11:36       ` Mohammed Shafi Shajakhan
2012-07-11  5:33       ` Mohammed Shafi Shajakhan
2012-07-12 14:24         ` Johannes Berg
2012-07-12 15:14           ` Mohammed Shafi Shajakhan
2012-07-12 15:17             ` Johannes Berg
2012-07-12 15:33               ` Mohammed Shafi Shajakhan

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).