core: don't allow concurrent flashes on the same device
Previously, a few operations (like disable) could trigger a modem flash in parallel with another flash. That's wrong, don't allow that. At the same time, add in finer-grained error checking on serial port speed operations, and fix a GSM generic bug that would send the POWER_UP string on disable.
This commit is contained in:
@@ -95,8 +95,16 @@ pre_init_done (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
enable_flash_done (MMSerialPort *port, gpointer user_data)
|
||||
enable_flash_done (MMSerialPort *port, GError *error, gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
|
||||
if (error) {
|
||||
info->error = g_error_copy (error);
|
||||
mm_callback_info_schedule (info);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_serial_port_queue_command (port, "E0 V1", 3, pre_init_done, user_data);
|
||||
}
|
||||
|
||||
@@ -111,8 +119,16 @@ disable_done (MMSerialPort *port,
|
||||
}
|
||||
|
||||
static void
|
||||
disable_flash_done (MMSerialPort *port, gpointer user_data)
|
||||
disable_flash_done (MMSerialPort *port, GError *error, gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
|
||||
if (error) {
|
||||
info->error = g_error_copy (error);
|
||||
mm_callback_info_schedule (info);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_serial_port_queue_command (port, "+CFUN=0", 5, disable_done, user_data);
|
||||
}
|
||||
|
||||
@@ -137,13 +153,15 @@ enable (MMModem *modem,
|
||||
if (mm_port_get_connected (MM_PORT (primary)))
|
||||
mm_serial_port_flash (primary, 1000, disable_flash_done, info);
|
||||
else
|
||||
disable_flash_done (primary, info);
|
||||
disable_flash_done (primary, NULL, info);
|
||||
} else {
|
||||
if (mm_serial_port_open (primary, &info->error))
|
||||
mm_serial_port_flash (primary, 100, enable_flash_done, info);
|
||||
|
||||
if (info->error)
|
||||
if (!mm_serial_port_open (primary, &info->error)) {
|
||||
g_assert (info->error);
|
||||
mm_callback_info_schedule (info);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_serial_port_flash (primary, 100, enable_flash_done, info);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user