Commit c6ed298f authored by Sergey Matyukevich's avatar Sergey Matyukevich Committed by Kalle Valo

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: default avatarSergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 75001bbc
...@@ -141,8 +141,8 @@ qtnf_change_virtual_intf(struct wiphy *wiphy, ...@@ -141,8 +141,8 @@ qtnf_change_virtual_intf(struct wiphy *wiphy,
ret = qtnf_cmd_send_change_intf_type(vif, type, mac_addr); ret = qtnf_cmd_send_change_intf_type(vif, type, mac_addr);
if (ret) { if (ret) {
pr_err("VIF%u.%u: failed to change VIF type: %d\n", pr_err("VIF%u.%u: failed to change type to %d\n",
vif->mac->macid, vif->vifid, ret); vif->mac->macid, vif->vifid, type);
return ret; return ret;
} }
...@@ -228,18 +228,22 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy, ...@@ -228,18 +228,22 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy,
if (params) if (params)
mac_addr = params->macaddr; mac_addr = params->macaddr;
if (qtnf_cmd_send_add_intf(vif, type, mac_addr)) { ret = qtnf_cmd_send_add_intf(vif, type, mac_addr);
pr_err("VIF%u.%u: failed to add VIF\n", mac->macid, vif->vifid); if (ret) {
pr_err("VIF%u.%u: failed to add VIF %pM\n",
mac->macid, vif->vifid, mac_addr);
goto err_cmd; goto err_cmd;
} }
if (!is_valid_ether_addr(vif->mac_addr)) { if (!is_valid_ether_addr(vif->mac_addr)) {
pr_err("VIF%u.%u: FW reported bad MAC: %pM\n", pr_err("VIF%u.%u: FW reported bad MAC: %pM\n",
mac->macid, vif->vifid, vif->mac_addr); mac->macid, vif->vifid, vif->mac_addr);
ret = -EINVAL;
goto err_mac; goto err_mac;
} }
if (qtnf_core_net_attach(mac, vif, name, name_assign_t)) { ret = qtnf_core_net_attach(mac, vif, name, name_assign_t);
if (ret) {
pr_err("VIF%u.%u: failed to attach netdev\n", mac->macid, pr_err("VIF%u.%u: failed to attach netdev\n", mac->macid,
vif->vifid); vif->vifid);
goto err_net; goto err_net;
...@@ -255,7 +259,7 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy, ...@@ -255,7 +259,7 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy,
err_cmd: err_cmd:
vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED; vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
return ERR_PTR(-EFAULT); return ERR_PTR(ret);
} }
static int qtnf_mgmt_set_appie(struct qtnf_vif *vif, static 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,12 +338,11 @@ static int qtnf_stop_ap(struct wiphy *wiphy, struct net_device *dev)
qtnf_scan_done(vif->mac, true); qtnf_scan_done(vif->mac, true);
ret = qtnf_cmd_send_stop_ap(vif); ret = qtnf_cmd_send_stop_ap(vif);
if (ret) { if (ret)
pr_err("VIF%u.%u: failed to stop AP operation in FW\n", pr_err("VIF%u.%u: failed to stop AP operation in FW\n",
vif->mac->macid, vif->vifid); vif->mac->macid, vif->vifid);
netif_carrier_off(vif->netdev); netif_carrier_off(vif->netdev);
}
return ret; return ret;
} }
...@@ -589,6 +592,7 @@ qtnf_del_station(struct wiphy *wiphy, struct net_device *dev, ...@@ -589,6 +592,7 @@ qtnf_del_station(struct wiphy *wiphy, struct net_device *dev,
if (ret) if (ret)
pr_err("VIF%u.%u: failed to delete STA %pM\n", pr_err("VIF%u.%u: failed to delete STA %pM\n",
vif->mac->macid, vif->vifid, params->mac); vif->mac->macid, vif->vifid, params->mac);
return ret; return ret;
} }
...@@ -596,21 +600,25 @@ static int ...@@ -596,21 +600,25 @@ static int
qtnf_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) qtnf_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
{ {
struct qtnf_wmac *mac = wiphy_priv(wiphy); struct qtnf_wmac *mac = wiphy_priv(wiphy);
int ret;
cancel_delayed_work_sync(&mac->scan_timeout); cancel_delayed_work_sync(&mac->scan_timeout);
mac->scan_req = request; mac->scan_req = request;
if (qtnf_cmd_send_scan(mac)) { ret = qtnf_cmd_send_scan(mac);
if (ret) {
pr_err("MAC%u: failed to start scan\n", mac->macid); pr_err("MAC%u: failed to start scan\n", mac->macid);
mac->scan_req = NULL; mac->scan_req = NULL;
return -EFAULT; goto out;
} }
pr_debug("MAC%u: scan started\n", mac->macid);
queue_delayed_work(mac->bus->workqueue, &mac->scan_timeout, queue_delayed_work(mac->bus->workqueue, &mac->scan_timeout,
QTNF_SCAN_TIMEOUT_SEC * HZ); QTNF_SCAN_TIMEOUT_SEC * HZ);
return 0; out:
return ret;
} }
static int static int
...@@ -630,12 +638,13 @@ qtnf_connect(struct wiphy *wiphy, struct net_device *dev, ...@@ -630,12 +638,13 @@ qtnf_connect(struct wiphy *wiphy, struct net_device *dev,
ret = qtnf_cmd_send_connect(vif, sme); ret = qtnf_cmd_send_connect(vif, sme);
if (ret) { if (ret) {
pr_err("VIF%u.%u: failed to connect\n", vif->mac->macid, pr_err("VIF%u.%u: failed to connect\n",
vif->vifid); vif->mac->macid, vif->vifid);
return ret; goto out;
} }
return 0; out:
return ret;
} }
static int static int
...@@ -661,8 +670,8 @@ qtnf_disconnect(struct wiphy *wiphy, struct net_device *dev, ...@@ -661,8 +670,8 @@ qtnf_disconnect(struct wiphy *wiphy, struct net_device *dev,
ret = qtnf_cmd_send_disconnect(vif, reason_code); ret = qtnf_cmd_send_disconnect(vif, reason_code);
if (ret) if (ret)
pr_err("VIF%u.%u: failed to disconnect\n", mac->macid, pr_err("VIF%u.%u: failed to disconnect\n",
vif->vifid); mac->macid, vif->vifid);
if (vif->wdev.current_bss) { if (vif->wdev.current_bss) {
netif_carrier_off(vif->netdev); netif_carrier_off(vif->netdev);
...@@ -740,7 +749,6 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device *dev, ...@@ -740,7 +749,6 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device *dev,
default: default:
pr_debug("failed to get chan(%d) stats from card\n", pr_debug("failed to get chan(%d) stats from card\n",
chan->hw_value); chan->hw_value);
ret = -EINVAL;
break; break;
} }
...@@ -763,6 +771,7 @@ qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, ...@@ -763,6 +771,7 @@ qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
ret = qtnf_cmd_get_channel(vif, chandef); ret = qtnf_cmd_get_channel(vif, chandef);
if (ret) { if (ret) {
pr_err("%s: failed to get channel: %d\n", ndev->name, ret); pr_err("%s: failed to get channel: %d\n", ndev->name, ret);
ret = -ENODATA;
goto out; goto out;
} }
...@@ -772,6 +781,7 @@ qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, ...@@ -772,6 +781,7 @@ qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
chandef->center_freq1, chandef->center_freq2, chandef->center_freq1, chandef->center_freq2,
chandef->width); chandef->width);
ret = -ENODATA; ret = -ENODATA;
goto out;
} }
out: out:
...@@ -841,10 +851,8 @@ static int qtnf_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, ...@@ -841,10 +851,8 @@ static int qtnf_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
ret = qtnf_cmd_send_pm_set(vif, enabled ? QLINK_PM_AUTO_STANDBY : ret = qtnf_cmd_send_pm_set(vif, enabled ? QLINK_PM_AUTO_STANDBY :
QLINK_PM_OFF, timeout); QLINK_PM_OFF, timeout);
if (ret) { if (ret)
pr_err("%s: failed to set PM mode ret=%d\n", dev->name, ret); pr_err("%s: failed to set PM mode ret=%d\n", dev->name, ret);
return ret;
}
return ret; return ret;
} }
...@@ -964,9 +972,16 @@ static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in, ...@@ -964,9 +972,16 @@ static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,
ret = qtnf_cmd_reg_notify(bus, req); ret = qtnf_cmd_reg_notify(bus, req);
if (ret) { if (ret) {
if (ret != -EOPNOTSUPP && ret != -EALREADY) if (ret == -EOPNOTSUPP) {
pr_warn("reg update not supported\n");
} else if (ret == -EALREADY) {
pr_info("regulatory domain is already set to %c%c",
req->alpha2[0], req->alpha2[1]);
} else {
pr_err("failed to update reg domain to %c%c\n", pr_err("failed to update reg domain to %c%c\n",
req->alpha2[0], req->alpha2[1]); req->alpha2[0], req->alpha2[1]);
}
return; return;
} }
...@@ -1139,7 +1154,8 @@ void qtnf_netdev_updown(struct net_device *ndev, bool up) ...@@ -1139,7 +1154,8 @@ void qtnf_netdev_updown(struct net_device *ndev, bool up)
struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev); struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev);
if (qtnf_cmd_send_updown_intf(vif, up)) if (qtnf_cmd_send_updown_intf(vif, up))
pr_err("failed to send up/down command to FW\n"); pr_err("failed to send %s command to VIF%u.%u\n",
up ? "UP" : "DOWN", vif->mac->macid, vif->vifid);
} }
void qtnf_virtual_intf_cleanup(struct net_device *ndev) void qtnf_virtual_intf_cleanup(struct net_device *ndev)
......
...@@ -80,7 +80,6 @@ static int qtnf_cmd_resp_result_decode(enum qlink_cmd_result qcode) ...@@ -80,7 +80,6 @@ static int qtnf_cmd_resp_result_decode(enum qlink_cmd_result qcode)
static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus, static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
struct sk_buff *cmd_skb, struct sk_buff *cmd_skb,
struct sk_buff **response_skb, struct sk_buff **response_skb,
u16 *result_code,
size_t const_resp_size, size_t const_resp_size,
size_t *var_resp_size) size_t *var_resp_size)
{ {
...@@ -88,7 +87,8 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus, ...@@ -88,7 +87,8 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
const struct qlink_resp *resp; const struct qlink_resp *resp;
struct sk_buff *resp_skb = NULL; struct sk_buff *resp_skb = NULL;
u16 cmd_id; u16 cmd_id;
u8 mac_id, vif_id; u8 mac_id;
u8 vif_id;
int ret; int ret;
cmd = (struct qlink_cmd *)cmd_skb->data; cmd = (struct qlink_cmd *)cmd_skb->data;
...@@ -97,8 +97,11 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus, ...@@ -97,8 +97,11 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
vif_id = cmd->vifid; vif_id = cmd->vifid;
cmd->mhdr.len = cpu_to_le16(cmd_skb->len); cmd->mhdr.len = cpu_to_le16(cmd_skb->len);
if (unlikely(bus->fw_state != QTNF_FW_STATE_ACTIVE && pr_debug("VIF%u.%u cmd=0x%.4X\n", mac_id, vif_id,
le16_to_cpu(cmd->cmd_id) != QLINK_CMD_FW_INIT)) { le16_to_cpu(cmd->cmd_id));
if (bus->fw_state != QTNF_FW_STATE_ACTIVE &&
le16_to_cpu(cmd->cmd_id) != QLINK_CMD_FW_INIT) {
pr_warn("VIF%u.%u: drop cmd 0x%.4X in fw state %d\n", pr_warn("VIF%u.%u: drop cmd 0x%.4X in fw state %d\n",
mac_id, vif_id, le16_to_cpu(cmd->cmd_id), mac_id, vif_id, le16_to_cpu(cmd->cmd_id),
bus->fw_state); bus->fw_state);
...@@ -106,24 +109,16 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus, ...@@ -106,24 +109,16 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
return -ENODEV; return -ENODEV;
} }
pr_debug("VIF%u.%u cmd=0x%.4X\n", mac_id, vif_id,
le16_to_cpu(cmd->cmd_id));
ret = qtnf_trans_send_cmd_with_resp(bus, cmd_skb, &resp_skb); ret = qtnf_trans_send_cmd_with_resp(bus, cmd_skb, &resp_skb);
if (ret)
if (unlikely(ret))
goto out; goto out;
resp = (const struct qlink_resp *)resp_skb->data; resp = (const struct qlink_resp *)resp_skb->data;
ret = qtnf_cmd_check_reply_header(resp, cmd_id, mac_id, vif_id, ret = qtnf_cmd_check_reply_header(resp, cmd_id, mac_id, vif_id,
const_resp_size); const_resp_size);
if (ret)
if (unlikely(ret))
goto out; goto out;
if (likely(result_code))
*result_code = le16_to_cpu(resp->result);
/* Return length of variable part of response */ /* Return length of variable part of response */
if (response_skb && var_resp_size) if (response_skb && var_resp_size)
*var_resp_size = le16_to_cpu(resp->mhdr.len) - const_resp_size; *var_resp_size = le16_to_cpu(resp->mhdr.len) - const_resp_size;
...@@ -134,14 +129,18 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus, ...@@ -134,14 +129,18 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
else else
consume_skb(resp_skb); consume_skb(resp_skb);
if (!ret && resp)
return qtnf_cmd_resp_result_decode(le16_to_cpu(resp->result));
pr_warn("VIF%u.%u: cmd 0x%.4X failed: %d\n",
mac_id, vif_id, le16_to_cpu(cmd->cmd_id), ret);
return ret; return ret;
} }
static inline int qtnf_cmd_send(struct qtnf_bus *bus, static inline int qtnf_cmd_send(struct qtnf_bus *bus, struct sk_buff *cmd_skb)
struct sk_buff *cmd_skb,
u16 *result_code)
{ {
return qtnf_cmd_send_with_reply(bus, cmd_skb, NULL, result_code, return qtnf_cmd_send_with_reply(bus, cmd_skb, NULL,
sizeof(struct qlink_resp), NULL); sizeof(struct qlink_resp), NULL);
} }
...@@ -228,7 +227,6 @@ int qtnf_cmd_send_start_ap(struct qtnf_vif *vif, ...@@ -228,7 +227,6 @@ int qtnf_cmd_send_start_ap(struct qtnf_vif *vif,
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_start_ap *cmd; struct qlink_cmd_start_ap *cmd;
struct qlink_auth_encr *aen; struct qlink_auth_encr *aen;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret; int ret;
int i; int i;
...@@ -329,30 +327,21 @@ int qtnf_cmd_send_start_ap(struct qtnf_vif *vif, ...@@ -329,30 +327,21 @@ int qtnf_cmd_send_start_ap(struct qtnf_vif *vif,
} }
qtnf_bus_lock(vif->mac->bus); qtnf_bus_lock(vif->mac->bus);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); if (ret)
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
vif->vifid, res_code);
ret = -EFAULT;
goto out; goto out;
}
netif_carrier_on(vif->netdev); netif_carrier_on(vif->netdev);
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
int qtnf_cmd_send_stop_ap(struct qtnf_vif *vif) int qtnf_cmd_send_stop_ap(struct qtnf_vif *vif)
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret; int ret;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,23 +351,13 @@ int qtnf_cmd_send_stop_ap(struct qtnf_vif *vif)
return -ENOMEM; return -ENOMEM;
qtnf_bus_lock(vif->mac->bus); qtnf_bus_lock(vif->mac->bus);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); if (ret)
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
vif->vifid, res_code);
ret = -EFAULT;
goto out; goto out;
}
netif_carrier_off(vif->netdev);
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -386,7 +365,6 @@ int qtnf_cmd_send_register_mgmt(struct qtnf_vif *vif, u16 frame_type, bool reg) ...@@ -386,7 +365,6 @@ int qtnf_cmd_send_register_mgmt(struct qtnf_vif *vif, u16 frame_type, bool reg)
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_mgmt_frame_register *cmd; struct qlink_cmd_mgmt_frame_register *cmd;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret; int ret;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,20 +379,13 @@ int qtnf_cmd_send_register_mgmt(struct qtnf_vif *vif, u16 frame_type, bool reg)
cmd->frame_type = cpu_to_le16(frame_type); cmd->frame_type = cpu_to_le16(frame_type);
cmd->do_register = reg; cmd->do_register = reg;
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
if (ret)
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
vif->vifid, res_code);
ret = -EFAULT;
goto out; goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -423,7 +394,6 @@ int qtnf_cmd_send_mgmt_frame(struct qtnf_vif *vif, u32 cookie, u16 flags, ...@@ -423,7 +394,6 @@ int qtnf_cmd_send_mgmt_frame(struct qtnf_vif *vif, u32 cookie, u16 flags,
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_mgmt_frame_tx *cmd; struct qlink_cmd_mgmt_frame_tx *cmd;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret; int ret;
if (sizeof(*cmd) + len > QTNF_MAX_CMD_BUF_SIZE) { 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,20 +418,13 @@ int qtnf_cmd_send_mgmt_frame(struct qtnf_vif *vif, u32 cookie, u16 flags,
if (len && buf) if (len && buf)
qtnf_cmd_skb_put_buffer(cmd_skb, buf, len); qtnf_cmd_skb_put_buffer(cmd_skb, buf, len);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
if (ret)
if (unlikely(ret))
goto out; goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
vif->vifid, res_code);
ret = -EFAULT;
goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -469,7 +432,6 @@ int qtnf_cmd_send_mgmt_set_appie(struct qtnf_vif *vif, u8 frame_type, ...@@ -469,7 +432,6 @@ int qtnf_cmd_send_mgmt_set_appie(struct qtnf_vif *vif, u8 frame_type,
const u8 *buf, size_t len) const u8 *buf, size_t len)
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret; int ret;
if (len > QTNF_MAX_CMD_BUF_SIZE) { 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,21 +449,13 @@ int qtnf_cmd_send_mgmt_set_appie(struct qtnf_vif *vif, u8 frame_type,
qtnf_cmd_tlv_ie_set_add(cmd_skb, frame_type, buf, len); qtnf_cmd_tlv_ie_set_add(cmd_skb, frame_type, buf, len);
qtnf_bus_lock(vif->mac->bus); qtnf_bus_lock(vif->mac->bus);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); if (ret)
if (unlikely(ret))
goto out; goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("VIF%u.%u frame %u: CMD failed: %u\n", vif->mac->macid,
vif->vifid, frame_type, res_code);
ret = -EFAULT;
goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -730,7 +684,6 @@ int qtnf_cmd_get_sta_info(struct qtnf_vif *vif, const u8 *sta_mac, ...@@ -730,7 +684,6 @@ int qtnf_cmd_get_sta_info(struct qtnf_vif *vif, const u8 *sta_mac,
struct qlink_cmd_get_sta_info *cmd; struct qlink_cmd_get_sta_info *cmd;
const struct qlink_resp_get_sta_info *resp; const struct qlink_resp_get_sta_info *resp;
size_t var_resp_len; size_t var_resp_len;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,31 +698,13 @@ int qtnf_cmd_get_sta_info(struct qtnf_vif *vif, const u8 *sta_mac,
ether_addr_copy(cmd->sta_addr, sta_mac); ether_addr_copy(cmd->sta_addr, sta_mac);
ret = qtnf_cmd_send_with_reply(vif->mac->bus, cmd_skb, &resp_skb, ret = qtnf_cmd_send_with_reply(vif->mac->bus, cmd_skb, &resp_skb,
&res_code, sizeof(*resp), sizeof(*resp), &var_resp_len);
&var_resp_len); if (ret)
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
switch (res_code) {
case QLINK_CMD_RESULT_ENOTFOUND:
pr_warn("VIF%u.%u: %pM STA not found\n",
vif->mac->macid, vif->vifid, sta_mac);
ret = -ENOENT;
break;
default:
pr_err("VIF%u.%u: can't get info for %pM: %u\n",
vif->mac->macid, vif->vifid, sta_mac, res_code);
ret = -EFAULT;
break;
}
goto out; goto out;
}
resp = (const struct qlink_resp_get_sta_info *)resp_skb->data; resp = (const struct qlink_resp_get_sta_info *)resp_skb->data;
if (unlikely(!ether_addr_equal(sta_mac, resp->sta_addr))) { if (!ether_addr_equal(sta_mac, resp->sta_addr)) {
pr_err("VIF%u.%u: wrong mac in reply: %pM != %pM\n", pr_err("VIF%u.%u: wrong mac in reply: %pM != %pM\n",
vif->mac->macid, vif->vifid, resp->sta_addr, sta_mac); vif->mac->macid, vif->vifid, resp->sta_addr, sta_mac);
ret = -EINVAL; ret = -EINVAL;
...@@ -795,7 +730,6 @@ static int qtnf_cmd_send_add_change_intf(struct qtnf_vif *vif, ...@@ -795,7 +730,6 @@ static int qtnf_cmd_send_add_change_intf(struct qtnf_vif *vif,
struct sk_buff *cmd_skb, *resp_skb = NULL; struct sk_buff *cmd_skb, *resp_skb = NULL;
struct qlink_cmd_manage_intf *cmd; struct qlink_cmd_manage_intf *cmd;
const struct qlink_resp_manage_intf *resp; const struct qlink_resp_manage_intf *resp;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,17 +762,9 @@ static int qtnf_cmd_send_add_change_intf(struct qtnf_vif *vif,
eth_zero_addr(cmd->intf_info.mac_addr); eth_zero_addr(cmd->intf_info.mac_addr);
ret = qtnf_cmd_send_with_reply(vif->mac->bus, cmd_skb, &resp_skb, ret = qtnf_cmd_send_with_reply(vif->mac->bus, cmd_skb, &resp_skb,
&res_code, sizeof(*resp), NULL); sizeof(*resp), NULL);
if (ret)
if (unlikely(ret))
goto out;
ret = qtnf_cmd_resp_result_decode(res_code);
if (ret) {
pr_err("VIF%u.%u: CMD %d failed: %u\n", vif->mac->macid,
vif->vifid, cmd_type, res_code);
goto out; goto out;
}
resp = (const struct qlink_resp_manage_intf *)resp_skb->data; resp = (const struct qlink_resp_manage_intf *)resp_skb->data;
ether_addr_copy(vif->mac_addr, resp->intf_info.mac_addr); 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,7 +794,6 @@ int qtnf_cmd_send_del_intf(struct qtnf_vif *vif)
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_manage_intf *cmd; struct qlink_cmd_manage_intf *cmd;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,17 +822,9 @@ int qtnf_cmd_send_del_intf(struct qtnf_vif *vif)
eth_zero_addr(cmd->intf_info.mac_addr); eth_zero_addr(cmd->intf_info.mac_addr);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
if (ret)
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
vif->vifid, res_code);
ret = -EFAULT;
goto out; goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
...@@ -1732,7 +1649,6 @@ int qtnf_cmd_get_mac_info(struct qtnf_wmac *mac) ...@@ -1732,7 +1649,6 @@ int qtnf_cmd_get_mac_info(struct qtnf_wmac *mac)
struct sk_buff *cmd_skb, *resp_skb = NULL; struct sk_buff *cmd_skb, *resp_skb = NULL;
const struct qlink_resp_get_mac_info *resp; const struct qlink_resp_get_mac_info *resp;
size_t var_data_len; size_t var_data_len;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, QLINK_VIFID_RSVD, 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,18 +1658,11 @@ int qtnf_cmd_get_mac_info(struct qtnf_wmac *mac)
return -ENOMEM; return -ENOMEM;
qtnf_bus_lock(mac->bus); qtnf_bus_lock(mac->bus);
ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb,
ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb, &res_code,
sizeof(*resp), &var_data_len); sizeof(*resp), &var_data_len);
if (unlikely(ret)) if (ret)
goto out; goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("MAC%u: CMD failed: %u\n", mac->macid, res_code);
ret = -EFAULT;
goto out;
}
resp = (const struct qlink_resp_get_mac_info *)resp_skb->data; resp = (const struct qlink_resp_get_mac_info *)resp_skb->data;
qtnf_cmd_resp_proc_mac_info(mac, resp); qtnf_cmd_resp_proc_mac_info(mac, resp);
ret = qtnf_parse_variable_mac_info(mac, resp->var_info, var_data_len); 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,7 +1678,6 @@ int qtnf_cmd_get_hw_info(struct qtnf_bus *bus)
{ {
struct sk_buff *cmd_skb, *resp_skb = NULL; struct sk_buff *cmd_skb, *resp_skb = NULL;
const struct qlink_resp_get_hw_info *resp; const struct qlink_resp_get_hw_info *resp;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
size_t info_len; size_t info_len;
...@@ -1780,18 +1688,10 @@ int qtnf_cmd_get_hw_info(struct qtnf_bus *bus) ...@@ -1780,18 +1688,10 @@ int qtnf_cmd_get_hw_info(struct qtnf_bus *bus)
return -ENOMEM; return -ENOMEM;
qtnf_bus_lock(bus); qtnf_bus_lock(bus);
ret = qtnf_cmd_send_with_reply(bus, cmd_skb, &resp_skb,
ret = qtnf_cmd_send_with_reply(bus, cmd_skb, &resp_skb, &res_code,
sizeof(*resp), &info_len); sizeof(*resp), &info_len);
if (ret)
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("cmd exec failed: 0x%.4X\n", res_code);
ret = -EFAULT;
goto out; goto out;
}
resp = (const struct qlink_resp_get_hw_info *)resp_skb->data; resp = (const struct qlink_resp_get_hw_info *)resp_skb->data;
ret = qtnf_cmd_resp_proc_hw_info(bus, resp, info_len); 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,7 +1710,6 @@ int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,
size_t info_len; size_t info_len;
struct qlink_cmd_band_info_get *cmd; struct qlink_cmd_band_info_get *cmd;
struct qlink_resp_band_info_get *resp; struct qlink_resp_band_info_get *resp;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
u8 qband; u8 qband;
...@@ -1838,18 +1737,10 @@ int qtnf_cmd_band_info_get(struct qtnf_wmac *mac, ...@@ -1838,18 +1737,10 @@ int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,
cmd->band = qband; cmd->band = qband;
qtnf_bus_lock(mac->bus); qtnf_bus_lock(mac->bus);
ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb,
ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb, &res_code,
sizeof(*resp), &info_len); sizeof(*resp), &info_len);
if (ret)
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("MAC%u: CMD failed: %u\n", mac->macid, res_code);
ret = -EFAULT;
goto out; goto out;
}
resp = (struct qlink_resp_band_info_get *)resp_skb->data; resp = (struct qlink_resp_band_info_get *)resp_skb->data;
if (resp->band != qband) { if (resp->band != qband) {
...@@ -1873,7 +1764,6 @@ int qtnf_cmd_send_get_phy_params(struct qtnf_wmac *mac) ...@@ -1873,7 +1764,6 @@ int qtnf_cmd_send_get_phy_params(struct qtnf_wmac *mac)
struct sk_buff *cmd_skb, *resp_skb = NULL; struct sk_buff *cmd_skb, *resp_skb = NULL;
size_t response_size; size_t response_size;
struct qlink_resp_phy_params *resp; struct qlink_resp_phy_params *resp;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0, 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,18 +1773,10 @@ int qtnf_cmd_send_get_phy_params(struct qtnf_wmac *mac)
return -ENOMEM; return -ENOMEM;
qtnf_bus_lock(mac->bus); qtnf_bus_lock(mac->bus);
ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb,
ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb, &res_code,
sizeof(*resp), &response_size); sizeof(*resp), &response_size);
if (ret)
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("MAC%u: CMD failed: %u\n", mac->macid, res_code);
ret = -EFAULT;
goto out; goto out;
}
resp = (struct qlink_resp_phy_params *)resp_skb->data; resp = (struct qlink_resp_phy_params *)resp_skb->data;
ret = qtnf_cmd_resp_proc_phy_params(mac, resp->info, response_size); 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,7 +1792,6 @@ int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed)
{ {
struct wiphy *wiphy = priv_to_wiphy(mac); struct wiphy *wiphy = priv_to_wiphy(mac);
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0, 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,26 +1812,19 @@ int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed)
qtnf_cmd_skb_put_tlv_u8(cmd_skb, QTN_TLV_ID_COVERAGE_CLASS, qtnf_cmd_skb_put_tlv_u8(cmd_skb, QTN_TLV_ID_COVERAGE_CLASS,
wiphy->coverage_class); wiphy->coverage_class);
ret = qtnf_cmd_send(mac->bus, cmd_skb, &res_code); ret = qtnf_cmd_send(mac->bus, cmd_skb);
if (ret)
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("MAC%u: CMD failed: %u\n", mac->macid, res_code);
ret = -EFAULT;
goto out; goto out;
}
out: out:
qtnf_bus_unlock(mac->bus); qtnf_bus_unlock(mac->bus);
return ret; return ret;
} }
int qtnf_cmd_send_init_fw(struct qtnf_bus *bus) int qtnf_cmd_send_init_fw(struct qtnf_bus *bus)
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(QLINK_MACID_RSVD, QLINK_VIFID_RSVD, 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,20 +1834,13 @@ int qtnf_cmd_send_init_fw(struct qtnf_bus *bus)
return -ENOMEM; return -ENOMEM;
qtnf_bus_lock(bus); qtnf_bus_lock(bus);
ret = qtnf_cmd_send(bus, cmd_skb);
ret = qtnf_cmd_send(bus, cmd_skb, &res_code); if (ret)
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("cmd exec failed: 0x%.4X\n", res_code);
ret = -EFAULT;
goto out; goto out;
}
out: out:
qtnf_bus_unlock(bus); qtnf_bus_unlock(bus);
return ret; return ret;
} }
...@@ -1988,9 +1855,7 @@ void qtnf_cmd_send_deinit_fw(struct qtnf_bus *bus) ...@@ -1988,9 +1855,7 @@ void qtnf_cmd_send_deinit_fw(struct qtnf_bus *bus)
return; return;
qtnf_bus_lock(bus); qtnf_bus_lock(bus);
qtnf_cmd_send(bus, cmd_skb);
qtnf_cmd_send(bus, cmd_skb, NULL);
qtnf_bus_unlock(bus); qtnf_bus_unlock(bus);
} }
...@@ -1999,7 +1864,6 @@ int qtnf_cmd_send_add_key(struct qtnf_vif *vif, u8 key_index, bool pairwise, ...@@ -1999,7 +1864,6 @@ int qtnf_cmd_send_add_key(struct qtnf_vif *vif, u8 key_index, bool pairwise,
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_add_key *cmd; struct qlink_cmd_add_key *cmd;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,19 +1895,13 @@ int qtnf_cmd_send_add_key(struct qtnf_vif *vif, u8 key_index, bool pairwise,
params->seq, params->seq,
params->seq_len); params->seq_len);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
if (unlikely(ret)) if (ret)
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("VIF%u.%u: CMD failed: %u\n",
vif->mac->macid, vif->vifid, res_code);
ret = -EFAULT;
goto out; goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -2052,7 +1910,6 @@ int qtnf_cmd_send_del_key(struct qtnf_vif *vif, u8 key_index, bool pairwise, ...@@ -2052,7 +1910,6 @@ int qtnf_cmd_send_del_key(struct qtnf_vif *vif, u8 key_index, bool pairwise,
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_del_key *cmd; struct qlink_cmd_del_key *cmd;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,19 +1929,14 @@ int qtnf_cmd_send_del_key(struct qtnf_vif *vif, u8 key_index, bool pairwise,
cmd->key_index = key_index; cmd->key_index = key_index;
cmd->pairwise = pairwise; cmd->pairwise = pairwise;
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code);
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) { ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
pr_err("VIF%u.%u: CMD failed: %u\n", if (ret)
vif->mac->macid, vif->vifid, res_code);
ret = -EFAULT;
goto out; goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -2093,7 +1945,6 @@ int qtnf_cmd_send_set_default_key(struct qtnf_vif *vif, u8 key_index, ...@@ -2093,7 +1945,6 @@ int qtnf_cmd_send_set_default_key(struct qtnf_vif *vif, u8 key_index,
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_set_def_key *cmd; struct qlink_cmd_set_def_key *cmd;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,19 +1959,14 @@ int qtnf_cmd_send_set_default_key(struct qtnf_vif *vif, u8 key_index,
cmd->key_index = key_index; cmd->key_index = key_index;
cmd->unicast = unicast; cmd->unicast = unicast;
cmd->multicast = multicast; cmd->multicast = multicast;
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code);
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) { ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid, if (ret)
vif->vifid, res_code);
ret = -EFAULT;
goto out; goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -2128,7 +1974,6 @@ int qtnf_cmd_send_set_default_mgmt_key(struct qtnf_vif *vif, u8 key_index) ...@@ -2128,7 +1974,6 @@ int qtnf_cmd_send_set_default_mgmt_key(struct qtnf_vif *vif, u8 key_index)
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_set_def_mgmt_key *cmd; struct qlink_cmd_set_def_mgmt_key *cmd;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,19 +1986,14 @@ int qtnf_cmd_send_set_default_mgmt_key(struct qtnf_vif *vif, u8 key_index)
cmd = (struct qlink_cmd_set_def_mgmt_key *)cmd_skb->data; cmd = (struct qlink_cmd_set_def_mgmt_key *)cmd_skb->data;
cmd->key_index = key_index; cmd->key_index = key_index;
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code);
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) { ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid, if (ret)
vif->vifid, res_code);
ret = -EFAULT;
goto out; goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -2183,7 +2023,6 @@ int qtnf_cmd_send_change_sta(struct qtnf_vif *vif, const u8 *mac, ...@@ -2183,7 +2023,6 @@ int qtnf_cmd_send_change_sta(struct qtnf_vif *vif, const u8 *mac,
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_change_sta *cmd; struct qlink_cmd_change_sta *cmd;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,19 +2053,13 @@ int qtnf_cmd_send_change_sta(struct qtnf_vif *vif, const u8 *mac,
goto out; goto out;
} }
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
if (unlikely(ret)) if (ret)
goto out; goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
vif->vifid, res_code);
ret = -EFAULT;
goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -2235,7 +2068,6 @@ int qtnf_cmd_send_del_sta(struct qtnf_vif *vif, ...@@ -2235,7 +2068,6 @@ int qtnf_cmd_send_del_sta(struct qtnf_vif *vif,
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_del_sta *cmd; struct qlink_cmd_del_sta *cmd;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,19 +2088,13 @@ int qtnf_cmd_send_del_sta(struct qtnf_vif *vif,
cmd->subtype = params->subtype; cmd->subtype = params->subtype;
cmd->reason_code = cpu_to_le16(params->reason_code); cmd->reason_code = cpu_to_le16(params->reason_code);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
if (unlikely(ret)) if (ret)
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
vif->vifid, res_code);
ret = -EFAULT;
goto out; goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -2312,7 +2138,6 @@ static void qtnf_cmd_randmac_tlv_add(struct sk_buff *cmd_skb, ...@@ -2312,7 +2138,6 @@ static void qtnf_cmd_randmac_tlv_add(struct sk_buff *cmd_skb,
int qtnf_cmd_send_scan(struct qtnf_wmac *mac) int qtnf_cmd_send_scan(struct qtnf_wmac *mac)
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
u16 res_code = QLINK_CMD_RESULT_OK;
struct ieee80211_channel *sc; struct ieee80211_channel *sc;
struct cfg80211_scan_request *scan_req = mac->scan_req; struct cfg80211_scan_request *scan_req = mac->scan_req;
int n_channels; int n_channels;
...@@ -2370,20 +2195,13 @@ int qtnf_cmd_send_scan(struct qtnf_wmac *mac) ...@@ -2370,20 +2195,13 @@ int qtnf_cmd_send_scan(struct qtnf_wmac *mac)
scan_req->mac_addr_mask); scan_req->mac_addr_mask);
} }
ret = qtnf_cmd_send(mac->bus, cmd_skb, &res_code); ret = qtnf_cmd_send(mac->bus, cmd_skb);
if (ret)
if (unlikely(ret))
goto out; goto out;
pr_debug("MAC%u: scan started\n", mac->macid);
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("MAC%u: CMD failed: %u\n", mac->macid, res_code);
ret = -EFAULT;
goto out;
}
out: out:
qtnf_bus_unlock(mac->bus); qtnf_bus_unlock(mac->bus);
return ret; return ret;
} }
...@@ -2393,7 +2211,6 @@ int qtnf_cmd_send_connect(struct qtnf_vif *vif, ...@@ -2393,7 +2211,6 @@ int qtnf_cmd_send_connect(struct qtnf_vif *vif,
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_connect *cmd; struct qlink_cmd_connect *cmd;
struct qlink_auth_encr *aen; struct qlink_auth_encr *aen;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret; int ret;
int i; int i;
u32 connect_flags = 0; u32 connect_flags = 0;
...@@ -2474,20 +2291,13 @@ int qtnf_cmd_send_connect(struct qtnf_vif *vif, ...@@ -2474,20 +2291,13 @@ int qtnf_cmd_send_connect(struct qtnf_vif *vif,
qtnf_cmd_channel_tlv_add(cmd_skb, sme->channel); qtnf_cmd_channel_tlv_add(cmd_skb, sme->channel);
qtnf_bus_lock(vif->mac->bus); qtnf_bus_lock(vif->mac->bus);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); if (ret)
if (unlikely(ret))
goto out; goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
vif->vifid, res_code);
ret = -EFAULT;
goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -2495,7 +2305,6 @@ int qtnf_cmd_send_disconnect(struct qtnf_vif *vif, u16 reason_code) ...@@ -2495,7 +2305,6 @@ int qtnf_cmd_send_disconnect(struct qtnf_vif *vif, u16 reason_code)
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_disconnect *cmd; struct qlink_cmd_disconnect *cmd;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret; int ret;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,19 +2318,13 @@ int qtnf_cmd_send_disconnect(struct qtnf_vif *vif, u16 reason_code)
cmd = (struct qlink_cmd_disconnect *)cmd_skb->data; cmd = (struct qlink_cmd_disconnect *)cmd_skb->data;
cmd->reason = cpu_to_le16(reason_code); cmd->reason = cpu_to_le16(reason_code);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
if (ret)
if (unlikely(ret))
goto out; goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
vif->vifid, res_code);
ret = -EFAULT;
goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -2529,7 +2332,6 @@ int qtnf_cmd_send_updown_intf(struct qtnf_vif *vif, bool up) ...@@ -2529,7 +2332,6 @@ int qtnf_cmd_send_updown_intf(struct qtnf_vif *vif, bool up)
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_updown *cmd; struct qlink_cmd_updown *cmd;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret; int ret;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,20 +2344,13 @@ int qtnf_cmd_send_updown_intf(struct qtnf_vif *vif, bool up)
cmd->if_up = !!up; cmd->if_up = !!up;
qtnf_bus_lock(vif->mac->bus); qtnf_bus_lock(vif->mac->bus);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb);
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); if (ret)
if (unlikely(ret))
goto out; goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid,
vif->vifid, res_code);
ret = -EFAULT;
goto out;
}
out: out:
qtnf_bus_unlock(vif->mac->bus); qtnf_bus_unlock(vif->mac->bus);
return ret; return ret;
} }
...@@ -2563,7 +2358,6 @@ int qtnf_cmd_reg_notify(struct qtnf_bus *bus, struct regulatory_request *req) ...@@ -2563,7 +2358,6 @@ int qtnf_cmd_reg_notify(struct qtnf_bus *bus, struct regulatory_request *req)
{ {
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
int ret; int ret;
u16 res_code;
struct qlink_cmd_reg_notify *cmd; struct qlink_cmd_reg_notify *cmd;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(QLINK_MACID_RSVD, QLINK_VIFID_RSVD, 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,29 +2398,10 @@ int qtnf_cmd_reg_notify(struct qtnf_bus *bus, struct regulatory_request *req)
} }
qtnf_bus_lock(bus); qtnf_bus_lock(bus);
ret = qtnf_cmd_send(bus, cmd_skb);
ret = qtnf_cmd_send(bus, cmd_skb, &res_code);
if (ret) if (ret)
goto out; goto out;
switch (res_code) {
case QLINK_CMD_RESULT_ENOTSUPP:
pr_warn("reg update not supported\n");
ret = -EOPNOTSUPP;
break;
case QLINK_CMD_RESULT_EALREADY:
pr_info("regulatory domain is already set to %c%c",
req->alpha2[0], req->alpha2[1]);
ret = -EALREADY;
break;
case QLINK_CMD_RESULT_OK:
ret = 0;
break;
default:
ret = -EFAULT;
break;
}
out: out:
qtnf_bus_unlock(bus); qtnf_bus_unlock(bus);
...@@ -2640,7 +2415,6 @@ int qtnf_cmd_get_chan_stats(struct qtnf_wmac *mac, u16 channel, ...@@ -2640,7 +2415,6 @@ int qtnf_cmd_get_chan_stats(struct qtnf_wmac *mac, u16 channel,
struct qlink_cmd_get_chan_stats *cmd; struct qlink_cmd_get_chan_stats *cmd;
struct qlink_resp_get_chan_stats *resp; struct qlink_resp_get_chan_stats *resp;
size_t var_data_len; size_t var_data_len;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret = 0; int ret = 0;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, QLINK_VIFID_RSVD, 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,25 +2428,10 @@ int qtnf_cmd_get_chan_stats(struct qtnf_wmac *mac, u16 channel,
cmd = (struct qlink_cmd_get_chan_stats *)cmd_skb->data; cmd = (struct qlink_cmd_get_chan_stats *)cmd_skb->data;
cmd->channel = cpu_to_le16(channel); cmd->channel = cpu_to_le16(channel);
ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb, &res_code, ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb,
sizeof(*resp), &var_data_len); sizeof(*resp), &var_data_len);
if (unlikely(ret)) { if (ret)
qtnf_bus_unlock(mac->bus);
return ret;
}
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
switch (res_code) {
case QLINK_CMD_RESULT_ENOTFOUND:
ret = -ENOENT;
break;
default:
pr_err("cmd exec failed: 0x%.4X\n", res_code);
ret = -EFAULT;
break;
}
goto out; goto out;
}
resp = (struct qlink_resp_get_chan_stats *)resp_skb->data; resp = (struct qlink_resp_get_chan_stats *)resp_skb->data;
ret = qtnf_cmd_resp_proc_chan_stat_info(stats, resp->info, 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, ...@@ -2681,6 +2440,7 @@ int qtnf_cmd_get_chan_stats(struct qtnf_wmac *mac, u16 channel,
out: out:
qtnf_bus_unlock(mac->bus); qtnf_bus_unlock(mac->bus);
consume_skb(resp_skb); consume_skb(resp_skb);
return ret; return ret;
} }
...@@ -2690,7 +2450,6 @@ int qtnf_cmd_send_chan_switch(struct qtnf_vif *vif, ...@@ -2690,7 +2450,6 @@ int qtnf_cmd_send_chan_switch(struct qtnf_vif *vif,
struct qtnf_wmac *mac = vif->mac; struct qtnf_wmac *mac = vif->mac;
struct qlink_cmd_chan_switch *cmd; struct qlink_cmd_chan_switch *cmd;
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret; int ret;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, vif->vifid, 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,32 +2466,13 @@ int qtnf_cmd_send_chan_switch(struct qtnf_vif *vif,
cmd->block_tx = params->block_tx; cmd->block_tx = params->block_tx;
cmd->beacon_count = params->count; cmd->beacon_count = params->count;
ret = qtnf_cmd_send(mac->bus, cmd_skb, &res_code); ret = qtnf_cmd_send(mac->bus, cmd_skb);
if (ret)
if (unlikely(ret))
goto out; goto out;
switch (res_code) {
case QLINK_CMD_RESULT_OK:
ret = 0;
break;
case QLINK_CMD_RESULT_ENOTFOUND:
ret = -ENOENT;
break;
case QLINK_CMD_RESULT_ENOTSUPP:
ret = -EOPNOTSUPP;
break;
case QLINK_CMD_RESULT_EALREADY:
ret = -EALREADY;
break;
case QLINK_CMD_RESULT_INVALID:
default:
ret = -EFAULT;
break;
}
out: out:
qtnf_bus_unlock(mac->bus); qtnf_bus_unlock(mac->bus);
return ret; return ret;
} }
...@@ -2742,7 +2482,6 @@ int qtnf_cmd_get_channel(struct qtnf_vif *vif, struct cfg80211_chan_def *chdef) ...@@ -2742,7 +2482,6 @@ int qtnf_cmd_get_channel(struct qtnf_vif *vif, struct cfg80211_chan_def *chdef)
const struct qlink_resp_channel_get *resp; const struct qlink_resp_channel_get *resp;
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct sk_buff *resp_skb = NULL; struct sk_buff *resp_skb = NULL;
u16 res_code = QLINK_CMD_RESULT_OK;
int ret; int ret;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,25 +2491,18 @@ int qtnf_cmd_get_channel(struct qtnf_vif *vif, struct cfg80211_chan_def *chdef)
return -ENOMEM; return -ENOMEM;
qtnf_bus_lock(bus); qtnf_bus_lock(bus);
ret = qtnf_cmd_send_with_reply(bus, cmd_skb, &resp_skb,
ret = qtnf_cmd_send_with_reply(bus, cmd_skb, &resp_skb, &res_code,
sizeof(*resp), NULL); sizeof(*resp), NULL);
if (ret)
qtnf_bus_unlock(bus);
if (unlikely(ret))
goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
ret = -ENODATA;
goto out; goto out;
}
resp = (const struct qlink_resp_channel_get *)resp_skb->data; resp = (const struct qlink_resp_channel_get *)resp_skb->data;
qlink_chandef_q2cfg(priv_to_wiphy(vif->mac), &resp->chan, chdef); qlink_chandef_q2cfg(priv_to_wiphy(vif->mac), &resp->chan, chdef);
out: out:
qtnf_bus_unlock(bus);
consume_skb(resp_skb); consume_skb(resp_skb);
return ret; return ret;
} }
...@@ -2782,7 +2514,6 @@ int qtnf_cmd_start_cac(const struct qtnf_vif *vif, ...@@ -2782,7 +2514,6 @@ int qtnf_cmd_start_cac(const struct qtnf_vif *vif,
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_cmd_start_cac *cmd; struct qlink_cmd_start_cac *cmd;
int ret; int ret;
u16 res_code;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
QLINK_CMD_START_CAC, QLINK_CMD_START_CAC,
...@@ -2795,19 +2526,12 @@ int qtnf_cmd_start_cac(const struct qtnf_vif *vif, ...@@ -2795,19 +2526,12 @@ int qtnf_cmd_start_cac(const struct qtnf_vif *vif,
qlink_chandef_cfg2q(chdef, &cmd->chan); qlink_chandef_cfg2q(chdef, &cmd->chan);
qtnf_bus_lock(bus); qtnf_bus_lock(bus);
ret = qtnf_cmd_send(bus, cmd_skb, &res_code); ret = qtnf_cmd_send(bus, cmd_skb);
qtnf_bus_unlock(bus);
if (ret) if (ret)
return ret; goto out;
switch (res_code) { out:
case QLINK_CMD_RESULT_OK: qtnf_bus_unlock(bus);
break;
default:
ret = -EOPNOTSUPP;
break;
}
return ret; return ret;
} }
...@@ -2819,7 +2543,6 @@ int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif, ...@@ -2819,7 +2543,6 @@ int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif,
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
struct qlink_tlv_hdr *tlv; struct qlink_tlv_hdr *tlv;
size_t acl_size = qtnf_cmd_acl_data_size(params); size_t acl_size = qtnf_cmd_acl_data_size(params);
u16 res_code;
int ret; int ret;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 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,22 +2557,12 @@ int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif,
qlink_acl_data_cfg2q(params, (struct qlink_acl_data *)tlv->val); qlink_acl_data_cfg2q(params, (struct qlink_acl_data *)tlv->val);
qtnf_bus_lock(bus); qtnf_bus_lock(bus);
ret = qtnf_cmd_send(bus, cmd_skb, &res_code); ret = qtnf_cmd_send(bus, cmd_skb);
qtnf_bus_unlock(bus); if (ret)
goto out;
if (unlikely(ret))
return ret;
switch (res_code) { out:
case QLINK_CMD_RESULT_OK: qtnf_bus_unlock(bus);
break;
case QLINK_CMD_RESULT_INVALID:
ret = -EINVAL;
break;
default:
ret = -EOPNOTSUPP;
break;
}
return ret; return ret;
} }
...@@ -2858,7 +2571,6 @@ int qtnf_cmd_send_pm_set(const struct qtnf_vif *vif, u8 pm_mode, int timeout) ...@@ -2858,7 +2571,6 @@ int qtnf_cmd_send_pm_set(const struct qtnf_vif *vif, u8 pm_mode, int timeout)
{ {
struct qtnf_bus *bus = vif->mac->bus; struct qtnf_bus *bus = vif->mac->bus;
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
u16 res_code = QLINK_CMD_RESULT_OK;
struct qlink_cmd_pm_set *cmd; struct qlink_cmd_pm_set *cmd;
int ret = 0; int ret = 0;
...@@ -2873,18 +2585,13 @@ int qtnf_cmd_send_pm_set(const struct qtnf_vif *vif, u8 pm_mode, int timeout) ...@@ -2873,18 +2585,13 @@ int qtnf_cmd_send_pm_set(const struct qtnf_vif *vif, u8 pm_mode, int timeout)
qtnf_bus_lock(bus); qtnf_bus_lock(bus);
ret = qtnf_cmd_send(bus, cmd_skb, &res_code); ret = qtnf_cmd_send(bus, cmd_skb);
if (ret)
if (unlikely(ret))
goto out; goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("cmd exec failed: 0x%.4X\n", res_code);
ret = -EFAULT;
}
out: out:
qtnf_bus_unlock(bus); qtnf_bus_unlock(bus);
return ret; return ret;
} }
...@@ -2893,7 +2600,6 @@ int qtnf_cmd_send_wowlan_set(const struct qtnf_vif *vif, ...@@ -2893,7 +2600,6 @@ int qtnf_cmd_send_wowlan_set(const struct qtnf_vif *vif,
{ {
struct qtnf_bus *bus = vif->mac->bus; struct qtnf_bus *bus = vif->mac->bus;
struct sk_buff *cmd_skb; struct sk_buff *cmd_skb;
u16 res_code = QLINK_CMD_RESULT_OK;
struct qlink_cmd_wowlan_set *cmd; struct qlink_cmd_wowlan_set *cmd;
u32 triggers = 0; u32 triggers = 0;
int count = 0; int count = 0;
...@@ -2929,16 +2635,10 @@ int qtnf_cmd_send_wowlan_set(const struct qtnf_vif *vif, ...@@ -2929,16 +2635,10 @@ int qtnf_cmd_send_wowlan_set(const struct qtnf_vif *vif,
cmd->triggers = cpu_to_le32(triggers); cmd->triggers = cpu_to_le32(triggers);
ret = qtnf_cmd_send(bus, cmd_skb, &res_code); ret = qtnf_cmd_send(bus, cmd_skb);
if (ret)
if (unlikely(ret))
goto out; goto out;
if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
pr_err("cmd exec failed: 0x%.4X\n", res_code);
ret = -EFAULT;
}
out: out:
qtnf_bus_unlock(bus); qtnf_bus_unlock(bus);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment