From e920902e25b0495889bc71f92fe9b8b8d53ce0f3 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Fri, 8 Jan 2021 02:30:43 +0100 Subject: [PATCH] power_control: properly track the first initial state Change-Id: I16e7474b5affbd90855a2e407b305e9dec581dfa Related: SYS#4918, SYS#4917 --- include/osmo-bts/gsm_data.h | 2 ++ src/common/power_control.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h index 253b115d8..8071a28fd 100644 --- a/include/osmo-bts/gsm_data.h +++ b/include/osmo-bts/gsm_data.h @@ -215,6 +215,8 @@ extern const struct gsm_power_ctrl_params power_ctrl_params_def; /* Measurement pre-processing state */ struct gsm_power_ctrl_meas_proc_state { + /* Number of measurements processed */ + unsigned int meas_num; /* Algorithm specific data */ union { struct { diff --git a/src/common/power_control.c b/src/common/power_control.c index 06296308f..5e2e85e9d 100644 --- a/src/common/power_control.c +++ b/src/common/power_control.c @@ -78,7 +78,7 @@ static int do_pf_ewma(const struct gsm_power_ctrl_meas_params *mp, int *Avg100 = &mps->ewma.Avg100; /* We don't have 'Avg[n - 1]' if this is the first run */ - if (*Avg100 == 0) { + if (mps->meas_num++ == 0) { *Avg100 = Val * EWMA_SCALE_FACTOR; return Val; }