From 1b57dba257f84678970c6470e14324b5caecde04 Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Thu, 17 Aug 2017 17:22:34 -0700 Subject: [PATCH] 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 --- os_if/linux/nan/src/os_if_nan.c | 4 ++-- os_if/linux/scan/src/wlan_cfg80211_scan.c | 4 ++-- os_if/linux/wifi_pos/src/os_if_wifi_pos.c | 2 +- os_if/linux/wlan_cfg80211.h | 20 ++++++++++++++++++++ utils/fwlog/dbglog_host.c | 3 ++- utils/ptt/src/wlan_ptt_sock_svc.c | 3 ++- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/os_if/linux/nan/src/os_if_nan.c b/os_if/linux/nan/src/os_if_nan.c index 7820c83cd8..1f2269a2c4 100644 --- a/os_if/linux/nan/src/os_if_nan.c +++ b/os_if/linux/nan/src/os_if_nan.c @@ -564,8 +564,8 @@ int os_if_nan_process_ndp_cmd(struct wlan_objmgr_psoc *psoc, struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX + 1]; char *iface_name; - if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX, - data, data_len, vendor_attr_policy)) { + if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX, + data, data_len, vendor_attr_policy)) { cfg80211_err("Invalid NDP vendor command attributes"); return -EINVAL; } diff --git a/os_if/linux/scan/src/wlan_cfg80211_scan.c b/os_if/linux/scan/src/wlan_cfg80211_scan.c index 24bf613c1d..4a4b820e77 100644 --- a/os_if/linux/scan/src/wlan_cfg80211_scan.c +++ b/os_if/linux/scan/src/wlan_cfg80211_scan.c @@ -1458,8 +1458,8 @@ int wlan_vendor_abort_scan(struct wlan_objmgr_pdev *pdev, uint8_t pdev_id; pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); - if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SCAN_MAX, data, - data_len, scan_policy)) { + if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SCAN_MAX, data, + data_len, scan_policy)) { cfg80211_err("Invalid ATTR"); return ret; } diff --git a/os_if/linux/wifi_pos/src/os_if_wifi_pos.c b/os_if/linux/wifi_pos/src/os_if_wifi_pos.c index 781a8f3802..e4ac2bbb61 100644 --- a/os_if/linux/wifi_pos/src/os_if_wifi_pos.c +++ b/os_if/linux/wifi_pos/src/os_if_wifi_pos.c @@ -93,7 +93,7 @@ static int wifi_pos_parse_req(const void *data, int len, int pid, tAniMsgHdr *msg_hdr; 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"); return OEM_ERR_INVALID_MESSAGE_TYPE; } diff --git a/os_if/linux/wlan_cfg80211.h b/os_if/linux/wlan_cfg80211.h index 81844c7742..49d788c9a7 100644 --- a/os_if/linux/wlan_cfg80211.h +++ b/os_if/linux/wlan_cfg80211.h @@ -64,6 +64,26 @@ .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)) static inline int wlan_cfg80211_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value) diff --git a/utils/fwlog/dbglog_host.c b/utils/fwlog/dbglog_host.c index 3ff92da587..6cc85db10f 100644 --- a/utils/fwlog/dbglog_host.c +++ b/utils/fwlog/dbglog_host.c @@ -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 * 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", __func__)); return; diff --git a/utils/ptt/src/wlan_ptt_sock_svc.c b/utils/ptt/src/wlan_ptt_sock_svc.c index 72d2006202..35f296002b 100644 --- a/utils/ptt/src/wlan_ptt_sock_svc.c +++ b/utils/ptt/src/wlan_ptt_sock_svc.c @@ -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 * 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"); return; }