pmaports/temp/modemmanager/0009-broadband-modem-skip-synchronization-after-resume-if.patch

53 lines
1.9 KiB
Diff

From d59ca53e142dcbbc6afa3d1ace97ac367f96986f Mon Sep 17 00:00:00 2001
From: Aleksander Morgado <aleksander@aleksander.es>
Date: Sun, 23 May 2021 12:35:07 +0200
Subject: [PATCH 09/39] broadband-modem: skip synchronization after resume if
not needed
The synchronization after resume should only be needed on enabled
modems, as otherwise there is really no chance that the state of the
modem may have changed during suspend.
E.g. if a modem is failed because it doesn't have a SIM card, or if
the SIM-PIN is locked, or if the modem has never been enabled, there
is no point in attempting to synchronize the runtime state of the
modem.
---
src/mm-broadband-modem.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 7d928aa8..db6eb8ce 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -11396,13 +11396,24 @@ synchronize (MMBaseModem *self,
SyncingContext *ctx;
GTask *task;
+ task = g_task_new (MM_BROADBAND_MODEM (self), NULL, callback, user_data);
+
+ /* Synchronization after resume is not needed on modems that have never
+ * been enabled.
+ */
+ if (MM_BROADBAND_MODEM (self)->priv->modem_state < MM_MODEM_STATE_ENABLED) {
+ g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE,
+ "Synchronization after resume not needed in modem state '%s'",
+ mm_modem_state_get_string (MM_BROADBAND_MODEM (self)->priv->modem_state));
+ g_object_unref (task);
+ return;
+ }
+
/* Create SyncingContext */
ctx = g_new0 (SyncingContext, 1);
ctx->step = SYNCING_STEP_FIRST;
-
- /* Create sync steps task and execute it */
- task = g_task_new (MM_BROADBAND_MODEM (self), NULL, callback, user_data);
g_task_set_task_data (task, ctx, (GDestroyNotify)g_free);
+
syncing_step (task);
}
--
2.31.1