base-modem: when getting best AT port, assume we may have lost specific ports
Don't assume that primary port is always set.
This commit is contained in:
@@ -365,22 +365,21 @@ mm_base_modem_get_best_at_port (MMBaseModem *self,
|
|||||||
|
|
||||||
/* Decide which port to use */
|
/* Decide which port to use */
|
||||||
port = mm_base_modem_get_port_primary (self);
|
port = mm_base_modem_get_port_primary (self);
|
||||||
g_assert (port);
|
if (port && !mm_port_get_connected (MM_PORT (port)))
|
||||||
if (mm_port_get_connected (MM_PORT (port))) {
|
return port;
|
||||||
|
|
||||||
/* If primary port is connected, check if we can get the secondary
|
/* If primary port is connected, check if we can get the secondary
|
||||||
* port */
|
* port */
|
||||||
port = mm_base_modem_get_port_secondary (self);
|
port = mm_base_modem_get_port_secondary (self);
|
||||||
if (!port) {
|
if (port && !mm_port_get_connected (MM_PORT (port)))
|
||||||
/* If we don't have a secondary port, we need to halt the AT
|
return port;
|
||||||
* operation */
|
|
||||||
|
/* Otherwise, we cannot get any port */
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_CONNECTED,
|
MM_CORE_ERROR_CONNECTED,
|
||||||
"No port available to run command");
|
"No port available to run command");
|
||||||
}
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
return port;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user