summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2010-11-13 17:51:37 +0100
committerSylvain Munaut <tnt@246tNt.com>2010-11-13 17:51:37 +0100
commit2a471ee25d34529fc6449a870de244f3a271100c (patch)
tree0c0cea42fa0e234d7184c43ec3ce6fb2797c5657 /src
parentdab0287b3fcb67d2690c3d6c8e7ace16b230e953 (diff)
gsm_utils: Define 4 upper bits as "flags" and mask them out in utility functions
This way those function don't care about the flags they don't know about Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src')
-rw-r--r--src/gsm_utils.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/gsm_utils.c b/src/gsm_utils.c
index 4b4e2c60..31e3cd69 100644
--- a/src/gsm_utils.c
+++ b/src/gsm_utils.c
@@ -359,7 +359,11 @@ void generate_backtrace()
enum gsm_band gsm_arfcn2band(uint16_t arfcn)
{
- if (arfcn & ARFCN_PCS)
+ int is_pcs = arfcn & ARFCN_PCS;
+
+ arfcn &= ~ARFCN_FLAG_MASK;
+
+ if (is_pcs)
return GSM_BAND_1900;
else if (arfcn <= 124)
return GSM_BAND_900;
@@ -386,8 +390,11 @@ uint16_t gsm_arfcn2freq10(uint16_t arfcn, int uplink)
{
uint16_t freq10_ul;
uint16_t freq10_dl;
+ int is_pcs = arfcn & ARFCN_PCS;
+
+ arfcn &= ~ARFCN_FLAG_MASK;
- if (arfcn & ARFCN_PCS) {
+ if (is_pcs) {
/* DCS 1900 */
arfcn &= ~ARFCN_PCS;
freq10_ul = 18502 + 2 * (arfcn-512);