aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-08-18 16:26:50 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2020-08-18 17:22:38 +0200
commit67e5a72a51db4b46d925709e1ec9f0c0bf882ebe (patch)
tree1e400487387440e8003373cc9d7aa9fc3268a30d /src
parent1565d16a0acf6f373499710fe2af0cce4d62a6fa (diff)
common: tx_power: Fix bug in power ramp up below max-initial value
See previous commit adding the unit test about the error description and expected behavior. The wrong behavior appeared due to step_size_mdB being unsigned and the whole addition at the left side of the comparison being turned too as unsigned, hence a small negative value turning into a big positive value, and tpp->p_total_cur_mdBm not being updated to speed up the power ramping. Change-Id: I36a34362ebc90226fd8e1e190f898c3718fd923a
Diffstat (limited to 'src')
-rw-r--r--src/common/tx_power.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/common/tx_power.c b/src/common/tx_power.c
index c5ea7ed6..08c4236d 100644
--- a/src/common/tx_power.c
+++ b/src/common/tx_power.c
@@ -278,7 +278,7 @@ int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int bypass,
} else {
/* We need to step it up. Start from the current value, shortcutting to max-initial. */
/* Set attenuation to cause no power change right now */
- if (tpp->p_total_cur_mdBm + tpp->ramp.step_size_mdB < tpp->ramp.max_initial_pout_mdBm)
+ if (tpp->p_total_cur_mdBm + (int)tpp->ramp.step_size_mdB < tpp->ramp.max_initial_pout_mdBm)
tpp->p_total_cur_mdBm = tpp->ramp.max_initial_pout_mdBm - tpp->ramp.step_size_mdB;
tpp->ramp.attenuation_mdB = tpp->p_total_tgt_mdBm - tpp->p_total_cur_mdBm;