qcacld-3.0: Refactor WE_SET_NSS processing

Currently the HDD function with the highest cyclomatic complexity is
__iw_setint_getnone(). The handing of WE_SET_NSS has a complexity
greater than 1, so refactor that logic into a separate function to
help reduce the complexity of __iw_setint_getnone(). As part of the
refactoring relocate the mac_handle NULL check to hdd_update_nss()
since that is where it is actually used.

Change-Id: I6fef7680b8013547cb2b8eb649e207e3026144ff
CRs-Fixed: 2338567
此提交包含在:
Jeff Johnson
2018-10-24 15:01:40 -07:00
提交者 nshrivas
父節點 a583339824
當前提交 389126493f
共有 2 個檔案被更改,包括 24 行新增14 行删除

查看文件

@@ -4723,6 +4723,11 @@ QDF_STATUS hdd_update_nss(struct hdd_adapter *adapter, uint8_t nss)
} }
mac_handle = hdd_ctx->mac_handle; mac_handle = hdd_ctx->mac_handle;
if (!mac_handle) {
hdd_err("NULL MAC handle");
return QDF_STATUS_E_INVAL;
}
if (sme_is_any_session_in_connected_state(mac_handle)) { if (sme_is_any_session_in_connected_state(mac_handle)) {
hdd_err("Connected sessions present, Do not change NSS"); hdd_err("Connected sessions present, Do not change NSS");
return QDF_STATUS_E_INVAL; return QDF_STATUS_E_INVAL;

查看文件

@@ -4286,6 +4286,24 @@ static int hdd_we_set_tm_level(struct hdd_adapter *adapter, int level)
return qdf_status_to_os_return(status); return qdf_status_to_os_return(status);
} }
static int hdd_we_set_nss(struct hdd_adapter *adapter, int nss)
{
QDF_STATUS status;
hdd_debug("NSS %d", nss);
if ((nss > 2) || (nss <= 0)) {
hdd_err("Invalid NSS: %d", nss);
return -EINVAL;
}
status = hdd_update_nss(adapter, nss);
if (QDF_IS_STATUS_ERROR(status))
hdd_err("cfg set failed, value %d status %d", nss, status);
return qdf_status_to_os_return(status);
}
/** /**
* iw_setint_getnone() - Generic "set integer" private ioctl handler * iw_setint_getnone() - Generic "set integer" private ioctl handler
* @dev: device upon which the ioctl was received * @dev: device upon which the ioctl was received
@@ -4371,21 +4389,8 @@ static int __iw_setint_getnone(struct net_device *dev,
break; break;
case WE_SET_NSS: case WE_SET_NSS:
{ ret = hdd_we_set_nss(adapter, set_value);
if (!mac_handle)
return -EINVAL;
hdd_debug("Set NSS = %d", set_value);
if ((set_value > 2) || (set_value <= 0)) {
hdd_err("NSS greater than 2 not supported");
ret = -EINVAL;
} else {
if (QDF_STATUS_SUCCESS !=
hdd_update_nss(adapter, set_value))
ret = -EINVAL;
}
break; break;
}
case WE_SET_GTX_HT_MCS: case WE_SET_GTX_HT_MCS:
{ {