aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-10-31 10:54:25 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-10-31 10:54:25 +0100
commitdaf1a353c32e3bbf182e8c9c2948c35627c3111d (patch)
treef5cb0e57639ec7f63bb1be538f3630fe109ec84b
parent25d35b6f915b65565ec90d17bfdaa96a7e6c391f (diff)
core: allow QMI modems without AT ports
-rw-r--r--src/mm-base-modem.c24
-rw-r--r--src/mm-broadband-modem-qmi.c62
-rw-r--r--src/mm-broadband-modem.c13
3 files changed, 86 insertions, 13 deletions
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
index 0224e0b5..db277097 100644
--- a/src/mm-base-modem.c
+++ b/src/mm-base-modem.c
@@ -920,17 +920,22 @@ mm_base_modem_organize_ports (MMBaseModem *self,
/* Fall back to a secondary port if we didn't find a primary port */
if (!primary) {
+#if defined WITH_QMI
+ /* On QMI-based modems we do allow not having a primary AT port */
+ if (!secondary && !qmi_primary) {
+#else
if (!secondary) {
+#endif
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
- "Failed to find primary port");
+ "Failed to find primary AT port");
return FALSE;
+ } else {
+ primary = secondary;
+ secondary = NULL;
}
- primary = secondary;
- secondary = NULL;
}
- g_assert (primary);
/* If the plugin didn't give us any secondary ports, use any additional
* primary ports or backup secondary ports as secondary.
@@ -938,6 +943,17 @@ mm_base_modem_organize_ports (MMBaseModem *self,
if (!secondary)
secondary = backup_primary ? backup_primary : backup_secondary;
+#if defined WITH_QMI
+ /* On QMI-based modems, we need to have at least a net port */
+ if (qmi_primary && !data_primary) {
+ g_set_error_literal (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Failed to find a net port in the QMI modem");
+ return FALSE;
+ }
+#endif
+
/* Data port defaults to primary AT port */
if (!data_primary)
data_primary = MM_PORT (primary);
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index c09ef462..13d68c3b 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -7024,6 +7024,56 @@ firmware_change_current (MMIfaceModemFirmware *self,
}
/*****************************************************************************/
+/* First enabling step */
+
+static gboolean
+enabling_started_finish (MMBroadbandModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
+}
+
+static void
+parent_enabling_started_ready (MMBroadbandModem *self,
+ GAsyncResult *res,
+ GSimpleAsyncResult *simple)
+{
+ GError *error = NULL;
+
+ if (!MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_qmi_parent_class)->enabling_started_finish (
+ self,
+ res,
+ &error)) {
+ /* Don't treat this as fatal. Parent enabling may fail if it cannot grab a primary
+ * AT port, which isn't really an issue in QMI-based modems */
+ mm_dbg ("Couldn't start parent enabling: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_simple_async_result_set_op_res_gboolean (simple, TRUE);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+}
+
+static void
+enabling_started (MMBroadbandModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+
+ result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ enabling_started);
+ MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_qmi_parent_class)->enabling_started (
+ self,
+ (GAsyncReadyCallback)parent_enabling_started_ready,
+ result);
+}
+
+/*****************************************************************************/
/* First initialization step */
typedef struct {
@@ -7070,11 +7120,13 @@ parent_initialization_started_ready (MMBroadbandModem *self,
res,
&error);
if (error) {
- g_prefix_error (&error, "Couldn't start parent initialization: ");
- g_simple_async_result_take_error (ctx->result, error);
- } else
- g_simple_async_result_set_op_res_gpointer (ctx->result, parent_ctx, NULL);
+ /* Don't treat this as fatal. Parent initialization may fail if it cannot grab a primary
+ * AT port, which isn't really an issue in QMI-based modems */
+ mm_dbg ("Couldn't start parent initialization: %s", error->message);
+ g_error_free (error);
+ }
+ g_simple_async_result_set_op_res_gpointer (ctx->result, parent_ctx, NULL);
initialization_started_context_complete_and_free (ctx);
}
@@ -7455,4 +7507,6 @@ mm_broadband_modem_qmi_class_init (MMBroadbandModemQmiClass *klass)
broadband_modem_class->initialization_started = initialization_started;
broadband_modem_class->initialization_started_finish = initialization_started_finish;
+ broadband_modem_class->enabling_started = enabling_started;
+ broadband_modem_class->enabling_started_finish = enabling_started_finish;
}
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 11725989..95a61cdb 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -6584,7 +6584,8 @@ initialization_stopped (MMBroadbandModem *self,
{
PortsContext *ctx = (PortsContext *)user_data;
- ports_context_unref (ctx);
+ if (ctx)
+ ports_context_unref (ctx);
return TRUE;
}
@@ -6609,12 +6610,13 @@ initialization_started_finish (MMBroadbandModem *self,
GAsyncResult *res,
GError **error)
{
+ gpointer ref;
+
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
return NULL;
- return ((gpointer) ports_context_ref (
- g_simple_async_result_get_op_res_gpointer (
- G_SIMPLE_ASYNC_RESULT (res))));
+ ref = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
+ return ref ? ports_context_ref (ref) : NULL;
}
static gboolean
@@ -7622,8 +7624,9 @@ initialization_started_ready (MMBroadbandModem *self,
GError *error = NULL;
gpointer ports_ctx;
+ /* May return NULL without error */
ports_ctx = MM_BROADBAND_MODEM_GET_CLASS (self)->initialization_started_finish (self, result, &error);
- if (!ports_ctx) {
+ if (error) {
mm_warn ("Couldn't start initialization: %s", error->message);
g_error_free (error);