aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorYair Shapira <yair.shapira@ti.com>2012-07-11 11:48:07 -0400
committerLuciano Coelho <coelho@ti.com>2012-07-18 08:08:22 -0400
commitbf722d1defc3020e9382106045f24c2978407e55 (patch)
tree3ef70ddc612b7ea9fa1fc931a2f3a0cdef9d5776 /drivers/net/wireless
parentff324317e6133ed4a88380eb675a93c76a9e0d5e (diff)
wlcore: make usage of nla_put clearer
handle errors of nla_put() inside the if(nla_put...) {} This makes the code simpler and clearer because: we take advantage from the fact that we have only one nla_put in our routines (so no real need for goto label). this avoids ugly goto forward followed by goto backward. Signed-off-by: Yair Shapira <yair.shapira@ti.com> Signed-off-by: Luciano Coelho <coelho@ti.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/ti/wlcore/testmode.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/drivers/net/wireless/ti/wlcore/testmode.c b/drivers/net/wireless/ti/wlcore/testmode.c
index 081f1750cb88..49e5ee1525c9 100644
--- a/drivers/net/wireless/ti/wlcore/testmode.c
+++ b/drivers/net/wireless/ti/wlcore/testmode.c
@@ -129,8 +129,12 @@ static int wl1271_tm_cmd_test(struct wl1271 *wl, struct nlattr *tb[])
129 goto out_sleep; 129 goto out_sleep;
130 } 130 }
131 131
132 if (nla_put(skb, WL1271_TM_ATTR_DATA, buf_len, buf)) 132 if (nla_put(skb, WL1271_TM_ATTR_DATA, buf_len, buf)) {
133 goto nla_put_failure; 133 kfree_skb(skb);
134 ret = -EMSGSIZE;
135 goto out_sleep;
136 }
137
134 ret = cfg80211_testmode_reply(skb); 138 ret = cfg80211_testmode_reply(skb);
135 if (ret < 0) 139 if (ret < 0)
136 goto out_sleep; 140 goto out_sleep;
@@ -142,11 +146,6 @@ out:
142 mutex_unlock(&wl->mutex); 146 mutex_unlock(&wl->mutex);
143 147
144 return ret; 148 return ret;
145
146nla_put_failure:
147 kfree_skb(skb);
148 ret = -EMSGSIZE;
149 goto out_sleep;
150} 149}
151 150
152static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) 151static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[])
@@ -192,8 +191,12 @@ static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[])
192 goto out_free; 191 goto out_free;
193 } 192 }
194 193
195 if (nla_put(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd)) 194 if (nla_put(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd)) {
196 goto nla_put_failure; 195 kfree_skb(skb);
196 ret = -EMSGSIZE;
197 goto out_free;
198 }
199
197 ret = cfg80211_testmode_reply(skb); 200 ret = cfg80211_testmode_reply(skb);
198 if (ret < 0) 201 if (ret < 0)
199 goto out_free; 202 goto out_free;
@@ -206,11 +209,6 @@ out:
206 mutex_unlock(&wl->mutex); 209 mutex_unlock(&wl->mutex);
207 210
208 return ret; 211 return ret;
209
210nla_put_failure:
211 kfree_skb(skb);
212 ret = -EMSGSIZE;
213 goto out_free;
214} 212}
215 213
216static int wl1271_tm_cmd_configure(struct wl1271 *wl, struct nlattr *tb[]) 214static int wl1271_tm_cmd_configure(struct wl1271 *wl, struct nlattr *tb[])
@@ -343,8 +341,12 @@ static int wl12xx_tm_cmd_get_mac(struct wl1271 *wl, struct nlattr *tb[])
343 goto out; 341 goto out;
344 } 342 }
345 343
346 if (nla_put(skb, WL1271_TM_ATTR_DATA, ETH_ALEN, mac_addr)) 344 if (nla_put(skb, WL1271_TM_ATTR_DATA, ETH_ALEN, mac_addr)) {
347 goto nla_put_failure; 345 kfree_skb(skb);
346 ret = -EMSGSIZE;
347 goto out;
348 }
349
348 ret = cfg80211_testmode_reply(skb); 350 ret = cfg80211_testmode_reply(skb);
349 if (ret < 0) 351 if (ret < 0)
350 goto out; 352 goto out;
@@ -352,11 +354,6 @@ static int wl12xx_tm_cmd_get_mac(struct wl1271 *wl, struct nlattr *tb[])
352out: 354out:
353 mutex_unlock(&wl->mutex); 355 mutex_unlock(&wl->mutex);
354 return ret; 356 return ret;
355
356nla_put_failure:
357 kfree_skb(skb);
358 ret = -EMSGSIZE;
359 goto out;
360} 357}
361 358
362int wl1271_tm_cmd(struct ieee80211_hw *hw, void *data, int len) 359int wl1271_tm_cmd(struct ieee80211_hw *hw, void *data, int len)