aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-10-24 10:36:24 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-10-25 16:19:11 +0200
commitd3ddfd583c5bd4cf3fc45886983b0bf4f26a1d3d (patch)
tree139c37ce5c6f560e5dc1998133d042aa71cf34b6 /src
parent89723c7ef28e3b071413bb22c561abfa5724d3ea (diff)
broadband-modem: make sure the primary port is used for the modem init sequence
Diffstat (limited to 'src')
-rw-r--r--src/mm-broadband-modem.c57
1 files changed, 44 insertions, 13 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 7423130a..bb2d231b 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -2303,15 +2303,24 @@ modem_init_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error)
{
- GError *inner_error = NULL;
+ return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
+}
- mm_base_modem_at_sequence_finish (MM_BASE_MODEM (self), res, NULL, &inner_error);
- if (inner_error) {
- g_propagate_error (error, inner_error);
- return FALSE;
- }
+static void
+modem_init_sequence_ready (MMBaseModem *self,
+ GAsyncResult *res,
+ GSimpleAsyncResult *simple)
+{
+ GError *error = NULL;
- return TRUE;
+ mm_base_modem_at_sequence_full_finish (MM_BASE_MODEM (self), res, NULL, &error);
+ if (error)
+ g_simple_async_result_take_error (simple, error);
+ else
+ g_simple_async_result_set_op_res_gboolean (simple, TRUE);
+
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
}
static const MMBaseModemAtCommand modem_init_sequence[] = {
@@ -2341,12 +2350,34 @@ modem_init (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- mm_base_modem_at_sequence (MM_BASE_MODEM (self),
- modem_init_sequence,
- NULL, /* response_processor_context */
- NULL, /* response_processor_context_free */
- callback,
- user_data);
+ MMAtSerialPort *primary;
+ GSimpleAsyncResult *result;
+
+ result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ modem_init);
+
+ primary = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
+ if (!primary) {
+ g_simple_async_result_set_error (
+ result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Need primary AT port to run modem init sequence");
+ g_simple_async_result_complete_in_idle (result);
+ g_object_unref (result);
+ return;
+ }
+
+ mm_base_modem_at_sequence_full (MM_BASE_MODEM (self),
+ primary,
+ modem_init_sequence,
+ NULL, /* response_processor_context */
+ NULL, /* response_processor_context_free */
+ NULL, /* cancellable */
+ (GAsyncReadyCallback)modem_init_sequence_ready,
+ result);
}
/*****************************************************************************/