iface-modem-3gpp: make registered state checking a macro

This commit is contained in:
Aleksander Morgado
2019-07-12 00:06:44 +02:00
committed by Dan Williams
parent d9615bfc2e
commit e9f5700d5f

View File

@@ -115,16 +115,13 @@ get_registration_state_context (MMIfaceModem3gpp *self)
return ctx; return ctx;
} }
static gboolean #define REG_STATE_IS_REGISTERED(state) \
reg_state_is_registered (MMModem3gppRegistrationState state) (state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME || \
{ state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING || \
return state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME || state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY || \
state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING || state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY || \
state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY || state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED || \
state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY || state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED)
state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED;
}
static MMModem3gppRegistrationState static MMModem3gppRegistrationState
get_consolidated_reg_state (RegistrationStateContext *ctx) get_consolidated_reg_state (RegistrationStateContext *ctx)
@@ -342,7 +339,7 @@ run_registration_checks_ready (MMIfaceModem3gpp *self,
} }
/* If we got registered, end registration checks */ /* If we got registered, end registration checks */
if (reg_state_is_registered (current_registration_state)) { if (REG_STATE_IS_REGISTERED (current_registration_state)) {
/* Request immediate access tech and signal update: we may have changed /* Request immediate access tech and signal update: we may have changed
* from home to roaming or viceversa, both registered states, so there * from home to roaming or viceversa, both registered states, so there
* wouldn't be an explicit refresh triggered from the modem interface as * wouldn't be an explicit refresh triggered from the modem interface as
@@ -470,7 +467,7 @@ mm_iface_modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
/* If the modem is already registered and the last time it was asked /* If the modem is already registered and the last time it was asked
* automatic registration, we're done */ * automatic registration, we're done */
if ((current_operator_code || reg_state_is_registered (reg_state)) && if ((current_operator_code || REG_STATE_IS_REGISTERED (reg_state)) &&
!registration_state_context->manual_registration) { !registration_state_context->manual_registration) {
mm_dbg ("Already registered in network '%s'," mm_dbg ("Already registered in network '%s',"
" automatic registration not launched...", " automatic registration not launched...",
@@ -1331,7 +1328,7 @@ mm_iface_modem_3gpp_update_access_technologies (MMIfaceModem3gpp *self,
/* Even if registration state didn't change, report access technology, /* Even if registration state didn't change, report access technology,
* but only if something valid to report */ * but only if something valid to report */
if (reg_state_is_registered (state) || ctx->reloading_registration_info) { if (REG_STATE_IS_REGISTERED (state) || ctx->reloading_registration_info) {
if (access_tech != MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN) if (access_tech != MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN)
mm_iface_modem_update_access_technologies (MM_IFACE_MODEM (self), mm_iface_modem_update_access_technologies (MM_IFACE_MODEM (self),
access_tech, access_tech,
@@ -1365,7 +1362,7 @@ mm_iface_modem_3gpp_update_location (MMIfaceModem3gpp *self,
* location updates, but only if something valid to report. For the case * location updates, but only if something valid to report. For the case
* where we're registering (loading current registration info after a state * where we're registering (loading current registration info after a state
* change to registered), we also allow LAC/CID updates. */ * change to registered), we also allow LAC/CID updates. */
if (reg_state_is_registered (state) || ctx->reloading_registration_info) { if (REG_STATE_IS_REGISTERED (state) || ctx->reloading_registration_info) {
if ((location_area_code > 0 || tracking_area_code > 0) && cell_id > 0) if ((location_area_code > 0 || tracking_area_code > 0) && cell_id > 0)
mm_iface_modem_location_3gpp_update_lac_tac_ci (MM_IFACE_MODEM_LOCATION (self), mm_iface_modem_location_3gpp_update_lac_tac_ci (MM_IFACE_MODEM_LOCATION (self),
location_area_code, location_area_code,
@@ -1448,7 +1445,7 @@ update_registration_state (MMIfaceModem3gpp *self,
if (new_state == old_state) if (new_state == old_state)
return; return;
if (reg_state_is_registered (new_state)) { if (REG_STATE_IS_REGISTERED (new_state)) {
MMModemState modem_state; MMModemState modem_state;
/* If already reloading registration info, skip it */ /* If already reloading registration info, skip it */