aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mm-broadband-modem-qmi.c45
-rw-r--r--src/mm-sim-qmi.c26
-rw-r--r--src/mm-sms-qmi.c26
3 files changed, 76 insertions, 21 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index d781301f..7a6f13ed 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -104,9 +104,19 @@ peek_qmi_client (MMBroadbandModemQmi *self,
QmiService service,
GError **error)
{
+ MMQmiPort *port;
QmiClient *client;
- client = mm_qmi_port_peek_client (mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self)),
+ port = mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self));
+ if (!port) {
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't peek QMI port");
+ return NULL;
+ }
+
+ client = mm_qmi_port_peek_client (port,
service,
MM_QMI_PORT_FLAG_DEFAULT);
if (!client)
@@ -4941,16 +4951,21 @@ messaging_check_support (MMIfaceModemMessaging *self,
{
GSimpleAsyncResult *result;
gboolean supported;
+ MMQmiPort *port;
result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
messaging_check_support);
- /* If we have support for the WMS client, messaging is supported */
- supported = !!mm_qmi_port_peek_client (mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self)),
- QMI_SERVICE_WMS,
- MM_QMI_PORT_FLAG_DEFAULT);
+ port = mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self));
+ if (!port)
+ supported = FALSE;
+ else
+ /* If we have support for the WMS client, messaging is supported */
+ supported = !!mm_qmi_port_peek_client (port,
+ QMI_SERVICE_WMS,
+ MM_QMI_PORT_FLAG_DEFAULT);
/* We only handle 3GPP messaging (PDU based) currently, so just ignore
* CDMA-only QMI modems */
@@ -5673,6 +5688,7 @@ parent_load_capabilities_ready (MMIfaceModemLocation *self,
{
MMModemLocationSource sources;
GError *error = NULL;
+ MMQmiPort *port;
sources = iface_modem_location_parent->load_capabilities_finish (self, res, &error);
if (error) {
@@ -5682,11 +5698,13 @@ parent_load_capabilities_ready (MMIfaceModemLocation *self,
return;
}
+ port = mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self));
+
/* Now our own check.
* If we have support for the PDS client, GPS location is supported */
- if (mm_qmi_port_peek_client (mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self)),
- QMI_SERVICE_PDS,
- MM_QMI_PORT_FLAG_DEFAULT))
+ if (port && mm_qmi_port_peek_client (port,
+ QMI_SERVICE_PDS,
+ MM_QMI_PORT_FLAG_DEFAULT))
sources |= (MM_MODEM_LOCATION_SOURCE_GPS_NMEA | MM_MODEM_LOCATION_SOURCE_GPS_RAW);
/* So we're done, complete */
@@ -6931,7 +6949,16 @@ initialization_started (MMBroadbandModem *self,
user_data,
initialization_started);
ctx->qmi = mm_base_modem_get_port_qmi (MM_BASE_MODEM (self));
- g_assert (ctx->qmi);
+
+ /* This may happen if we unplug the modem unexpectedly */
+ if (!ctx->qmi) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Cannot initialize: QMI port went missing");
+ initialization_started_context_complete_and_free (ctx);
+ return;
+ }
if (mm_qmi_port_is_open (ctx->qmi)) {
/* Nothing to be done, just launch parent's callback */
diff --git a/src/mm-sim-qmi.c b/src/mm-sim-qmi.c
index 63111b54..578bf774 100644
--- a/src/mm-sim-qmi.c
+++ b/src/mm-sim-qmi.c
@@ -40,16 +40,30 @@ ensure_qmi_client (MMSimQmi *self,
{
MMBaseModem *modem = NULL;
QmiClient *client;
+ MMQmiPort *port;
g_object_get (self,
MM_SIM_MODEM, &modem,
NULL);
g_assert (MM_IS_BASE_MODEM (modem));
- client = mm_qmi_port_peek_client (mm_base_modem_peek_port_qmi (modem),
+ port = mm_base_modem_peek_port_qmi (modem);
+ g_object_unref (modem);
+
+ if (!port) {
+ g_simple_async_report_error_in_idle (G_OBJECT (self),
+ callback,
+ user_data,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't peek QMI port");
+ return FALSE;
+ }
+
+ client = mm_qmi_port_peek_client (port,
service,
MM_QMI_PORT_FLAG_DEFAULT);
- if (!client)
+ if (!client) {
g_simple_async_report_error_in_idle (G_OBJECT (self),
callback,
user_data,
@@ -57,11 +71,11 @@ ensure_qmi_client (MMSimQmi *self,
MM_CORE_ERROR_FAILED,
"Couldn't peek client for service '%s'",
qmi_service_get_string (service));
- else
- *o_client = client;
+ return FALSE;
+ }
- g_object_unref (modem);
- return !!client;
+ *o_client = client;
+ return TRUE;
}
/*****************************************************************************/
diff --git a/src/mm-sms-qmi.c b/src/mm-sms-qmi.c
index 2b167ed2..fbdaeb02 100644
--- a/src/mm-sms-qmi.c
+++ b/src/mm-sms-qmi.c
@@ -43,16 +43,30 @@ ensure_qmi_client (MMSmsQmi *self,
{
MMBaseModem *modem = NULL;
QmiClient *client;
+ MMQmiPort *port;
g_object_get (self,
MM_SMS_MODEM, &modem,
NULL);
g_assert (MM_IS_BASE_MODEM (modem));
- client = mm_qmi_port_peek_client (mm_base_modem_peek_port_qmi (modem),
+ port = mm_base_modem_peek_port_qmi (modem);
+ g_object_unref (modem);
+
+ if (!port) {
+ g_simple_async_report_error_in_idle (G_OBJECT (self),
+ callback,
+ user_data,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't peek QMI port");
+ return FALSE;
+ }
+
+ client = mm_qmi_port_peek_client (port,
service,
MM_QMI_PORT_FLAG_DEFAULT);
- if (!client)
+ if (!client) {
g_simple_async_report_error_in_idle (G_OBJECT (self),
callback,
user_data,
@@ -60,11 +74,11 @@ ensure_qmi_client (MMSmsQmi *self,
MM_CORE_ERROR_FAILED,
"Couldn't peek client for service '%s'",
qmi_service_get_string (service));
- else
- *o_client = client;
+ return FALSE;
+ }
- g_object_unref (modem);
- return !!client;
+ *o_client = client;
+ return TRUE;
}
/*****************************************************************************/