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
This commit is contained in:
Manikandan Mohan 2019-10-15 15:05:57 -07:00 • committed by nshrivas
commit ae310478dd

View file

@ -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);