diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-09-24 11:30:58 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-10-02 15:30:29 +0200 |
commit | 615ed46a6ab25f71a7ab0d8201d33b4dbf8fc5b0 (patch) | |
tree | 1e8dadaa08ce45c3fd64c3019288260e11a8ded8 /openbsc/src/libbsc/gsm_04_08_utils.c | |
parent | 11cb7a9fd9d853aaf5ff3d34c179fa3afc9a80a4 (diff) |
amr: Instead of putting ms/bts into the same struct.. use it twice
This way a lot of if/else can just be killed by the caller deciding
which of the two instances to use.
I have copied both branches to new files, replace bts for ms in one
of them and ran diff on it. There is no difference.
Diffstat (limited to 'openbsc/src/libbsc/gsm_04_08_utils.c')
-rw-r--r-- | openbsc/src/libbsc/gsm_04_08_utils.c | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/openbsc/src/libbsc/gsm_04_08_utils.c b/openbsc/src/libbsc/gsm_04_08_utils.c index 24a1cfd61..4901912f5 100644 --- a/openbsc/src/libbsc/gsm_04_08_utils.c +++ b/openbsc/src/libbsc/gsm_04_08_utils.c @@ -364,7 +364,7 @@ void gsm48_lchan2chan_desc(struct gsm48_chan_desc *cd, } } -int gsm48_multirate_config(uint8_t *lv, struct amr_multirate_conf *mr, int ms) +int gsm48_multirate_config(uint8_t *lv, struct amr_multirate_conf *mr, struct amr_mode *modes) { int num = 0, i; @@ -387,33 +387,19 @@ int gsm48_multirate_config(uint8_t *lv, struct amr_multirate_conf *mr, int ms) memcpy(lv + 1, mr->gsm48_ie, 2); if (num == 1) return 0; - if (ms) { - lv[3] = mr->mode[0].threshold_ms & 0x3f; - lv[4] = mr->mode[0].hysteresis_ms << 4; - if (num == 2) - return 0; - lv[4] |= (mr->mode[1].threshold_ms & 0x3f) >> 2; - lv[5] = mr->mode[1].threshold_ms << 6; - lv[5] |= (mr->mode[1].hysteresis_ms & 0x0f) << 2; - if (num == 3) - return 0; - lv[5] |= (mr->mode[2].threshold_ms & 0x3f) >> 4; - lv[6] = mr->mode[2].threshold_ms << 4; - lv[6] |= mr->mode[2].hysteresis_ms & 0x0f; - } else { - lv[3] = mr->mode[0].threshold_bts & 0x3f; - lv[4] = mr->mode[0].hysteresis_bts << 4; - if (num == 2) - return 0; - lv[4] |= (mr->mode[1].threshold_bts & 0x3f) >> 2; - lv[5] = mr->mode[1].threshold_bts << 6; - lv[5] |= (mr->mode[1].hysteresis_bts & 0x0f) << 2; - if (num == 3) - return 0; - lv[5] |= (mr->mode[2].threshold_bts & 0x3f) >> 4; - lv[6] = mr->mode[2].threshold_bts << 4; - lv[6] |= mr->mode[2].hysteresis_bts & 0x0f; - } + + lv[3] = modes[0].threshold & 0x3f; + lv[4] = modes[0].hysteresis << 4; + if (num == 2) + return 0; + lv[4] |= (modes[1].threshold & 0x3f) >> 2; + lv[5] = modes[1].threshold << 6; + lv[5] |= (modes[1].hysteresis & 0x0f) << 2; + if (num == 3) + return 0; + lv[5] |= (modes[2].threshold & 0x3f) >> 4; + lv[6] = modes[2].threshold << 4; + lv[6] |= modes[2].hysteresis & 0x0f; return 0; } |