From 14e5c52f78e7ad23b18b111e3271cbecad6acf3f Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 8 Sep 2009 17:31:54 -0700 Subject: 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. --- plugins/mm-modem-zte.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'plugins/mm-modem-zte.c') diff --git a/plugins/mm-modem-zte.c b/plugins/mm-modem-zte.c index 0bec7f60..51e6e485 100644 --- a/plugins/mm-modem-zte.c +++ b/plugins/mm-modem-zte.c @@ -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); } } -- cgit v1.2.3-70-g09d2