aboutsummaryrefslogtreecommitdiff
path: root/src/mm-base-modem.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-03-07 17:07:36 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-16 14:53:23 +0100
commit4bdfd25de18bc6abaae6197f5f4646586c0da511 (patch)
treeb656082e788f7845226cf1e6712d9d8ea28876d4 /src/mm-base-modem.c
parentc24012ef1b6a4ba1368ca22f30b7db6c5ccec334 (diff)
base-modem: when getting best AT port, assume we may have lost specific ports
Don't assume that primary port is always set.
Diffstat (limited to 'src/mm-base-modem.c')
-rw-r--r--src/mm-base-modem.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
index 9f187306..668199b9 100644
--- a/src/mm-base-modem.c
+++ b/src/mm-base-modem.c
@@ -365,22 +365,21 @@ mm_base_modem_get_best_at_port (MMBaseModem *self,
/* Decide which port to use */
port = mm_base_modem_get_port_primary (self);
- g_assert (port);
- if (mm_port_get_connected (MM_PORT (port))) {
- /* If primary port is connected, check if we can get the secondary
- * port */
- port = mm_base_modem_get_port_secondary (self);
- if (!port) {
- /* If we don't have a secondary port, we need to halt the AT
- * operation */
- g_set_error (error,
- MM_CORE_ERROR,
- MM_CORE_ERROR_CONNECTED,
- "No port available to run command");
- }
- }
-
- return port;
+ if (port && !mm_port_get_connected (MM_PORT (port)))
+ return port;
+
+ /* If primary port is connected, check if we can get the secondary
+ * port */
+ port = mm_base_modem_get_port_secondary (self);
+ if (port && !mm_port_get_connected (MM_PORT (port)))
+ return port;
+
+ /* Otherwise, we cannot get any port */
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_CONNECTED,
+ "No port available to run command");
+ return NULL;
}
static void