suspend: actually check if the modem is found before resetting

The timeout was meant to give more time to find the modem, yet the
callback didn't actually check if it came back but blindly issued a
reset.
Add a check to the callback to see if the modem was found and only
reset if not.

Fixes https://gitlab.com/mobian1/devices/eg25-manager/-/issues/28
This commit is contained in:
Kai Lüke
2021-12-01 21:59:46 +01:00
committed by Arnaud Ferraris
parent a91bc71e23
commit 88c68b9933

View File

@@ -18,11 +18,22 @@
#define SD_PATH "/org/freedesktop/login1" #define SD_PATH "/org/freedesktop/login1"
#define SD_INTERFACE "org.freedesktop.login1.Manager" #define SD_INTERFACE "org.freedesktop.login1.Manager"
static void resume_ok(struct EG25Manager *manager)
{
manager->modem_state = EG25_STATE_CONFIGURED;
modem_resume_post(manager);
}
static gboolean check_modem_resume(struct EG25Manager *manager) static gboolean check_modem_resume(struct EG25Manager *manager)
{ {
g_message("Modem wasn't probed in time, restart it!");
manager->modem_recovery_timer = 0; manager->modem_recovery_timer = 0;
modem_reset(manager);
if (manager->mm_modem) {
resume_ok(manager);
} else {
g_message("Modem wasn't probed in time, restart it!");
modem_reset(manager);
}
return FALSE; return FALSE;
} }
@@ -184,8 +195,7 @@ static void signal_cb(GDBusProxy *proxy,
* If modem is managed by ofono, we also do resume sequence immediately * If modem is managed by ofono, we also do resume sequence immediately
* as ofono handles resuming from sleep itself. * as ofono handles resuming from sleep itself.
*/ */
manager->modem_state = EG25_STATE_CONFIGURED; resume_ok(manager);
modem_resume_post(manager);
} else { } else {
manager->modem_state = EG25_STATE_RESUMING; manager->modem_state = EG25_STATE_RESUMING;
manager->modem_recovery_timer = g_timeout_add_seconds(manager->modem_recovery_timeout, manager->modem_recovery_timer = g_timeout_add_seconds(manager->modem_recovery_timeout,