diff options
author | Dan Williams <dcbw@redhat.com> | 2009-09-08 17:31:54 -0700 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2009-09-08 17:34:04 -0700 |
commit | 14e5c52f78e7ad23b18b111e3271cbecad6acf3f (patch) | |
tree | ee6929c990c63139e4209a94f3e2d8c617547f4a /plugins/mm-modem-sierra.c | |
parent | 6cf01d2ab698d05eb58bffa7e85f41024f5c0546 (diff) |
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.
Diffstat (limited to 'plugins/mm-modem-sierra.c')
-rw-r--r-- | plugins/mm-modem-sierra.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/plugins/mm-modem-sierra.c b/plugins/mm-modem-sierra.c index 79b7ec30..ed9b887b 100644 --- a/plugins/mm-modem-sierra.c +++ b/plugins/mm-modem-sierra.c @@ -84,16 +84,32 @@ 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 = user_data; + + if (error) { + info->error = g_error_copy (error); + mm_callback_info_schedule (info); + return; + } + mm_serial_port_queue_command (port, "Z E0 V1 X4 &C1 +CMEE=1", 3, init_done, user_data); } static void -disable_flash_done (MMSerialPort *port, gpointer user_data) +disable_flash_done (MMSerialPort *port, GError *error, gpointer user_data) { + MMCallbackInfo *info = user_data; + + if (error) { + info->error = g_error_copy (error); + mm_callback_info_schedule (info); + return; + } + mm_serial_port_close (port); - mm_callback_info_schedule ((MMCallbackInfo *) user_data); + mm_callback_info_schedule (info); } static void @@ -118,13 +134,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); } } |