Revert "base-manager: add support to put modem in low power mode during suspend"
This reverts commit 23033217de.
This was mixed up in the wrong branch.
This commit is contained in:
+5
-15
@@ -62,14 +62,7 @@ static void
|
||||
sleeping_cb (MMSleepMonitor *sleep_monitor)
|
||||
{
|
||||
mm_dbg ("removing devices... (sleeping)");
|
||||
mm_base_manager_shutdown (manager, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
sleeping_low_power_cb (MMSleepMonitor *sleep_monitor)
|
||||
{
|
||||
mm_dbg ("removing devices and setting low power mode... (sleeping)");
|
||||
mm_base_manager_shutdown (manager, TRUE, TRUE);
|
||||
mm_base_manager_shutdown (manager, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -208,19 +201,16 @@ main (int argc, char *argv[])
|
||||
{
|
||||
MMSleepMonitor *sleep_monitor;
|
||||
|
||||
if (mm_context_get_test_no_suspend_resume ())
|
||||
if (mm_context_get_test_no_suspend_resume())
|
||||
mm_dbg ("Suspend/resume support disabled at runtime");
|
||||
else if (mm_context_get_test_quick_suspend_resume ()) {
|
||||
else if (mm_context_get_test_quick_suspend_resume()) {
|
||||
mm_dbg ("Quick suspend/resume hooks enabled");
|
||||
sleep_monitor = mm_sleep_monitor_get ();
|
||||
g_signal_connect (sleep_monitor, MM_SLEEP_MONITOR_RESUMING, G_CALLBACK (resuming_quick_cb), NULL);
|
||||
} else {
|
||||
mm_dbg ("Full suspend/resume hooks enabled");
|
||||
sleep_monitor = mm_sleep_monitor_get ();
|
||||
if (mm_context_get_test_radio_off_suspend_resume ())
|
||||
g_signal_connect (sleep_monitor, MM_SLEEP_MONITOR_SLEEPING, G_CALLBACK (sleeping_low_power_cb), NULL);
|
||||
else
|
||||
g_signal_connect (sleep_monitor, MM_SLEEP_MONITOR_SLEEPING, G_CALLBACK (sleeping_cb), NULL);
|
||||
g_signal_connect (sleep_monitor, MM_SLEEP_MONITOR_SLEEPING, G_CALLBACK (sleeping_cb), NULL);
|
||||
g_signal_connect (sleep_monitor, MM_SLEEP_MONITOR_RESUMING, G_CALLBACK (resuming_cb), NULL);
|
||||
}
|
||||
}
|
||||
@@ -238,7 +228,7 @@ main (int argc, char *argv[])
|
||||
if (manager) {
|
||||
GTimer *timer;
|
||||
|
||||
mm_base_manager_shutdown (manager, TRUE, FALSE);
|
||||
mm_base_manager_shutdown (manager, TRUE);
|
||||
|
||||
/* Wait for all modems to be disabled and removed, but don't wait
|
||||
* forever: if disabling the modems takes longer than 20s, just
|
||||
|
||||
+18
-76
@@ -57,7 +57,6 @@
|
||||
#include "mm-filter.h"
|
||||
#include "mm-log-object.h"
|
||||
#include "mm-base-modem.h"
|
||||
#include "mm-iface-modem.h"
|
||||
|
||||
static void initable_iface_init (GInitableIface *iface);
|
||||
static void log_object_iface_init (MMLogObjectInterface *iface);
|
||||
@@ -653,91 +652,39 @@ mm_base_manager_start (MMBaseManager *self,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
MMBaseManager *self;
|
||||
gboolean low_power;
|
||||
} DisableContext;
|
||||
|
||||
static void
|
||||
disable_context_free (DisableContext *ctx)
|
||||
{
|
||||
g_object_unref (ctx->self);
|
||||
g_slice_free (DisableContext, ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_device_after_disable (MMBaseModem *modem,
|
||||
DisableContext *ctx)
|
||||
remove_disable_ready (MMBaseModem *modem,
|
||||
GAsyncResult *res,
|
||||
MMBaseManager *self)
|
||||
{
|
||||
MMDevice *device;
|
||||
|
||||
device = find_device_by_modem (ctx->self, modem);
|
||||
/* We don't care about errors disabling at this point */
|
||||
mm_base_modem_disable_finish (modem, res, NULL);
|
||||
|
||||
device = find_device_by_modem (self, modem);
|
||||
if (device) {
|
||||
g_cancellable_cancel (mm_base_modem_peek_cancellable (modem));
|
||||
mm_device_remove_modem (device);
|
||||
g_hash_table_remove (ctx->self->priv->devices, mm_device_get_uid (device));
|
||||
g_hash_table_remove (self->priv->devices, mm_device_get_uid (device));
|
||||
}
|
||||
|
||||
disable_context_free (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
shutdown_low_power_ready (MMIfaceModem *modem,
|
||||
GAsyncResult *res,
|
||||
DisableContext *ctx)
|
||||
foreach_disable (gpointer key,
|
||||
MMDevice *device,
|
||||
MMBaseManager *self)
|
||||
{
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (!mm_iface_modem_set_power_state_finish (modem, res, &error))
|
||||
mm_obj_info (ctx->self, "changing to low power state failed: %s", error->message);
|
||||
|
||||
remove_device_after_disable (MM_BASE_MODEM (modem), ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
shutdown_disable_ready (MMBaseModem *modem,
|
||||
GAsyncResult *res,
|
||||
DisableContext *ctx)
|
||||
{
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
/* We don't care about errors disabling at this point */
|
||||
if (!mm_base_modem_disable_finish (modem, res, &error)) {
|
||||
mm_obj_info (ctx->self, "disabling modem failed: %s", error->message);
|
||||
}
|
||||
/* Bring the modem to low power mode if requested */
|
||||
else if (ctx->low_power) {
|
||||
mm_iface_modem_set_power_state (MM_IFACE_MODEM (modem),
|
||||
MM_MODEM_POWER_STATE_LOW,
|
||||
(GAsyncReadyCallback)shutdown_low_power_ready,
|
||||
ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
remove_device_after_disable (modem, ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
foreach_disable (gpointer key,
|
||||
MMDevice *device,
|
||||
DisableContext *foreach_ctx)
|
||||
{
|
||||
MMBaseModem *modem;
|
||||
DisableContext *ctx;
|
||||
MMBaseModem *modem;
|
||||
|
||||
modem = mm_device_peek_modem (device);
|
||||
if (!modem)
|
||||
return;
|
||||
|
||||
ctx = g_slice_new0 (DisableContext);
|
||||
ctx->self = g_object_ref (foreach_ctx->self);
|
||||
ctx->low_power = foreach_ctx->low_power;
|
||||
mm_base_modem_disable (modem, (GAsyncReadyCallback)shutdown_disable_ready, ctx);
|
||||
if (modem)
|
||||
mm_base_modem_disable (modem, (GAsyncReadyCallback)remove_disable_ready, self);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
foreach_remove (gpointer key,
|
||||
MMDevice *device,
|
||||
foreach_remove (gpointer key,
|
||||
MMDevice *device,
|
||||
MMBaseManager *self)
|
||||
{
|
||||
MMBaseModem *modem;
|
||||
@@ -751,8 +698,7 @@ foreach_remove (gpointer key,
|
||||
|
||||
void
|
||||
mm_base_manager_shutdown (MMBaseManager *self,
|
||||
gboolean disable,
|
||||
gboolean low_power)
|
||||
gboolean disable)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (MM_IS_BASE_MANAGER (self));
|
||||
@@ -761,11 +707,7 @@ mm_base_manager_shutdown (MMBaseManager *self,
|
||||
g_cancellable_cancel (self->priv->authp_cancellable);
|
||||
|
||||
if (disable) {
|
||||
DisableContext foreach_ctx = {
|
||||
.self = self,
|
||||
.low_power = low_power,
|
||||
};
|
||||
g_hash_table_foreach (self->priv->devices, (GHFunc)foreach_disable, &foreach_ctx);
|
||||
g_hash_table_foreach (self->priv->devices, (GHFunc)foreach_disable, self);
|
||||
|
||||
/* Disabling may take a few iterations of the mainloop, so the caller
|
||||
* has to iterate the mainloop until all devices have been disabled and
|
||||
|
||||
@@ -72,8 +72,7 @@ void mm_base_manager_start (MMBaseManager *manager,
|
||||
gboolean manual_scan);
|
||||
|
||||
void mm_base_manager_shutdown (MMBaseManager *manager,
|
||||
gboolean disable,
|
||||
gboolean power_low);
|
||||
gboolean disable);
|
||||
|
||||
#if defined WITH_SUSPEND_RESUME
|
||||
void mm_base_manager_sync (MMBaseManager *manager);
|
||||
|
||||
@@ -238,7 +238,6 @@ static gboolean test_no_udev;
|
||||
#if defined WITH_SUSPEND_RESUME
|
||||
static gboolean test_no_suspend_resume;
|
||||
static gboolean test_quick_suspend_resume;
|
||||
static gboolean test_radio_off_suspend_resume;
|
||||
#endif
|
||||
#if defined WITH_QRTR
|
||||
static gboolean test_no_qrtr;
|
||||
@@ -286,11 +285,6 @@ static const GOptionEntry test_entries[] = {
|
||||
"Enable quick suspend/resume support for modems which stay on during host suspension",
|
||||
NULL
|
||||
},
|
||||
{
|
||||
"test-radio-off-suspend-resume", 0, 0, G_OPTION_ARG_NONE, &test_radio_off_suspend_resume,
|
||||
"Enable support to turn radio off during suspend/resume",
|
||||
NULL
|
||||
},
|
||||
#endif
|
||||
#if defined WITH_QRTR
|
||||
{
|
||||
@@ -364,18 +358,11 @@ mm_context_get_test_no_suspend_resume (void)
|
||||
{
|
||||
return test_no_suspend_resume;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_context_get_test_quick_suspend_resume (void)
|
||||
{
|
||||
return test_quick_suspend_resume;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_context_get_test_radio_off_suspend_resume (void)
|
||||
{
|
||||
return test_radio_off_suspend_resume;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined WITH_QRTR
|
||||
|
||||
+2
-3
@@ -55,9 +55,8 @@ const gchar *mm_context_get_test_plugin_dir (void);
|
||||
gboolean mm_context_get_test_no_udev (void);
|
||||
#endif
|
||||
#if defined WITH_SUSPEND_RESUME
|
||||
gboolean mm_context_get_test_no_suspend_resume (void);
|
||||
gboolean mm_context_get_test_quick_suspend_resume (void);
|
||||
gboolean mm_context_get_test_radio_off_suspend_resume (void);
|
||||
gboolean mm_context_get_test_no_suspend_resume (void);
|
||||
gboolean mm_context_get_test_quick_suspend_resume (void);
|
||||
#endif
|
||||
#if defined WITH_QRTR
|
||||
gboolean mm_context_get_test_no_qrtr (void);
|
||||
|
||||
Reference in New Issue
Block a user