aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/quantenna/qtnfmac
diff options
context:
space:
mode:
authorSergey Matyukevich <sergey.matyukevich.os@quantenna.com>2018-10-05 06:11:33 -0400
committerKalle Valo <kvalo@codeaurora.org>2018-10-05 07:01:18 -0400
commitc6ed298ffe09fb2e1770705c9ff6d74b41581fbb (patch)
tree8762c20156839a4b213eebc9ea61d62254ed14f2 /drivers/net/wireless/quantenna/qtnfmac
parent75001bbc07656466830e2d914ef5cc24784efbf7 (diff)
qtnfmac: cleanup and unify command error handling
Unify command error handling using qtnf_cmd_resp_result_decode function. Do not duplicate error messages in command handlers and cfg80211 callbacks: report 'cmd exec fail' only on control path internal failure. Remove redundant 'unlikely' macros. Signed-off-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/quantenna/qtnfmac')
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/cfg80211.c64
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/commands.c518
2 files changed, 149 insertions, 433 deletions
diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index c4961e16d91a..4631277092bf 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -141,8 +141,8 @@ qtnf_change_virtual_intf(struct wiphy *wiphy,
141 141
142 ret = qtnf_cmd_send_change_intf_type(vif, type, mac_addr); 142 ret = qtnf_cmd_send_change_intf_type(vif, type, mac_addr);
143 if (ret) { 143 if (ret) {
144 pr_err("VIF%u.%u: failed to change VIF type: %d\n", 144 pr_err("VIF%u.%u: failed to change type to %d\n",
145 vif->mac->macid, vif->vifid, ret); 145 vif->mac->macid, vif->vifid, type);
146 return ret; 146 return ret;
147 } 147 }
148 148
@@ -228,18 +228,22 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy,
228 if (params) 228 if (params)
229 mac_addr = params->macaddr; 229 mac_addr = params->macaddr;
230 230
231 if (qtnf_cmd_send_add_intf(vif, type, mac_addr)) { 231 ret = qtnf_cmd_send_add_intf(vif, type, mac_addr);
232 pr_err("VIF%u.%u: failed to add VIF\n", mac->macid, vif->vifid); 232 if (ret) {
233 pr_err("VIF%u.%u: failed to add VIF %pM\n",
234 mac->macid, vif->vifid, mac_addr);
233 goto err_cmd; 235 goto err_cmd;
234 } 236 }
235 237
236 if (!is_valid_ether_addr(vif->mac_addr)) { 238 if (!is_valid_ether_addr(vif->mac_addr)) {
237 pr_err("VIF%u.%u: FW reported bad MAC: %pM\n", 239 pr_err("VIF%u.%u: FW reported bad MAC: %pM\n",
238 mac->macid, vif->vifid, vif->mac_addr); 240 mac->macid, vif->vifid, vif->mac_addr);
241 ret = -EINVAL;
239 goto err_mac; 242 goto err_mac;
240 } 243 }
241 244
242 if (qtnf_core_net_attach(mac, vif, name, name_assign_t)) { 245 ret = qtnf_core_net_attach(mac, vif, name, name_assign_t);
246 if (ret) {
243 pr_err("VIF%u.%u: failed to attach netdev\n", mac->macid, 247 pr_err("VIF%u.%u: failed to attach netdev\n", mac->macid,
244 vif->vifid); 248 vif->vifid);
245 goto err_net; 249 goto err_net;
@@ -255,7 +259,7 @@ err_mac:
255err_cmd: 259err_cmd:
256 vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED; 260 vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
257 261
258 return ERR_PTR(-EFAULT); 262 return ERR_PTR(ret);
259} 263}
260 264
261static int qtnf_mgmt_set_appie(struct qtnf_vif *vif, 265static int qtnf_mgmt_set_appie(struct qtnf_vif *vif,
@@ -334,12 +338,11 @@ static int qtnf_stop_ap(struct wiphy *wiphy, struct net_device *dev)
334 qtnf_scan_done(vif->mac, true); 338 qtnf_scan_done(vif->mac, true);
335 339
336 ret = qtnf_cmd_send_stop_ap(vif); 340 ret = qtnf_cmd_send_stop_ap(vif);
337 if (ret) { 341 if (ret)
338 pr_err("VIF%u.%u: failed to stop AP operation in FW\n", 342 pr_err("VIF%u.%u: failed to stop AP operation in FW\n",
339 vif->mac->macid, vif->vifid); 343 vif->mac->macid, vif->vifid);
340 344
341 netif_carrier_off(vif->netdev); 345 netif_carrier_off(vif->netdev);
342 }
343 346
344 return ret; 347 return ret;
345} 348}
@@ -589,6 +592,7 @@ qtnf_del_station(struct wiphy *wiphy, struct net_device *dev,
589 if (ret) 592 if (ret)
590 pr_err("VIF%u.%u: failed to delete STA %pM\n", 593 pr_err("VIF%u.%u: failed to delete STA %pM\n",
591 vif->mac->macid, vif->vifid, params->mac); 594 vif->mac->macid, vif->vifid, params->mac);
595
592 return ret; 596 return ret;
593} 597}
594 598
@@ -596,21 +600,25 @@ static int
596qtnf_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) 600qtnf_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
597{ 601{
598 struct qtnf_wmac *mac = wiphy_priv(wiphy); 602 struct qtnf_wmac *mac = wiphy_priv(wiphy);
603 int ret;
599 604
600 cancel_delayed_work_sync(&mac->scan_timeout); 605 cancel_delayed_work_sync(&mac->scan_timeout);
601 606
602 mac->scan_req = request; 607 mac->scan_req = request;
603 608
604 if (qtnf_cmd_send_scan(mac)) { 609 ret = qtnf_cmd_send_scan(mac);
610 if (ret) {
605 pr_err("MAC%u: failed to start scan\n", mac->macid); 611 pr_err("MAC%u: failed to start scan\n", mac->macid);
606 mac->scan_req = NULL; 612 mac->scan_req = NULL;
607 return -EFAULT; 613 goto out;
608 } 614 }
609 615
616 pr_debug("MAC%u: scan started\n", mac->macid);
610 queue_delayed_work(mac->bus->workqueue, &mac->scan_timeout, 617 queue_delayed_work(mac->bus->workqueue, &mac->scan_timeout,
611 QTNF_SCAN_TIMEOUT_SEC * HZ); 618 QTNF_SCAN_TIMEOUT_SEC * HZ);
612 619
613 return 0; 620out:
621 return ret;
614} 622}
615 623
616static int 624static int
@@ -630,12 +638,13 @@ qtnf_connect(struct wiphy *wiphy, struct net_device *dev,
630 638
631 ret = qtnf_cmd_send_connect(vif, sme); 639 ret = qtnf_cmd_send_connect(vif, sme);
632 if (ret) { 640 if (ret) {
633 pr_err("VIF%u.%u: failed to connect\n", vif->mac->macid, 641 pr_err("VIF%u.%u: failed to connect\n",
634 vif->vifid); 642 vif->mac->macid, vif->vifid);
635 return ret; 643 goto out;
636 } 644 }
637 645
638 return 0; 646out:
647 return ret;
639} 648}
640 649
641static int 650static int
@@ -661,8 +670,8 @@ qtnf_disconnect(struct wiphy *wiphy, struct net_device *dev,
661 670
662 ret = qtnf_cmd_send_disconnect(vif, reason_code); 671 ret = qtnf_cmd_send_disconnect(vif, reason_code);
663 if (ret) 672 if (ret)
664 pr_err("VIF%u.%u: failed to disconnect\n", mac->macid, 673 pr_err("VIF%u.%u: failed to disconnect\n",
665 vif->vifid); 674 mac->macid, vif->vifid);
666 675
667 if (vif->wdev.current_bss) { 676 if (vif->wdev.current_bss) {
668 netif_carrier_off(vif->netdev); 677 netif_carrier_off(vif->netdev);
@@ -740,7 +749,6 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device *dev,
740 default: 749 default:
741 pr_debug("failed to get chan(%d) stats from card\n", 750 pr_debug("failed to get chan(%d) stats from card\n",
742 chan->hw_value); 751 chan->hw_value);
743 ret = -EINVAL;
744 break; 752 break;
745 } 753 }
746 754
@@ -763,6 +771,7 @@ qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
763 ret = qtnf_cmd_get_channel(vif, chandef); 771 ret = qtnf_cmd_get_channel(vif, chandef);
764 if (ret) { 772 if (ret) {
765 pr_err("%s: failed to get channel: %d\n", ndev->name, ret); 773 pr_err("%s: failed to get channel: %d\n", ndev->name, ret);
774 ret = -ENODATA;
766 goto out; 775 goto out;
767 } 776 }
768 777
@@ -772,6 +781,7 @@ qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
772 chandef->center_freq1, chandef->center_freq2, 781 chandef->center_freq1, chandef->center_freq2,
773 chandef->width); 782 chandef->width);
774 ret = -ENODATA; 783 ret = -ENODATA;
784 goto out;
775 } 785 }
776 786
777out: 787out:
@@ -841,10 +851,8 @@ static int qtnf_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
841 851
842 ret = qtnf_cmd_send_pm_set(vif, enabled ? QLINK_PM_AUTO_STANDBY : 852 ret = qtnf_cmd_send_pm_set(vif, enabled ? QLINK_PM_AUTO_STANDBY :
843 QLINK_PM_OFF, timeout); 853 QLINK_PM_OFF, timeout);
844 if (ret) { 854 if (ret)
845 pr_err("%s: failed to set PM mode ret=%d\n", dev->name, ret); 855 pr_err("%s: failed to set PM mode ret=%d\n", dev->name, ret);
846 return ret;
847 }
848 856
849 return ret; 857 return ret;
850} 858}
@@ -964,9 +972,16 @@ static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,
964 972
965 ret = qtnf_cmd_reg_notify(bus, req); 973 ret = qtnf_cmd_reg_notify(bus, req);
966 if (ret) { 974 if (ret) {
967 if (ret != -EOPNOTSUPP && ret != -EALREADY) 975 if (ret == -EOPNOTSUPP) {
976 pr_warn("reg update not supported\n");
977 } else if (ret == -EALREADY) {
978 pr_info("regulatory domain is already set to %c%c",
979 req->alpha2[0], req->alpha2[1]);
980 } else {
968 pr_err("failed to update reg domain to %c%c\n", 981 pr_err("failed to update reg domain to %c%c\n",
969 req->alpha2[0], req->alpha2[1]); 982 req->alpha2[0], req->alpha2[1]);
983 }
984
970 return; 985 return;
971 } 986 }
972 987
@@ -1139,7 +1154,8 @@ void qtnf_netdev_updown(struct net_device *ndev, bool up)
1139 struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev); 1154 struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev);
1140 1155
1141 if (qtnf_cmd_send_updown_intf(vif, up)) 1156 if (qtnf_cmd_send_updown_intf(vif, up))
1142 pr_err("failed to send up/down command to FW\n"); 1157 pr_err("failed to send %s command to VIF%u.%u\n",
1158 up ? "UP" : "DOWN", vif->mac->macid, vif->vifid);
1143} 1159}
1144 1160
1145void qtnf_virtual_intf_cleanup(struct net_device *ndev) 1161void qtnf_virtual_intf_cleanup(struct net_device *ndev)
diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index ae9e77300533..63d93cf3ace0 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -80,7 +80,6 @@ static int qtnf_cmd_resp_result_decode(enum qlink_cmd_result qcode)
80static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus, 80static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
81 struct sk_buff *cmd_skb, 81 struct sk_buff *cmd_skb,
82 struct sk_buff **response_skb, 82 struct sk_buff **response_skb,
83 u16 *result_code,
84 size_t const_resp_size, 83 size_t const_resp_size,
85 size_t *var_resp_size) 84 size_t *var_resp_size)
86{ 85{
@@ -88,7 +87,8 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
88 const struct qlink_resp *resp; 87 const struct qlink_resp *resp;
89 struct sk_buff *resp_skb = NULL; 88 struct sk_buff *resp_skb = NULL;
90 u16 cmd_id; 89 u16 cmd_id;
91 u8 mac_id, vif_id; 90 u8 mac_id;
91 u8 vif_id;
92 int ret; 92 int ret;
93 93
94 cmd = (struct qlink_cmd *)cmd_skb->data; 94 cmd = (struct qlink_cmd *)cmd_skb->data;
@@ -97,8 +97,11 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
97 vif_id = cmd->vifid; 97 vif_id = cmd->vifid;
98 cmd->mhdr.len = cpu_to_le16(cmd_skb->len); 98 cmd->mhdr.len = cpu_to_le16(cmd_skb->len);
99 99
100 if (unlikely(bus->fw_state != QTNF_FW_STATE_ACTIVE && 100 pr_debug("VIF%u.%u cmd=0x%.4X\n", mac_id, vif_id,
101 le16_to_cpu(cmd->cmd_id) != QLINK_CMD_FW_INIT)) { 101 le16_to_cpu(cmd->cmd_id));
102
103 if (bus->fw_state != QTNF_FW_STATE_ACTIVE &&
104 le16_to_cpu(cmd->cmd_id) != QLINK_CMD_FW_INIT) {
102 pr_warn("VIF%u.%u: drop cmd 0x%.4X in fw state %d\n", 105 pr_warn("VIF%u.%u: drop cmd 0x%.4X in fw state %d\n",
103 mac_id, vif_id, le16_to_cpu(cmd->cmd_id), 106 mac_id, vif_id, le16_to_cpu(cmd->cmd_id),
104 bus->fw_state); 107 bus->fw_state);
@@ -106,24 +109,16 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
106 return -ENODEV; 109 return -ENODEV;
107 } 110 }
108 111
109 pr_debug("VIF%u.%u cmd=0x%.4X\n", mac_id, vif_id,
110 le16_to_cpu(cmd->cmd_id));
111
112 ret = qtnf_trans_send_cmd_with_resp(bus, cmd_skb, &resp_skb); 112 ret = qtnf_trans_send_cmd_with_resp(bus, cmd_skb, &resp_skb);
113 113 if (ret)
114 if (unlikely(ret))
115 goto out; 114 goto out;
116 115
117 resp = (const struct qlink_resp *)resp_skb->data; 116 resp = (const struct qlink_resp *)resp_skb->data;
118 ret = qtnf_cmd_check_reply_header(resp, cmd_id, mac_id, vif_id, 117 ret = qtnf_cmd_check_reply_header(resp, cmd_id, mac_id, vif_id,
119 const_resp_size); 118 const_resp_size);
120 119 if (ret)
121 if (unlikely(ret))
122 goto out; 120 goto out;
123 121
124 if (likely(result_code))
125 *result_code = le16_to_cpu(resp->result);
126
127 /* Return length of variable part of response */ 122 /* Return length of variable part of response */
128 if (response_skb && var_resp_size) 123 if (response_skb && var_resp_size)
129 *var_resp_size = le16_to_cpu(resp->mhdr.len) - const_resp_size; 124 *var_resp_size = le16_to_cpu(resp->mhdr.len) - const_resp_size;
@@ -134,14 +129,18 @@ out:
134 else 129 else
135 consume_skb(resp_skb); 130 consume_skb(resp_skb);
136 131
132 if (!ret && resp)
133 return qtnf_cmd_resp_result_decode(le16_to_cpu(resp->result));
134
135 pr_warn("VIF%u.%u: cmd 0x%.4X failed: %d\n",
136 mac_id, vif_id, le16_to_cpu(cmd->cmd_id), ret);
137
137 return ret; 138 return ret;
138} 139}
139 140
140static inline int qtnf_cmd_send(struct qtnf_bus *bus, 141static inline int qtnf_cmd_send(struct qtnf_bus *bus, struct sk_buff *cmd_skb)
141 struct sk_buff *cmd_skb,
142 u16 *result_code)
143{ 142{
144 return qtnf_cmd_send_with_reply(bus, cmd_skb, NULL, result_code, 143 return qtnf_cmd_send_with_reply(bus, cmd_skb, NULL,
145 sizeof(struct qlink_resp), NULL); 144 sizeof(struct qlink_resp), NULL);
146} 145}
147 146
@@ -228,7 +227,6 @@ int qtnf_cmd_send_start_ap(struct qtnf_vif *vif,
228 struct sk_buff *cmd_skb; 227 struct sk_buff *cmd_skb;
229 struct qlink_cmd_start_ap *cmd; 228 struct qlink_cmd_start_ap *cmd;
230 struct qlink_auth_encr *aen; 229 struct qlink_auth_encr *aen;
231 u16 res_code = QLINK_CMD_RESULT_OK;
232 int ret; 230 int ret;
233 int i; 231 int i;
234 232
@@ -329,30 +327,21 @@ int qtnf_cmd_send_start_ap(struct qtnf_vif *vif,
329 } 327 }
330 328
331 qtnf_bus_lock(vif->mac->bus); 329 qtnf_bus_lock(vif->mac->bus);
332 330 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
333 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 331 if (ret)
334
335 if (unlikely(ret))
336 goto out;
337
338 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
339 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
340 vif->vifid, res_code);
341 ret = -EFAULT;
342 goto out; 332 goto out;
343 }
344 333
345 netif_carrier_on(vif->netdev); 334 netif_carrier_on(vif->netdev);
346 335
347out: 336out:
348 qtnf_bus_unlock(vif->mac->bus); 337 qtnf_bus_unlock(vif->mac->bus);
338
349 return ret; 339 return ret;
350} 340}
351 341
352int qtnf_cmd_send_stop_ap(struct qtnf_vif *vif) 342int qtnf_cmd_send_stop_ap(struct qtnf_vif *vif)
353{ 343{
354 struct sk_buff *cmd_skb; 344 struct sk_buff *cmd_skb;
355 u16 res_code = QLINK_CMD_RESULT_OK;
356 int ret; 345 int ret;
357 346
358 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 347 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -362,23 +351,13 @@ int qtnf_cmd_send_stop_ap(struct qtnf_vif *vif)
362 return -ENOMEM; 351 return -ENOMEM;
363 352
364 qtnf_bus_lock(vif->mac->bus); 353 qtnf_bus_lock(vif->mac->bus);
365 354 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
366 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 355 if (ret)
367
368 if (unlikely(ret))
369 goto out;
370
371 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
372 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
373 vif->vifid, res_code);
374 ret = -EFAULT;
375 goto out; 356 goto out;
376 }
377
378 netif_carrier_off(vif->netdev);
379 357
380out: 358out:
381 qtnf_bus_unlock(vif->mac->bus); 359 qtnf_bus_unlock(vif->mac->bus);
360
382 return ret; 361 return ret;
383} 362}
384 363
@@ -386,7 +365,6 @@ int qtnf_cmd_send_register_mgmt(struct qtnf_vif *vif, u16 frame_type, bool reg)
386{ 365{
387 struct sk_buff *cmd_skb; 366 struct sk_buff *cmd_skb;
388 struct qlink_cmd_mgmt_frame_register *cmd; 367 struct qlink_cmd_mgmt_frame_register *cmd;
389 u16 res_code = QLINK_CMD_RESULT_OK;
390 int ret; 368 int ret;
391 369
392 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 370 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -401,20 +379,13 @@ int qtnf_cmd_send_register_mgmt(struct qtnf_vif *vif, u16 frame_type, bool reg)
401 cmd->frame_type = cpu_to_le16(frame_type); 379 cmd->frame_type = cpu_to_le16(frame_type);
402 cmd->do_register = reg; 380 cmd->do_register = reg;
403 381
404 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 382 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
405 383 if (ret)
406 if (unlikely(ret))
407 goto out;
408
409 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
410 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
411 vif->vifid, res_code);
412 ret = -EFAULT;
413 goto out; 384 goto out;
414 }
415 385
416out: 386out:
417 qtnf_bus_unlock(vif->mac->bus); 387 qtnf_bus_unlock(vif->mac->bus);
388
418 return ret; 389 return ret;
419} 390}
420 391
@@ -423,7 +394,6 @@ int qtnf_cmd_send_mgmt_frame(struct qtnf_vif *vif, u32 cookie, u16 flags,
423{ 394{
424 struct sk_buff *cmd_skb; 395 struct sk_buff *cmd_skb;
425 struct qlink_cmd_mgmt_frame_tx *cmd; 396 struct qlink_cmd_mgmt_frame_tx *cmd;
426 u16 res_code = QLINK_CMD_RESULT_OK;
427 int ret; 397 int ret;
428 398
429 if (sizeof(*cmd) + len > QTNF_MAX_CMD_BUF_SIZE) { 399 if (sizeof(*cmd) + len > QTNF_MAX_CMD_BUF_SIZE) {
@@ -448,20 +418,13 @@ int qtnf_cmd_send_mgmt_frame(struct qtnf_vif *vif, u32 cookie, u16 flags,
448 if (len && buf) 418 if (len && buf)
449 qtnf_cmd_skb_put_buffer(cmd_skb, buf, len); 419 qtnf_cmd_skb_put_buffer(cmd_skb, buf, len);
450 420
451 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 421 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
452 422 if (ret)
453 if (unlikely(ret))
454 goto out; 423 goto out;
455 424
456 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
457 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
458 vif->vifid, res_code);
459 ret = -EFAULT;
460 goto out;
461 }
462
463out: 425out:
464 qtnf_bus_unlock(vif->mac->bus); 426 qtnf_bus_unlock(vif->mac->bus);
427
465 return ret; 428 return ret;
466} 429}
467 430
@@ -469,7 +432,6 @@ int qtnf_cmd_send_mgmt_set_appie(struct qtnf_vif *vif, u8 frame_type,
469 const u8 *buf, size_t len) 432 const u8 *buf, size_t len)
470{ 433{
471 struct sk_buff *cmd_skb; 434 struct sk_buff *cmd_skb;
472 u16 res_code = QLINK_CMD_RESULT_OK;
473 int ret; 435 int ret;
474 436
475 if (len > QTNF_MAX_CMD_BUF_SIZE) { 437 if (len > QTNF_MAX_CMD_BUF_SIZE) {
@@ -487,21 +449,13 @@ int qtnf_cmd_send_mgmt_set_appie(struct qtnf_vif *vif, u8 frame_type,
487 qtnf_cmd_tlv_ie_set_add(cmd_skb, frame_type, buf, len); 449 qtnf_cmd_tlv_ie_set_add(cmd_skb, frame_type, buf, len);
488 450
489 qtnf_bus_lock(vif->mac->bus); 451 qtnf_bus_lock(vif->mac->bus);
490 452 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
491 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 453 if (ret)
492
493 if (unlikely(ret))
494 goto out; 454 goto out;
495 455
496 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
497 pr_err("VIF%u.%u frame %u: CMD failed: %u\n", vif->mac->macid,
498 vif->vifid, frame_type, res_code);
499 ret = -EFAULT;
500 goto out;
501 }
502
503out: 456out:
504 qtnf_bus_unlock(vif->mac->bus); 457 qtnf_bus_unlock(vif->mac->bus);
458
505 return ret; 459 return ret;
506} 460}
507 461
@@ -730,7 +684,6 @@ int qtnf_cmd_get_sta_info(struct qtnf_vif *vif, const u8 *sta_mac,
730 struct qlink_cmd_get_sta_info *cmd; 684 struct qlink_cmd_get_sta_info *cmd;
731 const struct qlink_resp_get_sta_info *resp; 685 const struct qlink_resp_get_sta_info *resp;
732 size_t var_resp_len; 686 size_t var_resp_len;
733 u16 res_code = QLINK_CMD_RESULT_OK;
734 int ret = 0; 687 int ret = 0;
735 688
736 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 689 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -745,31 +698,13 @@ int qtnf_cmd_get_sta_info(struct qtnf_vif *vif, const u8 *sta_mac,
745 ether_addr_copy(cmd->sta_addr, sta_mac); 698 ether_addr_copy(cmd->sta_addr, sta_mac);
746 699
747 ret = qtnf_cmd_send_with_reply(vif->mac->bus, cmd_skb, &resp_skb, 700 ret = qtnf_cmd_send_with_reply(vif->mac->bus, cmd_skb, &resp_skb,
748 &res_code, sizeof(*resp), 701 sizeof(*resp), &var_resp_len);
749 &var_resp_len); 702 if (ret)
750
751 if (unlikely(ret))
752 goto out;
753
754 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
755 switch (res_code) {
756 case QLINK_CMD_RESULT_ENOTFOUND:
757 pr_warn("VIF%u.%u: %pM STA not found\n",
758 vif->mac->macid, vif->vifid, sta_mac);
759 ret = -ENOENT;
760 break;
761 default:
762 pr_err("VIF%u.%u: can't get info for %pM: %u\n",
763 vif->mac->macid, vif->vifid, sta_mac, res_code);
764 ret = -EFAULT;
765 break;
766 }
767 goto out; 703 goto out;
768 }
769 704
770 resp = (const struct qlink_resp_get_sta_info *)resp_skb->data; 705 resp = (const struct qlink_resp_get_sta_info *)resp_skb->data;
771 706
772 if (unlikely(!ether_addr_equal(sta_mac, resp->sta_addr))) { 707 if (!ether_addr_equal(sta_mac, resp->sta_addr)) {
773 pr_err("VIF%u.%u: wrong mac in reply: %pM != %pM\n", 708 pr_err("VIF%u.%u: wrong mac in reply: %pM != %pM\n",
774 vif->mac->macid, vif->vifid, resp->sta_addr, sta_mac); 709 vif->mac->macid, vif->vifid, resp->sta_addr, sta_mac);
775 ret = -EINVAL; 710 ret = -EINVAL;
@@ -795,7 +730,6 @@ static int qtnf_cmd_send_add_change_intf(struct qtnf_vif *vif,
795 struct sk_buff *cmd_skb, *resp_skb = NULL; 730 struct sk_buff *cmd_skb, *resp_skb = NULL;
796 struct qlink_cmd_manage_intf *cmd; 731 struct qlink_cmd_manage_intf *cmd;
797 const struct qlink_resp_manage_intf *resp; 732 const struct qlink_resp_manage_intf *resp;
798 u16 res_code = QLINK_CMD_RESULT_OK;
799 int ret = 0; 733 int ret = 0;
800 734
801 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 735 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -828,17 +762,9 @@ static int qtnf_cmd_send_add_change_intf(struct qtnf_vif *vif,
828 eth_zero_addr(cmd->intf_info.mac_addr); 762 eth_zero_addr(cmd->intf_info.mac_addr);
829 763
830 ret = qtnf_cmd_send_with_reply(vif->mac->bus, cmd_skb, &resp_skb, 764 ret = qtnf_cmd_send_with_reply(vif->mac->bus, cmd_skb, &resp_skb,
831 &res_code, sizeof(*resp), NULL); 765 sizeof(*resp), NULL);
832 766 if (ret)
833 if (unlikely(ret))
834 goto out;
835
836 ret = qtnf_cmd_resp_result_decode(res_code);
837 if (ret) {
838 pr_err("VIF%u.%u: CMD %d failed: %u\n", vif->mac->macid,
839 vif->vifid, cmd_type, res_code);
840 goto out; 767 goto out;
841 }
842 768
843 resp = (const struct qlink_resp_manage_intf *)resp_skb->data; 769 resp = (const struct qlink_resp_manage_intf *)resp_skb->data;
844 ether_addr_copy(vif->mac_addr, resp->intf_info.mac_addr); 770 ether_addr_copy(vif->mac_addr, resp->intf_info.mac_addr);
@@ -868,7 +794,6 @@ int qtnf_cmd_send_del_intf(struct qtnf_vif *vif)
868{ 794{
869 struct sk_buff *cmd_skb; 795 struct sk_buff *cmd_skb;
870 struct qlink_cmd_manage_intf *cmd; 796 struct qlink_cmd_manage_intf *cmd;
871 u16 res_code = QLINK_CMD_RESULT_OK;
872 int ret = 0; 797 int ret = 0;
873 798
874 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 799 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -897,17 +822,9 @@ int qtnf_cmd_send_del_intf(struct qtnf_vif *vif)
897 822
898 eth_zero_addr(cmd->intf_info.mac_addr); 823 eth_zero_addr(cmd->intf_info.mac_addr);
899 824
900 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 825 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
901 826 if (ret)
902 if (unlikely(ret))
903 goto out;
904
905 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
906 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
907 vif->vifid, res_code);
908 ret = -EFAULT;
909 goto out; 827 goto out;
910 }
911 828
912out: 829out:
913 qtnf_bus_unlock(vif->mac->bus); 830 qtnf_bus_unlock(vif->mac->bus);
@@ -1732,7 +1649,6 @@ int qtnf_cmd_get_mac_info(struct qtnf_wmac *mac)
1732 struct sk_buff *cmd_skb, *resp_skb = NULL; 1649 struct sk_buff *cmd_skb, *resp_skb = NULL;
1733 const struct qlink_resp_get_mac_info *resp; 1650 const struct qlink_resp_get_mac_info *resp;
1734 size_t var_data_len; 1651 size_t var_data_len;
1735 u16 res_code = QLINK_CMD_RESULT_OK;
1736 int ret = 0; 1652 int ret = 0;
1737 1653
1738 cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, QLINK_VIFID_RSVD, 1654 cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, QLINK_VIFID_RSVD,
@@ -1742,18 +1658,11 @@ int qtnf_cmd_get_mac_info(struct qtnf_wmac *mac)
1742 return -ENOMEM; 1658 return -ENOMEM;
1743 1659
1744 qtnf_bus_lock(mac->bus); 1660 qtnf_bus_lock(mac->bus);
1745 1661 ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb,
1746 ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb, &res_code,
1747 sizeof(*resp), &var_data_len); 1662 sizeof(*resp), &var_data_len);
1748 if (unlikely(ret)) 1663 if (ret)
1749 goto out; 1664 goto out;
1750 1665
1751 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
1752 pr_err("MAC%u: CMD failed: %u\n", mac->macid, res_code);
1753 ret = -EFAULT;
1754 goto out;
1755 }
1756
1757 resp = (const struct qlink_resp_get_mac_info *)resp_skb->data; 1666 resp = (const struct qlink_resp_get_mac_info *)resp_skb->data;
1758 qtnf_cmd_resp_proc_mac_info(mac, resp); 1667 qtnf_cmd_resp_proc_mac_info(mac, resp);
1759 ret = qtnf_parse_variable_mac_info(mac, resp->var_info, var_data_len); 1668 ret = qtnf_parse_variable_mac_info(mac, resp->var_info, var_data_len);
@@ -1769,7 +1678,6 @@ int qtnf_cmd_get_hw_info(struct qtnf_bus *bus)
1769{ 1678{
1770 struct sk_buff *cmd_skb, *resp_skb = NULL; 1679 struct sk_buff *cmd_skb, *resp_skb = NULL;
1771 const struct qlink_resp_get_hw_info *resp; 1680 const struct qlink_resp_get_hw_info *resp;
1772 u16 res_code = QLINK_CMD_RESULT_OK;
1773 int ret = 0; 1681 int ret = 0;
1774 size_t info_len; 1682 size_t info_len;
1775 1683
@@ -1780,18 +1688,10 @@ int qtnf_cmd_get_hw_info(struct qtnf_bus *bus)
1780 return -ENOMEM; 1688 return -ENOMEM;
1781 1689
1782 qtnf_bus_lock(bus); 1690 qtnf_bus_lock(bus);
1783 1691 ret = qtnf_cmd_send_with_reply(bus, cmd_skb, &resp_skb,
1784 ret = qtnf_cmd_send_with_reply(bus, cmd_skb, &resp_skb, &res_code,
1785 sizeof(*resp), &info_len); 1692 sizeof(*resp), &info_len);
1786 1693 if (ret)
1787 if (unlikely(ret))
1788 goto out;
1789
1790 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
1791 pr_err("cmd exec failed: 0x%.4X\n", res_code);
1792 ret = -EFAULT;
1793 goto out; 1694 goto out;
1794 }
1795 1695
1796 resp = (const struct qlink_resp_get_hw_info *)resp_skb->data; 1696 resp = (const struct qlink_resp_get_hw_info *)resp_skb->data;
1797 ret = qtnf_cmd_resp_proc_hw_info(bus, resp, info_len); 1697 ret = qtnf_cmd_resp_proc_hw_info(bus, resp, info_len);
@@ -1810,7 +1710,6 @@ int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,
1810 size_t info_len; 1710 size_t info_len;
1811 struct qlink_cmd_band_info_get *cmd; 1711 struct qlink_cmd_band_info_get *cmd;
1812 struct qlink_resp_band_info_get *resp; 1712 struct qlink_resp_band_info_get *resp;
1813 u16 res_code = QLINK_CMD_RESULT_OK;
1814 int ret = 0; 1713 int ret = 0;
1815 u8 qband; 1714 u8 qband;
1816 1715
@@ -1838,18 +1737,10 @@ int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,
1838 cmd->band = qband; 1737 cmd->band = qband;
1839 1738
1840 qtnf_bus_lock(mac->bus); 1739 qtnf_bus_lock(mac->bus);
1841 1740 ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb,
1842 ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb, &res_code,
1843 sizeof(*resp), &info_len); 1741 sizeof(*resp), &info_len);
1844 1742 if (ret)
1845 if (unlikely(ret))
1846 goto out;
1847
1848 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
1849 pr_err("MAC%u: CMD failed: %u\n", mac->macid, res_code);
1850 ret = -EFAULT;
1851 goto out; 1743 goto out;
1852 }
1853 1744
1854 resp = (struct qlink_resp_band_info_get *)resp_skb->data; 1745 resp = (struct qlink_resp_band_info_get *)resp_skb->data;
1855 if (resp->band != qband) { 1746 if (resp->band != qband) {
@@ -1873,7 +1764,6 @@ int qtnf_cmd_send_get_phy_params(struct qtnf_wmac *mac)
1873 struct sk_buff *cmd_skb, *resp_skb = NULL; 1764 struct sk_buff *cmd_skb, *resp_skb = NULL;
1874 size_t response_size; 1765 size_t response_size;
1875 struct qlink_resp_phy_params *resp; 1766 struct qlink_resp_phy_params *resp;
1876 u16 res_code = QLINK_CMD_RESULT_OK;
1877 int ret = 0; 1767 int ret = 0;
1878 1768
1879 cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0, 1769 cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
@@ -1883,18 +1773,10 @@ int qtnf_cmd_send_get_phy_params(struct qtnf_wmac *mac)
1883 return -ENOMEM; 1773 return -ENOMEM;
1884 1774
1885 qtnf_bus_lock(mac->bus); 1775 qtnf_bus_lock(mac->bus);
1886 1776 ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb,
1887 ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb, &res_code,
1888 sizeof(*resp), &response_size); 1777 sizeof(*resp), &response_size);
1889 1778 if (ret)
1890 if (unlikely(ret))
1891 goto out;
1892
1893 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
1894 pr_err("MAC%u: CMD failed: %u\n", mac->macid, res_code);
1895 ret = -EFAULT;
1896 goto out; 1779 goto out;
1897 }
1898 1780
1899 resp = (struct qlink_resp_phy_params *)resp_skb->data; 1781 resp = (struct qlink_resp_phy_params *)resp_skb->data;
1900 ret = qtnf_cmd_resp_proc_phy_params(mac, resp->info, response_size); 1782 ret = qtnf_cmd_resp_proc_phy_params(mac, resp->info, response_size);
@@ -1910,7 +1792,6 @@ int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed)
1910{ 1792{
1911 struct wiphy *wiphy = priv_to_wiphy(mac); 1793 struct wiphy *wiphy = priv_to_wiphy(mac);
1912 struct sk_buff *cmd_skb; 1794 struct sk_buff *cmd_skb;
1913 u16 res_code = QLINK_CMD_RESULT_OK;
1914 int ret = 0; 1795 int ret = 0;
1915 1796
1916 cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0, 1797 cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
@@ -1931,26 +1812,19 @@ int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed)
1931 qtnf_cmd_skb_put_tlv_u8(cmd_skb, QTN_TLV_ID_COVERAGE_CLASS, 1812 qtnf_cmd_skb_put_tlv_u8(cmd_skb, QTN_TLV_ID_COVERAGE_CLASS,
1932 wiphy->coverage_class); 1813 wiphy->coverage_class);
1933 1814
1934 ret = qtnf_cmd_send(mac->bus, cmd_skb, &res_code); 1815 ret = qtnf_cmd_send(mac->bus, cmd_skb);
1935 1816 if (ret)
1936 if (unlikely(ret))
1937 goto out;
1938
1939 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
1940 pr_err("MAC%u: CMD failed: %u\n", mac->macid, res_code);
1941 ret = -EFAULT;
1942 goto out; 1817 goto out;
1943 }
1944 1818
1945out: 1819out:
1946 qtnf_bus_unlock(mac->bus); 1820 qtnf_bus_unlock(mac->bus);
1821
1947 return ret; 1822 return ret;
1948} 1823}
1949 1824
1950int qtnf_cmd_send_init_fw(struct qtnf_bus *bus) 1825int qtnf_cmd_send_init_fw(struct qtnf_bus *bus)
1951{ 1826{
1952 struct sk_buff *cmd_skb; 1827 struct sk_buff *cmd_skb;
1953 u16 res_code = QLINK_CMD_RESULT_OK;
1954 int ret = 0; 1828 int ret = 0;
1955 1829
1956 cmd_skb = qtnf_cmd_alloc_new_cmdskb(QLINK_MACID_RSVD, QLINK_VIFID_RSVD, 1830 cmd_skb = qtnf_cmd_alloc_new_cmdskb(QLINK_MACID_RSVD, QLINK_VIFID_RSVD,
@@ -1960,20 +1834,13 @@ int qtnf_cmd_send_init_fw(struct qtnf_bus *bus)
1960 return -ENOMEM; 1834 return -ENOMEM;
1961 1835
1962 qtnf_bus_lock(bus); 1836 qtnf_bus_lock(bus);
1963 1837 ret = qtnf_cmd_send(bus, cmd_skb);
1964 ret = qtnf_cmd_send(bus, cmd_skb, &res_code); 1838 if (ret)
1965
1966 if (unlikely(ret))
1967 goto out;
1968
1969 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
1970 pr_err("cmd exec failed: 0x%.4X\n", res_code);
1971 ret = -EFAULT;
1972 goto out; 1839 goto out;
1973 }
1974 1840
1975out: 1841out:
1976 qtnf_bus_unlock(bus); 1842 qtnf_bus_unlock(bus);
1843
1977 return ret; 1844 return ret;
1978} 1845}
1979 1846
@@ -1988,9 +1855,7 @@ void qtnf_cmd_send_deinit_fw(struct qtnf_bus *bus)
1988 return; 1855 return;
1989 1856
1990 qtnf_bus_lock(bus); 1857 qtnf_bus_lock(bus);
1991 1858 qtnf_cmd_send(bus, cmd_skb);
1992 qtnf_cmd_send(bus, cmd_skb, NULL);
1993
1994 qtnf_bus_unlock(bus); 1859 qtnf_bus_unlock(bus);
1995} 1860}
1996 1861
@@ -1999,7 +1864,6 @@ int qtnf_cmd_send_add_key(struct qtnf_vif *vif, u8 key_index, bool pairwise,
1999{ 1864{
2000 struct sk_buff *cmd_skb; 1865 struct sk_buff *cmd_skb;
2001 struct qlink_cmd_add_key *cmd; 1866 struct qlink_cmd_add_key *cmd;
2002 u16 res_code = QLINK_CMD_RESULT_OK;
2003 int ret = 0; 1867 int ret = 0;
2004 1868
2005 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 1869 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -2031,19 +1895,13 @@ int qtnf_cmd_send_add_key(struct qtnf_vif *vif, u8 key_index, bool pairwise,
2031 params->seq, 1895 params->seq,
2032 params->seq_len); 1896 params->seq_len);
2033 1897
2034 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 1898 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
2035 if (unlikely(ret)) 1899 if (ret)
2036 goto out;
2037
2038 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
2039 pr_err("VIF%u.%u: CMD failed: %u\n",
2040 vif->mac->macid, vif->vifid, res_code);
2041 ret = -EFAULT;
2042 goto out; 1900 goto out;
2043 }
2044 1901
2045out: 1902out:
2046 qtnf_bus_unlock(vif->mac->bus); 1903 qtnf_bus_unlock(vif->mac->bus);
1904
2047 return ret; 1905 return ret;
2048} 1906}
2049 1907
@@ -2052,7 +1910,6 @@ int qtnf_cmd_send_del_key(struct qtnf_vif *vif, u8 key_index, bool pairwise,
2052{ 1910{
2053 struct sk_buff *cmd_skb; 1911 struct sk_buff *cmd_skb;
2054 struct qlink_cmd_del_key *cmd; 1912 struct qlink_cmd_del_key *cmd;
2055 u16 res_code = QLINK_CMD_RESULT_OK;
2056 int ret = 0; 1913 int ret = 0;
2057 1914
2058 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 1915 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -2072,19 +1929,14 @@ int qtnf_cmd_send_del_key(struct qtnf_vif *vif, u8 key_index, bool pairwise,
2072 1929
2073 cmd->key_index = key_index; 1930 cmd->key_index = key_index;
2074 cmd->pairwise = pairwise; 1931 cmd->pairwise = pairwise;
2075 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code);
2076 if (unlikely(ret))
2077 goto out;
2078 1932
2079 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) { 1933 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
2080 pr_err("VIF%u.%u: CMD failed: %u\n", 1934 if (ret)
2081 vif->mac->macid, vif->vifid, res_code);
2082 ret = -EFAULT;
2083 goto out; 1935 goto out;
2084 }
2085 1936
2086out: 1937out:
2087 qtnf_bus_unlock(vif->mac->bus); 1938 qtnf_bus_unlock(vif->mac->bus);
1939
2088 return ret; 1940 return ret;
2089} 1941}
2090 1942
@@ -2093,7 +1945,6 @@ int qtnf_cmd_send_set_default_key(struct qtnf_vif *vif, u8 key_index,
2093{ 1945{
2094 struct sk_buff *cmd_skb; 1946 struct sk_buff *cmd_skb;
2095 struct qlink_cmd_set_def_key *cmd; 1947 struct qlink_cmd_set_def_key *cmd;
2096 u16 res_code = QLINK_CMD_RESULT_OK;
2097 int ret = 0; 1948 int ret = 0;
2098 1949
2099 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 1950 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -2108,19 +1959,14 @@ int qtnf_cmd_send_set_default_key(struct qtnf_vif *vif, u8 key_index,
2108 cmd->key_index = key_index; 1959 cmd->key_index = key_index;
2109 cmd->unicast = unicast; 1960 cmd->unicast = unicast;
2110 cmd->multicast = multicast; 1961 cmd->multicast = multicast;
2111 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code);
2112 if (unlikely(ret))
2113 goto out;
2114 1962
2115 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) { 1963 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
2116 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid, 1964 if (ret)
2117 vif->vifid, res_code);
2118 ret = -EFAULT;
2119 goto out; 1965 goto out;
2120 }
2121 1966
2122out: 1967out:
2123 qtnf_bus_unlock(vif->mac->bus); 1968 qtnf_bus_unlock(vif->mac->bus);
1969
2124 return ret; 1970 return ret;
2125} 1971}
2126 1972
@@ -2128,7 +1974,6 @@ int qtnf_cmd_send_set_default_mgmt_key(struct qtnf_vif *vif, u8 key_index)
2128{ 1974{
2129 struct sk_buff *cmd_skb; 1975 struct sk_buff *cmd_skb;
2130 struct qlink_cmd_set_def_mgmt_key *cmd; 1976 struct qlink_cmd_set_def_mgmt_key *cmd;
2131 u16 res_code = QLINK_CMD_RESULT_OK;
2132 int ret = 0; 1977 int ret = 0;
2133 1978
2134 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 1979 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -2141,19 +1986,14 @@ int qtnf_cmd_send_set_default_mgmt_key(struct qtnf_vif *vif, u8 key_index)
2141 1986
2142 cmd = (struct qlink_cmd_set_def_mgmt_key *)cmd_skb->data; 1987 cmd = (struct qlink_cmd_set_def_mgmt_key *)cmd_skb->data;
2143 cmd->key_index = key_index; 1988 cmd->key_index = key_index;
2144 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code);
2145 if (unlikely(ret))
2146 goto out;
2147 1989
2148 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) { 1990 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
2149 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid, 1991 if (ret)
2150 vif->vifid, res_code);
2151 ret = -EFAULT;
2152 goto out; 1992 goto out;
2153 }
2154 1993
2155out: 1994out:
2156 qtnf_bus_unlock(vif->mac->bus); 1995 qtnf_bus_unlock(vif->mac->bus);
1996
2157 return ret; 1997 return ret;
2158} 1998}
2159 1999
@@ -2183,7 +2023,6 @@ int qtnf_cmd_send_change_sta(struct qtnf_vif *vif, const u8 *mac,
2183{ 2023{
2184 struct sk_buff *cmd_skb; 2024 struct sk_buff *cmd_skb;
2185 struct qlink_cmd_change_sta *cmd; 2025 struct qlink_cmd_change_sta *cmd;
2186 u16 res_code = QLINK_CMD_RESULT_OK;
2187 int ret = 0; 2026 int ret = 0;
2188 2027
2189 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 2028 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -2214,19 +2053,13 @@ int qtnf_cmd_send_change_sta(struct qtnf_vif *vif, const u8 *mac,
2214 goto out; 2053 goto out;
2215 } 2054 }
2216 2055
2217 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 2056 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
2218 if (unlikely(ret)) 2057 if (ret)
2219 goto out; 2058 goto out;
2220 2059
2221 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
2222 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
2223 vif->vifid, res_code);
2224 ret = -EFAULT;
2225 goto out;
2226 }
2227
2228out: 2060out:
2229 qtnf_bus_unlock(vif->mac->bus); 2061 qtnf_bus_unlock(vif->mac->bus);
2062
2230 return ret; 2063 return ret;
2231} 2064}
2232 2065
@@ -2235,7 +2068,6 @@ int qtnf_cmd_send_del_sta(struct qtnf_vif *vif,
2235{ 2068{
2236 struct sk_buff *cmd_skb; 2069 struct sk_buff *cmd_skb;
2237 struct qlink_cmd_del_sta *cmd; 2070 struct qlink_cmd_del_sta *cmd;
2238 u16 res_code = QLINK_CMD_RESULT_OK;
2239 int ret = 0; 2071 int ret = 0;
2240 2072
2241 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 2073 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -2256,19 +2088,13 @@ int qtnf_cmd_send_del_sta(struct qtnf_vif *vif,
2256 cmd->subtype = params->subtype; 2088 cmd->subtype = params->subtype;
2257 cmd->reason_code = cpu_to_le16(params->reason_code); 2089 cmd->reason_code = cpu_to_le16(params->reason_code);
2258 2090
2259 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 2091 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
2260 if (unlikely(ret)) 2092 if (ret)
2261 goto out;
2262
2263 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
2264 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
2265 vif->vifid, res_code);
2266 ret = -EFAULT;
2267 goto out; 2093 goto out;
2268 }
2269 2094
2270out: 2095out:
2271 qtnf_bus_unlock(vif->mac->bus); 2096 qtnf_bus_unlock(vif->mac->bus);
2097
2272 return ret; 2098 return ret;
2273} 2099}
2274 2100
@@ -2312,7 +2138,6 @@ static void qtnf_cmd_randmac_tlv_add(struct sk_buff *cmd_skb,
2312int qtnf_cmd_send_scan(struct qtnf_wmac *mac) 2138int qtnf_cmd_send_scan(struct qtnf_wmac *mac)
2313{ 2139{
2314 struct sk_buff *cmd_skb; 2140 struct sk_buff *cmd_skb;
2315 u16 res_code = QLINK_CMD_RESULT_OK;
2316 struct ieee80211_channel *sc; 2141 struct ieee80211_channel *sc;
2317 struct cfg80211_scan_request *scan_req = mac->scan_req; 2142 struct cfg80211_scan_request *scan_req = mac->scan_req;
2318 int n_channels; 2143 int n_channels;
@@ -2370,20 +2195,13 @@ int qtnf_cmd_send_scan(struct qtnf_wmac *mac)
2370 scan_req->mac_addr_mask); 2195 scan_req->mac_addr_mask);
2371 } 2196 }
2372 2197
2373 ret = qtnf_cmd_send(mac->bus, cmd_skb, &res_code); 2198 ret = qtnf_cmd_send(mac->bus, cmd_skb);
2374 2199 if (ret)
2375 if (unlikely(ret))
2376 goto out; 2200 goto out;
2377 2201
2378 pr_debug("MAC%u: scan started\n", mac->macid);
2379
2380 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
2381 pr_err("MAC%u: CMD failed: %u\n", mac->macid, res_code);
2382 ret = -EFAULT;
2383 goto out;
2384 }
2385out: 2202out:
2386 qtnf_bus_unlock(mac->bus); 2203 qtnf_bus_unlock(mac->bus);
2204
2387 return ret; 2205 return ret;
2388} 2206}
2389 2207
@@ -2393,7 +2211,6 @@ int qtnf_cmd_send_connect(struct qtnf_vif *vif,
2393 struct sk_buff *cmd_skb; 2211 struct sk_buff *cmd_skb;
2394 struct qlink_cmd_connect *cmd; 2212 struct qlink_cmd_connect *cmd;
2395 struct qlink_auth_encr *aen; 2213 struct qlink_auth_encr *aen;
2396 u16 res_code = QLINK_CMD_RESULT_OK;
2397 int ret; 2214 int ret;
2398 int i; 2215 int i;
2399 u32 connect_flags = 0; 2216 u32 connect_flags = 0;
@@ -2474,20 +2291,13 @@ int qtnf_cmd_send_connect(struct qtnf_vif *vif,
2474 qtnf_cmd_channel_tlv_add(cmd_skb, sme->channel); 2291 qtnf_cmd_channel_tlv_add(cmd_skb, sme->channel);
2475 2292
2476 qtnf_bus_lock(vif->mac->bus); 2293 qtnf_bus_lock(vif->mac->bus);
2477 2294 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
2478 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 2295 if (ret)
2479
2480 if (unlikely(ret))
2481 goto out; 2296 goto out;
2482 2297
2483 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
2484 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
2485 vif->vifid, res_code);
2486 ret = -EFAULT;
2487 goto out;
2488 }
2489out: 2298out:
2490 qtnf_bus_unlock(vif->mac->bus); 2299 qtnf_bus_unlock(vif->mac->bus);
2300
2491 return ret; 2301 return ret;
2492} 2302}
2493 2303
@@ -2495,7 +2305,6 @@ int qtnf_cmd_send_disconnect(struct qtnf_vif *vif, u16 reason_code)
2495{ 2305{
2496 struct sk_buff *cmd_skb; 2306 struct sk_buff *cmd_skb;
2497 struct qlink_cmd_disconnect *cmd; 2307 struct qlink_cmd_disconnect *cmd;
2498 u16 res_code = QLINK_CMD_RESULT_OK;
2499 int ret; 2308 int ret;
2500 2309
2501 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 2310 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -2509,19 +2318,13 @@ int qtnf_cmd_send_disconnect(struct qtnf_vif *vif, u16 reason_code)
2509 cmd = (struct qlink_cmd_disconnect *)cmd_skb->data; 2318 cmd = (struct qlink_cmd_disconnect *)cmd_skb->data;
2510 cmd->reason = cpu_to_le16(reason_code); 2319 cmd->reason = cpu_to_le16(reason_code);
2511 2320
2512 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 2321 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
2513 2322 if (ret)
2514 if (unlikely(ret))
2515 goto out; 2323 goto out;
2516 2324
2517 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
2518 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
2519 vif->vifid, res_code);
2520 ret = -EFAULT;
2521 goto out;
2522 }
2523out: 2325out:
2524 qtnf_bus_unlock(vif->mac->bus); 2326 qtnf_bus_unlock(vif->mac->bus);
2327
2525 return ret; 2328 return ret;
2526} 2329}
2527 2330
@@ -2529,7 +2332,6 @@ int qtnf_cmd_send_updown_intf(struct qtnf_vif *vif, bool up)
2529{ 2332{
2530 struct sk_buff *cmd_skb; 2333 struct sk_buff *cmd_skb;
2531 struct qlink_cmd_updown *cmd; 2334 struct qlink_cmd_updown *cmd;
2532 u16 res_code = QLINK_CMD_RESULT_OK;
2533 int ret; 2335 int ret;
2534 2336
2535 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 2337 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -2542,20 +2344,13 @@ int qtnf_cmd_send_updown_intf(struct qtnf_vif *vif, bool up)
2542 cmd->if_up = !!up; 2344 cmd->if_up = !!up;
2543 2345
2544 qtnf_bus_lock(vif->mac->bus); 2346 qtnf_bus_lock(vif->mac->bus);
2545 2347 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
2546 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 2348 if (ret)
2547
2548 if (unlikely(ret))
2549 goto out; 2349 goto out;
2550 2350
2551 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
2552 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
2553 vif->vifid, res_code);
2554 ret = -EFAULT;
2555 goto out;
2556 }
2557out: 2351out:
2558 qtnf_bus_unlock(vif->mac->bus); 2352 qtnf_bus_unlock(vif->mac->bus);
2353
2559 return ret; 2354 return ret;
2560} 2355}
2561 2356
@@ -2563,7 +2358,6 @@ int qtnf_cmd_reg_notify(struct qtnf_bus *bus, struct regulatory_request *req)
2563{ 2358{
2564 struct sk_buff *cmd_skb; 2359 struct sk_buff *cmd_skb;
2565 int ret; 2360 int ret;
2566 u16 res_code;
2567 struct qlink_cmd_reg_notify *cmd; 2361 struct qlink_cmd_reg_notify *cmd;
2568 2362
2569 cmd_skb = qtnf_cmd_alloc_new_cmdskb(QLINK_MACID_RSVD, QLINK_VIFID_RSVD, 2363 cmd_skb = qtnf_cmd_alloc_new_cmdskb(QLINK_MACID_RSVD, QLINK_VIFID_RSVD,
@@ -2604,29 +2398,10 @@ int qtnf_cmd_reg_notify(struct qtnf_bus *bus, struct regulatory_request *req)
2604 } 2398 }
2605 2399
2606 qtnf_bus_lock(bus); 2400 qtnf_bus_lock(bus);
2607 2401 ret = qtnf_cmd_send(bus, cmd_skb);
2608 ret = qtnf_cmd_send(bus, cmd_skb, &res_code);
2609 if (ret) 2402 if (ret)
2610 goto out; 2403 goto out;
2611 2404
2612 switch (res_code) {
2613 case QLINK_CMD_RESULT_ENOTSUPP:
2614 pr_warn("reg update not supported\n");
2615 ret = -EOPNOTSUPP;
2616 break;
2617 case QLINK_CMD_RESULT_EALREADY:
2618 pr_info("regulatory domain is already set to %c%c",
2619 req->alpha2[0], req->alpha2[1]);
2620 ret = -EALREADY;
2621 break;
2622 case QLINK_CMD_RESULT_OK:
2623 ret = 0;
2624 break;
2625 default:
2626 ret = -EFAULT;
2627 break;
2628 }
2629
2630out: 2405out:
2631 qtnf_bus_unlock(bus); 2406 qtnf_bus_unlock(bus);
2632 2407
@@ -2640,7 +2415,6 @@ int qtnf_cmd_get_chan_stats(struct qtnf_wmac *mac, u16 channel,
2640 struct qlink_cmd_get_chan_stats *cmd; 2415 struct qlink_cmd_get_chan_stats *cmd;
2641 struct qlink_resp_get_chan_stats *resp; 2416 struct qlink_resp_get_chan_stats *resp;
2642 size_t var_data_len; 2417 size_t var_data_len;
2643 u16 res_code = QLINK_CMD_RESULT_OK;
2644 int ret = 0; 2418 int ret = 0;
2645 2419
2646 cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, QLINK_VIFID_RSVD, 2420 cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, QLINK_VIFID_RSVD,
@@ -2654,25 +2428,10 @@ int qtnf_cmd_get_chan_stats(struct qtnf_wmac *mac, u16 channel,
2654 cmd = (struct qlink_cmd_get_chan_stats *)cmd_skb->data; 2428 cmd = (struct qlink_cmd_get_chan_stats *)cmd_skb->data;
2655 cmd->channel = cpu_to_le16(channel); 2429 cmd->channel = cpu_to_le16(channel);
2656 2430
2657 ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb, &res_code, 2431 ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb,
2658 sizeof(*resp), &var_data_len); 2432 sizeof(*resp), &var_data_len);
2659 if (unlikely(ret)) { 2433 if (ret)
2660 qtnf_bus_unlock(mac->bus);
2661 return ret;
2662 }
2663
2664 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
2665 switch (res_code) {
2666 case QLINK_CMD_RESULT_ENOTFOUND:
2667 ret = -ENOENT;
2668 break;
2669 default:
2670 pr_err("cmd exec failed: 0x%.4X\n", res_code);
2671 ret = -EFAULT;
2672 break;
2673 }
2674 goto out; 2434 goto out;
2675 }
2676 2435
2677 resp = (struct qlink_resp_get_chan_stats *)resp_skb->data; 2436 resp = (struct qlink_resp_get_chan_stats *)resp_skb->data;
2678 ret = qtnf_cmd_resp_proc_chan_stat_info(stats, resp->info, 2437 ret = qtnf_cmd_resp_proc_chan_stat_info(stats, resp->info,
@@ -2681,6 +2440,7 @@ int qtnf_cmd_get_chan_stats(struct qtnf_wmac *mac, u16 channel,
2681out: 2440out:
2682 qtnf_bus_unlock(mac->bus); 2441 qtnf_bus_unlock(mac->bus);
2683 consume_skb(resp_skb); 2442 consume_skb(resp_skb);
2443
2684 return ret; 2444 return ret;
2685} 2445}
2686 2446
@@ -2690,7 +2450,6 @@ int qtnf_cmd_send_chan_switch(struct qtnf_vif *vif,
2690 struct qtnf_wmac *mac = vif->mac; 2450 struct qtnf_wmac *mac = vif->mac;
2691 struct qlink_cmd_chan_switch *cmd; 2451 struct qlink_cmd_chan_switch *cmd;
2692 struct sk_buff *cmd_skb; 2452 struct sk_buff *cmd_skb;
2693 u16 res_code = QLINK_CMD_RESULT_OK;
2694 int ret; 2453 int ret;
2695 2454
2696 cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, vif->vifid, 2455 cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, vif->vifid,
@@ -2707,32 +2466,13 @@ int qtnf_cmd_send_chan_switch(struct qtnf_vif *vif,
2707 cmd->block_tx = params->block_tx; 2466 cmd->block_tx = params->block_tx;
2708 cmd->beacon_count = params->count; 2467 cmd->beacon_count = params->count;
2709 2468
2710 ret = qtnf_cmd_send(mac->bus, cmd_skb, &res_code); 2469 ret = qtnf_cmd_send(mac->bus, cmd_skb);
2711 2470 if (ret)
2712 if (unlikely(ret))
2713 goto out; 2471 goto out;
2714 2472
2715 switch (res_code) {
2716 case QLINK_CMD_RESULT_OK:
2717 ret = 0;
2718 break;
2719 case QLINK_CMD_RESULT_ENOTFOUND:
2720 ret = -ENOENT;
2721 break;
2722 case QLINK_CMD_RESULT_ENOTSUPP:
2723 ret = -EOPNOTSUPP;
2724 break;
2725 case QLINK_CMD_RESULT_EALREADY:
2726 ret = -EALREADY;
2727 break;
2728 case QLINK_CMD_RESULT_INVALID:
2729 default:
2730 ret = -EFAULT;
2731 break;
2732 }
2733
2734out: 2473out:
2735 qtnf_bus_unlock(mac->bus); 2474 qtnf_bus_unlock(mac->bus);
2475
2736 return ret; 2476 return ret;
2737} 2477}
2738 2478
@@ -2742,7 +2482,6 @@ int qtnf_cmd_get_channel(struct qtnf_vif *vif, struct cfg80211_chan_def *chdef)
2742 const struct qlink_resp_channel_get *resp; 2482 const struct qlink_resp_channel_get *resp;
2743 struct sk_buff *cmd_skb; 2483 struct sk_buff *cmd_skb;
2744 struct sk_buff *resp_skb = NULL; 2484 struct sk_buff *resp_skb = NULL;
2745 u16 res_code = QLINK_CMD_RESULT_OK;
2746 int ret; 2485 int ret;
2747 2486
2748 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 2487 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -2752,25 +2491,18 @@ int qtnf_cmd_get_channel(struct qtnf_vif *vif, struct cfg80211_chan_def *chdef)
2752 return -ENOMEM; 2491 return -ENOMEM;
2753 2492
2754 qtnf_bus_lock(bus); 2493 qtnf_bus_lock(bus);
2755 2494 ret = qtnf_cmd_send_with_reply(bus, cmd_skb, &resp_skb,
2756 ret = qtnf_cmd_send_with_reply(bus, cmd_skb, &resp_skb, &res_code,
2757 sizeof(*resp), NULL); 2495 sizeof(*resp), NULL);
2758 2496 if (ret)
2759 qtnf_bus_unlock(bus);
2760
2761 if (unlikely(ret))
2762 goto out;
2763
2764 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
2765 ret = -ENODATA;
2766 goto out; 2497 goto out;
2767 }
2768 2498
2769 resp = (const struct qlink_resp_channel_get *)resp_skb->data; 2499 resp = (const struct qlink_resp_channel_get *)resp_skb->data;
2770 qlink_chandef_q2cfg(priv_to_wiphy(vif->mac), &resp->chan, chdef); 2500 qlink_chandef_q2cfg(priv_to_wiphy(vif->mac), &resp->chan, chdef);
2771 2501
2772out: 2502out:
2503 qtnf_bus_unlock(bus);
2773 consume_skb(resp_skb); 2504 consume_skb(resp_skb);
2505
2774 return ret; 2506 return ret;
2775} 2507}
2776 2508
@@ -2782,7 +2514,6 @@ int qtnf_cmd_start_cac(const struct qtnf_vif *vif,
2782 struct sk_buff *cmd_skb; 2514 struct sk_buff *cmd_skb;
2783 struct qlink_cmd_start_cac *cmd; 2515 struct qlink_cmd_start_cac *cmd;
2784 int ret; 2516 int ret;
2785 u16 res_code;
2786 2517
2787 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 2518 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
2788 QLINK_CMD_START_CAC, 2519 QLINK_CMD_START_CAC,
@@ -2795,19 +2526,12 @@ int qtnf_cmd_start_cac(const struct qtnf_vif *vif,
2795 qlink_chandef_cfg2q(chdef, &cmd->chan); 2526 qlink_chandef_cfg2q(chdef, &cmd->chan);
2796 2527
2797 qtnf_bus_lock(bus); 2528 qtnf_bus_lock(bus);
2798 ret = qtnf_cmd_send(bus, cmd_skb, &res_code); 2529 ret = qtnf_cmd_send(bus, cmd_skb);
2799 qtnf_bus_unlock(bus);
2800
2801 if (ret) 2530 if (ret)
2802 return ret; 2531 goto out;
2803 2532
2804 switch (res_code) { 2533out:
2805 case QLINK_CMD_RESULT_OK: 2534 qtnf_bus_unlock(bus);
2806 break;
2807 default:
2808 ret = -EOPNOTSUPP;
2809 break;
2810 }
2811 2535
2812 return ret; 2536 return ret;
2813} 2537}
@@ -2819,7 +2543,6 @@ int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif,
2819 struct sk_buff *cmd_skb; 2543 struct sk_buff *cmd_skb;
2820 struct qlink_tlv_hdr *tlv; 2544 struct qlink_tlv_hdr *tlv;
2821 size_t acl_size = qtnf_cmd_acl_data_size(params); 2545 size_t acl_size = qtnf_cmd_acl_data_size(params);
2822 u16 res_code;
2823 int ret; 2546 int ret;
2824 2547
2825 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 2548 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
@@ -2834,22 +2557,12 @@ int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif,
2834 qlink_acl_data_cfg2q(params, (struct qlink_acl_data *)tlv->val); 2557 qlink_acl_data_cfg2q(params, (struct qlink_acl_data *)tlv->val);
2835 2558
2836 qtnf_bus_lock(bus); 2559 qtnf_bus_lock(bus);
2837 ret = qtnf_cmd_send(bus, cmd_skb, &res_code); 2560 ret = qtnf_cmd_send(bus, cmd_skb);
2838 qtnf_bus_unlock(bus); 2561 if (ret)
2839 2562 goto out;
2840 if (unlikely(ret))
2841 return ret;
2842 2563
2843 switch (res_code) { 2564out:
2844 case QLINK_CMD_RESULT_OK: 2565 qtnf_bus_unlock(bus);
2845 break;
2846 case QLINK_CMD_RESULT_INVALID:
2847 ret = -EINVAL;
2848 break;
2849 default:
2850 ret = -EOPNOTSUPP;
2851 break;
2852 }
2853 2566
2854 return ret; 2567 return ret;
2855} 2568}
@@ -2858,7 +2571,6 @@ int qtnf_cmd_send_pm_set(const struct qtnf_vif *vif, u8 pm_mode, int timeout)
2858{ 2571{
2859 struct qtnf_bus *bus = vif->mac->bus; 2572 struct qtnf_bus *bus = vif->mac->bus;
2860 struct sk_buff *cmd_skb; 2573 struct sk_buff *cmd_skb;
2861 u16 res_code = QLINK_CMD_RESULT_OK;
2862 struct qlink_cmd_pm_set *cmd; 2574 struct qlink_cmd_pm_set *cmd;
2863 int ret = 0; 2575 int ret = 0;
2864 2576
@@ -2873,18 +2585,13 @@ int qtnf_cmd_send_pm_set(const struct qtnf_vif *vif, u8 pm_mode, int timeout)
2873 2585
2874 qtnf_bus_lock(bus); 2586 qtnf_bus_lock(bus);
2875 2587
2876 ret = qtnf_cmd_send(bus, cmd_skb, &res_code); 2588 ret = qtnf_cmd_send(bus, cmd_skb);
2877 2589 if (ret)
2878 if (unlikely(ret))
2879 goto out; 2590 goto out;
2880 2591
2881 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
2882 pr_err("cmd exec failed: 0x%.4X\n", res_code);
2883 ret = -EFAULT;
2884 }
2885
2886out: 2592out:
2887 qtnf_bus_unlock(bus); 2593 qtnf_bus_unlock(bus);
2594
2888 return ret; 2595 return ret;
2889} 2596}
2890 2597
@@ -2893,7 +2600,6 @@ int qtnf_cmd_send_wowlan_set(const struct qtnf_vif *vif,
2893{ 2600{
2894 struct qtnf_bus *bus = vif->mac->bus; 2601 struct qtnf_bus *bus = vif->mac->bus;
2895 struct sk_buff *cmd_skb; 2602 struct sk_buff *cmd_skb;
2896 u16 res_code = QLINK_CMD_RESULT_OK;
2897 struct qlink_cmd_wowlan_set *cmd; 2603 struct qlink_cmd_wowlan_set *cmd;
2898 u32 triggers = 0; 2604 u32 triggers = 0;
2899 int count = 0; 2605 int count = 0;
@@ -2929,16 +2635,10 @@ int qtnf_cmd_send_wowlan_set(const struct qtnf_vif *vif,
2929 2635
2930 cmd->triggers = cpu_to_le32(triggers); 2636 cmd->triggers = cpu_to_le32(triggers);
2931 2637
2932 ret = qtnf_cmd_send(bus, cmd_skb, &res_code); 2638 ret = qtnf_cmd_send(bus, cmd_skb);
2933 2639 if (ret)
2934 if (unlikely(ret))
2935 goto out; 2640 goto out;
2936 2641
2937 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
2938 pr_err("cmd exec failed: 0x%.4X\n", res_code);
2939 ret = -EFAULT;
2940 }
2941
2942out: 2642out:
2943 qtnf_bus_unlock(bus); 2643 qtnf_bus_unlock(bus);
2944 return ret; 2644 return ret;