diff options
author | Eliad Peller <eliad@wizery.com> | 2011-12-06 05:15:05 -0500 |
---|---|---|
committer | Luciano Coelho <coelho@ti.com> | 2011-12-08 05:32:36 -0500 |
commit | abc47470ef63cdde2efdf358ae373afb16f358c0 (patch) | |
tree | 4cfc94c6df38625e39414e917a3c5942670001db /drivers | |
parent | e0d62536d032db689adf9c8162a9d2caf4714f44 (diff) |
wl12xx: fix testmode test/interrogate commands
fix several issues in testmode test/interrogate commands:
1. check the driver state is not OFF.
2. wakeup the chip from elp (if needed)
3. fix memory leak in wl1271_tm_cmd_interrogate()
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/wl12xx/testmode.c | 72 |
1 files changed, 53 insertions, 19 deletions
diff --git a/drivers/net/wireless/wl12xx/testmode.c b/drivers/net/wireless/wl12xx/testmode.c index 61fff45686a..2f9ebff2ded 100644 --- a/drivers/net/wireless/wl12xx/testmode.c +++ b/drivers/net/wireless/wl12xx/testmode.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "debug.h" | 29 | #include "debug.h" |
30 | #include "acx.h" | 30 | #include "acx.h" |
31 | #include "reg.h" | 31 | #include "reg.h" |
32 | #include "ps.h" | ||
32 | 33 | ||
33 | #define WL1271_TM_MAX_DATA_LENGTH 1024 | 34 | #define WL1271_TM_MAX_DATA_LENGTH 1024 |
34 | 35 | ||
@@ -88,31 +89,47 @@ static int wl1271_tm_cmd_test(struct wl1271 *wl, struct nlattr *tb[]) | |||
88 | return -EMSGSIZE; | 89 | return -EMSGSIZE; |
89 | 90 | ||
90 | mutex_lock(&wl->mutex); | 91 | mutex_lock(&wl->mutex); |
91 | ret = wl1271_cmd_test(wl, buf, buf_len, answer); | ||
92 | mutex_unlock(&wl->mutex); | ||
93 | 92 | ||
93 | if (wl->state == WL1271_STATE_OFF) { | ||
94 | ret = -EINVAL; | ||
95 | goto out; | ||
96 | } | ||
97 | |||
98 | ret = wl1271_ps_elp_wakeup(wl); | ||
99 | if (ret < 0) | ||
100 | goto out; | ||
101 | |||
102 | ret = wl1271_cmd_test(wl, buf, buf_len, answer); | ||
94 | if (ret < 0) { | 103 | if (ret < 0) { |
95 | wl1271_warning("testmode cmd test failed: %d", ret); | 104 | wl1271_warning("testmode cmd test failed: %d", ret); |
96 | return ret; | 105 | goto out_sleep; |
97 | } | 106 | } |
98 | 107 | ||
99 | if (answer) { | 108 | if (answer) { |
100 | len = nla_total_size(buf_len); | 109 | len = nla_total_size(buf_len); |
101 | skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, len); | 110 | skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, len); |
102 | if (!skb) | 111 | if (!skb) { |
103 | return -ENOMEM; | 112 | ret = -ENOMEM; |
113 | goto out_sleep; | ||
114 | } | ||
104 | 115 | ||
105 | NLA_PUT(skb, WL1271_TM_ATTR_DATA, buf_len, buf); | 116 | NLA_PUT(skb, WL1271_TM_ATTR_DATA, buf_len, buf); |
106 | ret = cfg80211_testmode_reply(skb); | 117 | ret = cfg80211_testmode_reply(skb); |
107 | if (ret < 0) | 118 | if (ret < 0) |
108 | return ret; | 119 | goto out_sleep; |
109 | } | 120 | } |
110 | 121 | ||
111 | return 0; | 122 | out_sleep: |
123 | wl1271_ps_elp_sleep(wl); | ||
124 | out: | ||
125 | mutex_unlock(&wl->mutex); | ||
126 | |||
127 | return ret; | ||
112 | 128 | ||
113 | nla_put_failure: | 129 | nla_put_failure: |
114 | kfree_skb(skb); | 130 | kfree_skb(skb); |
115 | return -EMSGSIZE; | 131 | ret = -EMSGSIZE; |
132 | goto out_sleep; | ||
116 | } | 133 | } |
117 | 134 | ||
118 | static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) | 135 | static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) |
@@ -129,33 +146,50 @@ static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) | |||
129 | 146 | ||
130 | ie_id = nla_get_u8(tb[WL1271_TM_ATTR_IE_ID]); | 147 | ie_id = nla_get_u8(tb[WL1271_TM_ATTR_IE_ID]); |
131 | 148 | ||
149 | mutex_lock(&wl->mutex); | ||
150 | |||
151 | if (wl->state == WL1271_STATE_OFF) { | ||
152 | ret = -EINVAL; | ||
153 | goto out; | ||
154 | } | ||
155 | |||
156 | ret = wl1271_ps_elp_wakeup(wl); | ||
157 | if (ret < 0) | ||
158 | goto out; | ||
159 | |||
132 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | 160 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); |
133 | if (!cmd) | 161 | if (!cmd) { |
134 | return -ENOMEM; | 162 | ret = -ENOMEM; |
163 | goto out_sleep; | ||
164 | } | ||
135 | 165 | ||
136 | mutex_lock(&wl->mutex); | ||
137 | ret = wl1271_cmd_interrogate(wl, ie_id, cmd, sizeof(*cmd)); | 166 | ret = wl1271_cmd_interrogate(wl, ie_id, cmd, sizeof(*cmd)); |
138 | mutex_unlock(&wl->mutex); | ||
139 | |||
140 | if (ret < 0) { | 167 | if (ret < 0) { |
141 | wl1271_warning("testmode cmd interrogate failed: %d", ret); | 168 | wl1271_warning("testmode cmd interrogate failed: %d", ret); |
142 | kfree(cmd); | 169 | goto out_free; |
143 | return ret; | ||
144 | } | 170 | } |
145 | 171 | ||
146 | skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, sizeof(*cmd)); | 172 | skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, sizeof(*cmd)); |
147 | if (!skb) { | 173 | if (!skb) { |
148 | kfree(cmd); | 174 | ret = -ENOMEM; |
149 | return -ENOMEM; | 175 | goto out_free; |
150 | } | 176 | } |
151 | 177 | ||
152 | NLA_PUT(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd); | 178 | NLA_PUT(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd); |
153 | 179 | ||
154 | return 0; | 180 | out_free: |
181 | kfree(cmd); | ||
182 | out_sleep: | ||
183 | wl1271_ps_elp_sleep(wl); | ||
184 | out: | ||
185 | mutex_unlock(&wl->mutex); | ||
186 | |||
187 | return ret; | ||
155 | 188 | ||
156 | nla_put_failure: | 189 | nla_put_failure: |
157 | kfree_skb(skb); | 190 | kfree_skb(skb); |
158 | return -EMSGSIZE; | 191 | ret = -EMSGSIZE; |
192 | goto out_free; | ||
159 | } | 193 | } |
160 | 194 | ||
161 | static int wl1271_tm_cmd_configure(struct wl1271 *wl, struct nlattr *tb[]) | 195 | static int wl1271_tm_cmd_configure(struct wl1271 *wl, struct nlattr *tb[]) |