From aa4fd7c421776c33f0955517eb441fa2a14d6401 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Fri, 19 Apr 2013 08:34:40 +0200 Subject: [PATCH] broadband-modem-mbim: don't make no-SIM errors directly fatal, retry instead The MC7710 will report a MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED status when initializing and the SIM is not ready yet. So retry a couple of times as we do for MBIM_SUBSCRIBER_READY_STATE_NOT_INITIALIZED. If all retries are consumed, get the last reported status to build the error. This change makes all modems without SIM require up to 10s to get fully initialized and exposed in DBus; but it shouldn't be a big deal as the modems are unusable anyway. https://bugzilla.gnome.org/show_bug.cgi?id=698264 --- src/mm-broadband-modem-mbim.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index 823528c5..13103317 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -527,7 +527,8 @@ unlock_required_subscriber_ready_state_ready (MbimDevice *device, /* Don't set error */ break; case MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED: - error = mm_mobile_equipment_error_for_code (MM_MOBILE_EQUIPMENT_ERROR_SIM_NOT_INSERTED); + /* This is an error, but we still want to retry. + * The MC7710 may use this while the SIM is not ready yet. */ break; case MBIM_SUBSCRIBER_READY_STATE_BAD_SIM: error = mm_mobile_equipment_error_for_code (MM_MOBILE_EQUIPMENT_ERROR_SIM_WRONG); @@ -546,12 +547,19 @@ unlock_required_subscriber_ready_state_ready (MbimDevice *device, load_unlock_required_context_complete_and_free (ctx); } /* Need to retry? */ - else if (ready_state == MBIM_SUBSCRIBER_READY_STATE_NOT_INITIALIZED) { + else if (ready_state == MBIM_SUBSCRIBER_READY_STATE_NOT_INITIALIZED || + ready_state == MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED) { if (--ctx->n_ready_status_checks == 0) { - g_simple_async_result_set_error (ctx->result, - MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Error waiting for SIM to get initialized"); + /* All retries consumed, issue error */ + if (ready_state == MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED) + g_simple_async_result_take_error ( + ctx->result, + mm_mobile_equipment_error_for_code (MM_MOBILE_EQUIPMENT_ERROR_SIM_NOT_INSERTED)); + else + g_simple_async_result_set_error (ctx->result, + MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Error waiting for SIM to get initialized"); load_unlock_required_context_complete_and_free (ctx); } else { /* Retry */