core: flash failure on disconnect shouldn't be a hard error (rh #578280)

This commit is contained in:
Dan Williams
2010-04-24 23:40:24 -07:00
parent 411051b1f3
commit b9bb12a01e
8 changed files with 26 additions and 13 deletions

View File

@@ -406,7 +406,7 @@ do_enable (MMGenericGsm *modem, MMModemFn callback, gpointer user_data)
g_assert (primary); g_assert (primary);
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data); info = mm_callback_info_new (MM_MODEM (modem), callback, user_data);
mm_serial_port_flash (MM_SERIAL_PORT (primary), 100, enable_flash_done, info); mm_serial_port_flash (MM_SERIAL_PORT (primary), 100, FALSE, enable_flash_done, info);
} }
static void static void

View File

@@ -43,6 +43,7 @@ mm_serial_error_get_type (void)
ENUM_ENTRY (MM_SERIAL_SEND_FAILED, "SerialSendfailed"), ENUM_ENTRY (MM_SERIAL_SEND_FAILED, "SerialSendfailed"),
ENUM_ENTRY (MM_SERIAL_RESPONSE_TIMEOUT, "SerialResponseTimeout"), ENUM_ENTRY (MM_SERIAL_RESPONSE_TIMEOUT, "SerialResponseTimeout"),
ENUM_ENTRY (MM_SERIAL_OPEN_FAILED_NO_DEVICE, "SerialOpenFailedNoDevice"), ENUM_ENTRY (MM_SERIAL_OPEN_FAILED_NO_DEVICE, "SerialOpenFailedNoDevice"),
ENUM_ENTRY (MM_SERIAL_ERROR_FLASH_FAILED, "SerialFlashFailed"),
{ 0, 0, 0 } { 0, 0, 0 }
}; };

View File

@@ -23,7 +23,8 @@ enum {
MM_SERIAL_OPEN_FAILED = 0, MM_SERIAL_OPEN_FAILED = 0,
MM_SERIAL_SEND_FAILED = 1, MM_SERIAL_SEND_FAILED = 1,
MM_SERIAL_RESPONSE_TIMEOUT = 2, MM_SERIAL_RESPONSE_TIMEOUT = 2,
MM_SERIAL_OPEN_FAILED_NO_DEVICE = 3 MM_SERIAL_OPEN_FAILED_NO_DEVICE = 3,
MM_SERIAL_ERROR_FLASH_FAILED = 4,
}; };
#define MM_SERIAL_ERROR (mm_serial_error_quark ()) #define MM_SERIAL_ERROR (mm_serial_error_quark ())

View File

@@ -588,7 +588,7 @@ enable (MMModem *modem,
MM_MODEM_STATE_ENABLING, MM_MODEM_STATE_ENABLING,
MM_MODEM_STATE_REASON_NONE); MM_MODEM_STATE_REASON_NONE);
mm_serial_port_flash (MM_SERIAL_PORT (priv->primary), 100, flash_done, info); mm_serial_port_flash (MM_SERIAL_PORT (priv->primary), 100, FALSE, flash_done, info);
} }
static void static void
@@ -681,7 +681,7 @@ disable (MMModem *modem,
MM_MODEM_STATE_REASON_NONE); MM_MODEM_STATE_REASON_NONE);
if (mm_port_get_connected (MM_PORT (priv->primary))) if (mm_port_get_connected (MM_PORT (priv->primary)))
mm_serial_port_flash (MM_SERIAL_PORT (priv->primary), 1000, disable_flash_done, info); mm_serial_port_flash (MM_SERIAL_PORT (priv->primary), 1000, TRUE, disable_flash_done, info);
else else
disable_flash_done (MM_SERIAL_PORT (priv->primary), NULL, info); disable_flash_done (MM_SERIAL_PORT (priv->primary), NULL, info);
} }
@@ -776,7 +776,7 @@ disconnect (MMModem *modem,
NULL); NULL);
mm_modem_set_state (modem, MM_MODEM_STATE_DISCONNECTING, MM_MODEM_STATE_REASON_NONE); mm_modem_set_state (modem, MM_MODEM_STATE_DISCONNECTING, MM_MODEM_STATE_REASON_NONE);
mm_serial_port_flash (MM_SERIAL_PORT (priv->primary), 1000, disconnect_flash_done, info); mm_serial_port_flash (MM_SERIAL_PORT (priv->primary), 1000, TRUE, disconnect_flash_done, info);
} }
static void static void

View File

