qcacmn: Add wrapper for nla_parse()

The Linux kernel version 4.12 introduced an API change to nla_parse().
Add conditional compilation to call nla_parse with the correct
parameters based on the version of the linux kernel being compiled
against.

Change-Id: Ie904d217a42a2396f8245251a9c90a15dac2c0c9
CRs-Fixed: 2093354
This commit is contained in:
Dustin Brown
2017-08-17 17:22:34 -07:00
committed by snandini
parent e72853c63f
commit 1b57dba257
6 changed files with 29 additions and 7 deletions

View File

@@ -564,7 +564,7 @@ int os_if_nan_process_ndp_cmd(struct wlan_objmgr_psoc *psoc,
struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX + 1]; struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX + 1];
char *iface_name; char *iface_name;
if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX, if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX,
data, data_len, vendor_attr_policy)) { data, data_len, vendor_attr_policy)) {
cfg80211_err("Invalid NDP vendor command attributes"); cfg80211_err("Invalid NDP vendor command attributes");
return -EINVAL; return -EINVAL;

View File

@@ -1458,7 +1458,7 @@ int wlan_vendor_abort_scan(struct wlan_objmgr_pdev *pdev,
uint8_t pdev_id; uint8_t pdev_id;
pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SCAN_MAX, data, if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SCAN_MAX, data,
data_len, scan_policy)) { data_len, scan_policy)) {
cfg80211_err("Invalid ATTR"); cfg80211_err("Invalid ATTR");
return ret; return ret;

View File

@@ -93,7 +93,7 @@ static int wifi_pos_parse_req(const void *data, int len, int pid,
tAniMsgHdr *msg_hdr; tAniMsgHdr *msg_hdr;
struct nlattr *tb[CLD80211_ATTR_MAX + 1]; struct nlattr *tb[CLD80211_ATTR_MAX + 1];
if (nla_parse(tb, CLD80211_ATTR_MAX, data, len, NULL)) { if (wlan_cfg80211_nla_parse(tb, CLD80211_ATTR_MAX, data, len, NULL)) {
cfg80211_err("invalid data in request"); cfg80211_err("invalid data in request");
return OEM_ERR_INVALID_MESSAGE_TYPE; return OEM_ERR_INVALID_MESSAGE_TYPE;
} }

View File

@@ -64,6 +64,26 @@
.doit = NULL \ .doit = NULL \
}, },
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
static inline int wlan_cfg80211_nla_parse(struct nlattr **tb,
int maxtype,
const struct nlattr *head,
int len,
const struct nla_policy *policy)
{
return nla_parse(tb, maxtype, head, len, policy);
}
#else
static inline int wlan_cfg80211_nla_parse(struct nlattr **tb,
int maxtype,
const struct nlattr *head,
int len,
const struct nla_policy *policy)
{
return nla_parse(tb, maxtype, head, len, policy, NULL);
}
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)) #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0))
static inline int static inline int
wlan_cfg80211_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value) wlan_cfg80211_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value)

View File

@@ -4174,7 +4174,8 @@ static void cnss_diag_cmd_handler(const void *data, int data_len,
* audit note: it is ok to pass a NULL policy here since a * audit note: it is ok to pass a NULL policy here since a
* length check on the data is added later already * length check on the data is added later already
*/ */
if (nla_parse(tb, CLD80211_ATTR_MAX, data, data_len, NULL)) { if (wlan_cfg80211_nla_parse(tb, CLD80211_ATTR_MAX,
data, data_len, NULL)) {
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: nla parse fails \n", AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: nla parse fails \n",
__func__)); __func__));
return; return;

View File

@@ -272,7 +272,8 @@ static void ptt_cmd_handler(const void *data, int data_len, void *ctx, int pid)
* audit note: it is ok to pass a NULL policy here since a * audit note: it is ok to pass a NULL policy here since a
* length check on the data is added later already * length check on the data is added later already
*/ */
if (nla_parse(tb, CLD80211_ATTR_MAX, data, data_len, NULL)) { if (wlan_cfg80211_nla_parse(tb, CLD80211_ATTR_MAX,
data, data_len, NULL)) {
PTT_TRACE(QDF_TRACE_LEVEL_ERROR, "Invalid ATTR"); PTT_TRACE(QDF_TRACE_LEVEL_ERROR, "Invalid ATTR");
return; return;
} }