core: allow QMI modems without AT ports

This commit is contained in:
Aleksander Morgado
2012-10-31 10:54:25 +01:00
parent 25d35b6f91
commit daf1a353c3
3 changed files with 86 additions and 13 deletions
+20 -4
View File
@@ -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);
+58 -4
View File
@@ -7023,6 +7023,56 @@ firmware_change_current (MMIfaceModemFirmware *self,
qmi_message_dms_set_firmware_preference_input_unref (input);
}
/*****************************************************************************/
/* 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 */
@@ -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;
}
+8 -5
View File
@@ -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);