@@ -912,7 +912,7 @@ real_do_enable (MMGenericGsm *self, MMModemFn callback, gpointer user_data)
MMCallbackInfo *info; MMCallbackInfo *info;
info = mm_callback_info_new (MM_MODEM (self), callback, user_data); info = mm_callback_info_new (MM_MODEM (self), callback, user_data);
mm_serial_port_flash (MM_SERIAL_PORT (priv->primary), 100, enable_flash_done, info); mm_serial_port_flash (MM_SERIAL_PORT (priv->primary), 100, FALSE, enable_flash_done, info);
} }
static void static void
@@ -1072,7 +1072,7 @@ disable (MMModem *modem,
MM_MODEM_STATE_REASON_NONE); MM_MODEM_STATE_REASON_NONE);
if (mm_port_get_connected (MM_PORT (priv->primary))) if (mm_port_get_connected (MM_PORT (priv->primary)))
mm_serial_port_flash (MM_SERIAL_PORT (priv->primary), 1000, disable_flash_done, info); mm_serial_port_flash (MM_SERIAL_PORT (priv->primary), 1000, TRUE, disable_flash_done, info);
else else
disable_flash_done (MM_SERIAL_PORT (priv->primary), NULL, info); disable_flash_done (MM_SERIAL_PORT (priv->primary), NULL, info);
} }
@@ -2195,7 +2195,7 @@ real_do_disconnect (MMGenericGsm *self,
MMCallbackInfo *info; MMCallbackInfo *info;
info = mm_callback_info_new (MM_MODEM (self), callback, user_data); info = mm_callback_info_new (MM_MODEM (self), callback, user_data);
mm_serial_port_flash (MM_SERIAL_PORT (priv->primary), 1000, disconnect_flash_done, info); mm_serial_port_flash (MM_SERIAL_PORT (priv->primary), 1000, TRUE, disconnect_flash_done, info);
} }
static void static void

View File

@@ -805,7 +805,7 @@ try_open (gpointer user_data)
g_debug ("(%s): probe requested by plugin '%s'", g_debug ("(%s): probe requested by plugin '%s'",
g_udev_device_get_name (port), g_udev_device_get_name (port),
mm_plugin_get_name (MM_PLUGIN (task_priv->plugin))); mm_plugin_get_name (MM_PLUGIN (task_priv->plugin)));
mm_serial_port_flash (MM_SERIAL_PORT (task_priv->probe_port), 100, flash_done, task); mm_serial_port_flash (MM_SERIAL_PORT (task_priv->probe_port), 100, TRUE, flash_done, task);
} }
return FALSE; return FALSE;

View File

@@ -958,8 +958,14 @@ flash_do (gpointer data)
priv->flash_id = 0; priv->flash_id = 0;
if (!set_speed (info->port, info->current_speed, &error)) if (info->current_speed) {
g_assert (error); if (!set_speed (info->port, info->current_speed, &error))
g_assert (error);
} else {
error = g_error_new_literal (MM_SERIAL_ERROR,
MM_SERIAL_ERROR_FLASH_FAILED,
"Failed to retrieve current speed");
}
info->callback (info->port, error, info->user_data); info->callback (info->port, error, info->user_data);
g_clear_error (&error); g_clear_error (&error);
@@ -970,6 +976,7 @@ flash_do (gpointer data)
gboolean gboolean
mm_serial_port_flash (MMSerialPort *self, mm_serial_port_flash (MMSerialPort *self,
guint32 flash_time, guint32 flash_time,
gboolean ignore_errors,
MMSerialFlashFn callback, MMSerialFlashFn callback,
gpointer user_data) gpointer user_data)
{ {
@@ -977,6 +984,7 @@ mm_serial_port_flash (MMSerialPort *self,
MMSerialPortPrivate *priv; MMSerialPortPrivate *priv;
speed_t cur_speed = 0; speed_t cur_speed = 0;
GError *error = NULL; GError *error = NULL;
gboolean success;
g_return_val_if_fail (MM_IS_SERIAL_PORT (self), FALSE); g_return_val_if_fail (MM_IS_SERIAL_PORT (self), FALSE);
g_return_val_if_fail (callback != NULL, FALSE); g_return_val_if_fail (callback != NULL, FALSE);
@@ -992,7 +1000,8 @@ mm_serial_port_flash (MMSerialPort *self,
return FALSE; return FALSE;
} }
if (!get_speed (self, &cur_speed, &error)) { success = get_speed (self, &cur_speed, &error);
if (!success && !ignore_errors) {
callback (self, error, user_data); callback (self, error, user_data);
g_error_free (error); g_error_free (error);
return FALSE; return FALSE;
@@ -1004,7 +1013,8 @@ mm_serial_port_flash (MMSerialPort *self,
info->callback = callback; info->callback = callback;
info->user_data = user_data; info->user_data = user_data;
if (!set_speed (self, B0, &error)) { success = set_speed (self, B0, &error);
if (!success && !ignore_errors) {
callback (self, error, user_data); callback (self, error, user_data);
g_error_free (error); g_error_free (error);
return FALSE; return FALSE;

View File

@@ -110,6 +110,7 @@ void mm_serial_port_close (MMSerialPort *self);
gboolean mm_serial_port_flash (MMSerialPort *self, gboolean mm_serial_port_flash (MMSerialPort *self,
guint32 flash_time, guint32 flash_time,
gboolean ignore_errors,
MMSerialFlashFn callback, MMSerialFlashFn callback,
gpointer user_data); gpointer user_data);
void mm_serial_port_flash_cancel (MMSerialPort *self); void mm_serial_port_flash_cancel (MMSerialPort *self);