From ae310478ddf74b399282cef7daab252120925140 Mon Sep 17 00:00:00 2001 From: Manikandan Mohan Date: Tue, 15 Oct 2019 15:05:57 -0700 Subject: [PATCH] qcacmn: Fix channel conversion utility functions Update wlan_chan_to_freq and wlan_freq_to_chan utility functions to handle invalid channel number and freq value of 0 respectively. Change-Id: I92e2d5026bb93439b77b749d447654ceb9413fde CRs-fixed: 2546771 --- umac/cmn_services/utils/src/wlan_utility.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/umac/cmn_services/utils/src/wlan_utility.c b/umac/cmn_services/utils/src/wlan_utility.c index 5bab3e124d4d..c82001afd594 100644 --- a/umac/cmn_services/utils/src/wlan_utility.c +++ b/umac/cmn_services/utils/src/wlan_utility.c @@ -28,7 +28,9 @@ uint32_t wlan_chan_to_freq(uint8_t chan) { - /* ch 0 - ch 13 */ + if (chan == 0 ) + return 0; + if (chan < WLAN_24_GHZ_CHANNEL_14) return WLAN_24_GHZ_BASE_FREQ + chan * WLAN_CHAN_SPACING_5MHZ; else if (chan == WLAN_24_GHZ_CHANNEL_14) @@ -47,6 +49,9 @@ uint8_t wlan_freq_to_chan(uint32_t freq) { uint8_t chan; + if (freq == 0) + return 0; + if (freq > WLAN_24_GHZ_BASE_FREQ && freq < WLAN_CHAN_14_FREQ) chan = ((freq - WLAN_24_GHZ_BASE_FREQ) / WLAN_CHAN_SPACING_5MHZ);