ublox: remove custom power operation synchronization logic
These are already synchronized at interface level, so there is already a guarantee that they won't happen at the same time.
This commit is contained in:
@@ -52,9 +52,6 @@ struct _MMBroadbandModemUbloxPrivate {
|
||||
MMUbloxNetworkingMode mode;
|
||||
gboolean mode_checked;
|
||||
|
||||
/* Flag to specify whether a power operation is ongoing */
|
||||
gboolean power_operation_ongoing;
|
||||
|
||||
/* Mode combination to apply if "any" requested */
|
||||
MMModemMode any_allowed;
|
||||
|
||||
@@ -136,28 +133,6 @@ preload_support_config (MMBroadbandModemUblox *self)
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
acquire_power_operation (MMBroadbandModemUblox *self,
|
||||
GError **error)
|
||||
{
|
||||
if (self->priv->power_operation_ongoing) {
|
||||
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_RETRY,
|
||||
"An operation which requires power updates is currently in progress");
|
||||
return FALSE;
|
||||
}
|
||||
self->priv->power_operation_ongoing = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
release_power_operation (MMBroadbandModemUblox *self)
|
||||
{
|
||||
g_assert (self->priv->power_operation_ongoing);
|
||||
self->priv->power_operation_ongoing = FALSE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Load supported bands (Modem interface) */
|
||||
|
||||
@@ -301,12 +276,10 @@ load_current_bands (MMIfaceModem *_self,
|
||||
|
||||
typedef enum {
|
||||
SET_CURRENT_MODES_BANDS_STEP_FIRST,
|
||||
SET_CURRENT_MODES_BANDS_STEP_ACQUIRE,
|
||||
SET_CURRENT_MODES_BANDS_STEP_CURRENT_POWER,
|
||||
SET_CURRENT_MODES_BANDS_STEP_BEFORE_COMMAND,
|
||||
SET_CURRENT_MODES_BANDS_STEP_COMMAND,
|
||||
SET_CURRENT_MODES_BANDS_STEP_AFTER_COMMAND,
|
||||
SET_CURRENT_MODES_BANDS_STEP_RELEASE,
|
||||
SET_CURRENT_MODES_BANDS_STEP_LAST,
|
||||
} SetCurrentModesBandsStep;
|
||||
|
||||
@@ -360,7 +333,7 @@ set_current_modes_bands_reregister_in_network_ready (MMIfaceModem3gpp *self,
|
||||
/* propagate the error if none already set */
|
||||
mm_iface_modem_3gpp_reregister_in_network_finish (self, res, ctx->saved_error ? NULL : &ctx->saved_error);
|
||||
|
||||
/* Go to next step (release power operation) regardless of the result */
|
||||
/* Go to next step regardless of the result */
|
||||
ctx->step++;
|
||||
set_current_modes_bands_step (task);
|
||||
}
|
||||
@@ -377,7 +350,7 @@ set_current_modes_bands_after_command_ready (MMBaseModem *self,
|
||||
/* propagate the error if none already set */
|
||||
mm_base_modem_at_command_finish (self, res, ctx->saved_error ? NULL : &ctx->saved_error);
|
||||
|
||||
/* Go to next step (release power operation) regardless of the result */
|
||||
/* Go to next step regardless of the result */
|
||||
ctx->step++;
|
||||
set_current_modes_bands_step (task);
|
||||
}
|
||||
@@ -392,7 +365,7 @@ set_current_modes_bands_command_ready (MMBaseModem *self,
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
if (!mm_base_modem_at_command_finish (self, res, &ctx->saved_error))
|
||||
ctx->step = SET_CURRENT_MODES_BANDS_STEP_RELEASE;
|
||||
ctx->step = SET_CURRENT_MODES_BANDS_STEP_LAST;
|
||||
else
|
||||
ctx->step++;
|
||||
|
||||
@@ -409,7 +382,7 @@ set_current_modes_bands_before_command_ready (MMBaseModem *self,
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
if (!mm_base_modem_at_command_finish (self, res, &ctx->saved_error))
|
||||
ctx->step = SET_CURRENT_MODES_BANDS_STEP_RELEASE;
|
||||
ctx->step = SET_CURRENT_MODES_BANDS_STEP_LAST;
|
||||
else
|
||||
ctx->step++;
|
||||
|
||||
@@ -431,7 +404,7 @@ set_current_modes_bands_current_power_ready (MMBaseModem *_self,
|
||||
|
||||
response = mm_base_modem_at_command_finish (_self, res, &ctx->saved_error);
|
||||
if (!response || !mm_ublox_parse_cfun_response (response, &ctx->initial_state, &ctx->saved_error))
|
||||
ctx->step = SET_CURRENT_MODES_BANDS_STEP_RELEASE;
|
||||
ctx->step = SET_CURRENT_MODES_BANDS_STEP_LAST;
|
||||
else
|
||||
ctx->step++;
|
||||
|
||||
@@ -452,16 +425,6 @@ set_current_modes_bands_step (GTask *task)
|
||||
ctx->step++;
|
||||
/* fall through */
|
||||
|
||||
case SET_CURRENT_MODES_BANDS_STEP_ACQUIRE:
|
||||
mm_obj_dbg (self, "acquiring power operation...");
|
||||
if (!acquire_power_operation (self, &ctx->saved_error)) {
|
||||
ctx->step = SET_CURRENT_MODES_BANDS_STEP_LAST;
|
||||
set_current_modes_bands_step (task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* fall through */
|
||||
|
||||
case SET_CURRENT_MODES_BANDS_STEP_CURRENT_POWER:
|
||||
/* If using CFUN, we check whether we're already in low-power mode.
|
||||
* And if we are, we just skip triggering low-power mode ourselves.
|
||||
@@ -549,12 +512,6 @@ set_current_modes_bands_step (GTask *task)
|
||||
ctx->step++;
|
||||
/* fall through */
|
||||
|
||||
case SET_CURRENT_MODES_BANDS_STEP_RELEASE:
|
||||
mm_obj_dbg (self, "releasing power operation...");
|
||||
release_power_operation (self);
|
||||
ctx->step++;
|
||||
/* fall through */
|
||||
|
||||
case SET_CURRENT_MODES_BANDS_STEP_LAST:
|
||||
if (ctx->saved_error) {
|
||||
g_task_return_error (task, ctx->saved_error);
|
||||
@@ -749,23 +706,7 @@ common_modem_power_operation_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
power_operation_ready (MMBaseModem *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
release_power_operation (MM_BROADBAND_MODEM_UBLOX (self));
|
||||
|
||||
if (!mm_base_modem_at_command_finish (self, res, &error))
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
return !!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -774,25 +715,12 @@ common_modem_power_operation (MMBroadbandModemUblox *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
GError *error = NULL;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
/* Fail if there is already an ongoing power management operation */
|
||||
if (!acquire_power_operation (self, &error)) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Use AT+CFUN=4 for power down, puts device in airplane mode */
|
||||
mm_base_modem_at_command (MM_BASE_MODEM (self),
|
||||
command,
|
||||
30,
|
||||
FALSE,
|
||||
(GAsyncReadyCallback) power_operation_ready,
|
||||
task);
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user