fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/30053 )
Change subject: trxcon: add handle_full_power_scan_req(), reduce code duplication ......................................................................
trxcon: add handle_full_power_scan_req(), reduce code duplication
Allow TRXCON_ST_{FULL_POWER_SCAN->FULL_POWER_SCAN} state transition so that we can call osmo_fsm_inst_state_chg() unconditionally.
Change-Id: I1ea69561a2d3cf73009c6244b1d0f090d744d7b2 Related: OS#5599 --- M src/host/trxcon/src/trxcon_fsm.c 1 file changed, 20 insertions(+), 26 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve fixeria: Looks good to me, approved
diff --git a/src/host/trxcon/src/trxcon_fsm.c b/src/host/trxcon/src/trxcon_fsm.c index 5268bc6..38b95ec 100644 --- a/src/host/trxcon/src/trxcon_fsm.c +++ b/src/host/trxcon/src/trxcon_fsm.c @@ -121,6 +121,22 @@ } }
+static void handle_full_power_scan_req(struct osmo_fsm_inst *fi, + const struct trxcon_param_full_power_scan_req *req) +{ + struct trxcon_inst *trxcon = fi->priv; + const struct phyif_cmd phycmd = { + .type = PHYIF_CMDT_MEASURE, + .param.measure = { + .band_arfcn_start = req->band_arfcn_start, + .band_arfcn_stop = req->band_arfcn_stop, + }, + }; + + osmo_fsm_inst_state_chg(fi, TRXCON_ST_FULL_POWER_SCAN, 0, 0); /* TODO: timeout */ + phyif_handle_cmd(trxcon->phyif, &phycmd); +} + static void trxcon_st_reset_action(struct osmo_fsm_inst *fi, uint32_t event, void *data) { @@ -156,20 +172,8 @@ break; } case TRXCON_EV_FULL_POWER_SCAN_REQ: - { - const struct trxcon_param_full_power_scan_req *req = data; - const struct phyif_cmd phycmd = { - .type = PHYIF_CMDT_MEASURE, - .param.measure = { - .band_arfcn_start = req->band_arfcn_start, - .band_arfcn_stop = req->band_arfcn_stop, - }, - }; - - osmo_fsm_inst_state_chg(fi, TRXCON_ST_FULL_POWER_SCAN, 0, 0); /* TODO: timeout */ - phyif_handle_cmd(trxcon->phyif, &phycmd); + handle_full_power_scan_req(fi, (const struct trxcon_param_full_power_scan_req *)data); break; - } default: OSMO_ASSERT(0); } @@ -189,19 +193,8 @@ break; } case TRXCON_EV_FULL_POWER_SCAN_REQ: - { - const struct trxcon_param_full_power_scan_req *req = data; - const struct phyif_cmd phycmd = { - .type = PHYIF_CMDT_MEASURE, - .param.measure = { - .band_arfcn_start = req->band_arfcn_start, - .band_arfcn_stop = req->band_arfcn_stop, - }, - }; - - phyif_handle_cmd(trxcon->phyif, &phycmd); + handle_full_power_scan_req(fi, (const struct trxcon_param_full_power_scan_req *)data); break; - } default: OSMO_ASSERT(0); } @@ -528,7 +521,8 @@ }, [TRXCON_ST_FULL_POWER_SCAN] = { .name = "FULL_POWER_SCAN", - .out_state_mask = S(TRXCON_ST_RESET), + .out_state_mask = S(TRXCON_ST_RESET) + | S(TRXCON_ST_FULL_POWER_SCAN), .in_event_mask = S(TRXCON_EV_FULL_POWER_SCAN_RES) | S(TRXCON_EV_FULL_POWER_SCAN_REQ), .action = &trxcon_st_full_power_scan_action,