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
This commit is contained in:
Vadim Yanitskiy 2022-11-06 21:26:46 +07:00
parent 6fc090593d
commit 03ef0b4e9f
1 changed files with 20 additions and 26 deletions

View File

@ -121,6 +121,22 @@ static int trxcon_timer_cb(struct osmo_fsm_inst *fi)
}
}
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 @@ static void trxcon_st_reset_action(struct osmo_fsm_inst *fi,
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 @@ static void trxcon_st_full_power_scan_action(struct osmo_fsm_inst *fi,
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 @@ static const struct osmo_fsm_state trxcon_fsm_states[] = {
},
[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,