From 0d8f51f1a566e2ecafafae26b1889028d938eecc Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 4 Oct 2021 12:44:03 +0200 Subject: trx_provision_fsm: poweronoff_sent flag: track POWERON and POWEROFF separately It helps better understanding the code, and will allow handling situations where for instance a POWERON in in transit while the BTS is instructed to shutdown, hence a POWEROFF needs to be sent. Change-Id: Iaf62217ceab7420afa4140cba61e1c2f983c61b4 --- src/osmo-bts-trx/trx_provision_fsm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/osmo-bts-trx/trx_provision_fsm.c') diff --git a/src/osmo-bts-trx/trx_provision_fsm.c b/src/osmo-bts-trx/trx_provision_fsm.c index 4ea67584..3d7eebfc 100644 --- a/src/osmo-bts-trx/trx_provision_fsm.c +++ b/src/osmo-bts-trx/trx_provision_fsm.c @@ -50,12 +50,14 @@ static void l1if_poweronoff_cb(struct trx_l1h *l1h, bool poweronoff, int rc) struct phy_link *plink = pinst->phy_link; plink->u.osmotrx.powered = poweronoff; - plink->u.osmotrx.poweronoff_sent = false; - if (poweronoff) + if (poweronoff) { + plink->u.osmotrx.poweron_sent = false; osmo_fsm_inst_dispatch(l1h->provision_fi, TRX_PROV_EV_POWERON_CNF, (void*)(intptr_t)rc); - else + } else { + plink->u.osmotrx.poweroff_sent = false; osmo_fsm_inst_dispatch(l1h->provision_fi, TRX_PROV_EV_POWEROFF_CNF, (void*)(intptr_t)rc); + } } @@ -520,7 +522,7 @@ static void st_open_wait_power_cnf_on_enter(struct osmo_fsm_inst *fi, uint32_t p struct phy_instance *pinst = l1h->phy_inst; trx_if_cmd_poweron(l1h, l1if_poweronoff_cb); - pinst->phy_link->u.osmotrx.poweronoff_sent = true; + pinst->phy_link->u.osmotrx.poweron_sent = true; } static void st_open_wait_power_cnf(struct osmo_fsm_inst *fi, uint32_t event, void *data) @@ -588,9 +590,9 @@ static void st_open_poweron(struct osmo_fsm_inst *fi, uint32_t event, void *data switch (event) { case TRX_PROV_EV_CLOSE: /* power off transceiver, if not already */ - if (pinst->num == 0 && plink->u.osmotrx.powered && !plink->u.osmotrx.poweronoff_sent) { - trx_if_cmd_poweroff(l1h, l1if_poweronoff_cb); - plink->u.osmotrx.poweronoff_sent = true; + if (pinst->num == 0 && plink->u.osmotrx.powered && !plink->u.osmotrx.poweroff_sent) { + trx_if_cmd_poweroff(l1h, l1if_poweronoff_cb); + plink->u.osmotrx.poweroff_sent = true; } trx_prov_fsm_state_chg(fi, TRX_PROV_ST_OPEN_WAIT_POWEROFF_CNF); break; -- cgit v1.2.3