diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-07-09 10:45:09 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-07-09 10:45:09 +0200 |
commit | 63f3dcb2fe3dee42fe223751c5394a751e7ecc42 (patch) | |
tree | 91ee2c4eaa71ca7d1e86a522025ee976a1d8a3cc /src | |
parent | 681d5d29d577ab4d2d822bb42ccbb74ac7d73b95 (diff) |
iface-modem: don't fail enabling if modem_power_up() isn't implemented
There are modems (e.g. Nokia, Thuraya, Iridium) which don't require or
don't support power management, and therefore there is no way to
either load or update the power status.
In those modems we just assume ON is the current and only value (set
in the skeleton during initialization) and so when we attempt to
update the power state to ON during enabling, the logic should not
break.
Fix the logic by making sure the requested_power_setup() function
pointers are only checked for validity after ensuring we're not
already in the desired power state.
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/398
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-iface-modem.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index d384738a..c3c4106d 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -3872,6 +3872,15 @@ set_power_state_step (GTask *task) case SET_POWER_STATE_STEP_UPDATE: mm_obj_dbg (self, "updating power state: '%s'...", mm_modem_power_state_get_string (ctx->requested_power_state)); + + /* Error if unsupported */ + if (!ctx->requested_power_setup || !ctx->requested_power_setup_finish) { + g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, + "Requested power transition is not supported by this modem"); + g_object_unref (task); + return; + } + ctx->requested_power_setup (self, (GAsyncReadyCallback)requested_power_setup_ready, task); return; @@ -3972,14 +3981,6 @@ mm_iface_modem_set_power_state (MMIfaceModem *self, g_assert_not_reached (); } - /* Error if unsupported */ - if (!ctx->requested_power_setup || !ctx->requested_power_setup_finish) { - g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, - "Requested power transition is not supported by this modem"); - g_object_unref (task); - return; - } - set_power_state_step (task); } |