diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2017-01-13 20:57:30 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-01-16 11:24:16 +0100 |
commit | b12a257e523e0cb6c266b707814c60e9689f4a58 (patch) | |
tree | f12a9c82aa76354a839299f1a7681c6b36e09c4f /src/qmi-firmware-update | |
parent | 86293bebe23d4e43b8ea87a5235b57fd5ea3eaee (diff) | |
download | external_libqmi-b12a257e523e0cb6c266b707814c60e9689f4a58.zip external_libqmi-b12a257e523e0cb6c266b707814c60e9689f4a58.tar.gz external_libqmi-b12a257e523e0cb6c266b707814c60e9689f4a58.tar.bz2 |
qmi-firmware-update: don't release CID if reset operation successful
Diffstat (limited to 'src/qmi-firmware-update')
-rw-r--r-- | src/qmi-firmware-update/qfu-reseter.c | 10 | ||||
-rw-r--r-- | src/qmi-firmware-update/qfu-updater.c | 45 |
2 files changed, 21 insertions, 34 deletions
diff --git a/src/qmi-firmware-update/qfu-reseter.c b/src/qmi-firmware-update/qfu-reseter.c index b37ff2d..17f7913 100644 --- a/src/qmi-firmware-update/qfu-reseter.c +++ b/src/qmi-firmware-update/qfu-reseter.c @@ -52,6 +52,7 @@ typedef struct { /* QMI client amd device */ QmiDevice *qmi_device; QmiClientDms *qmi_client; + gboolean ignore_release_cid; /* List of AT devices */ GList *at_devices; GList *current; @@ -68,7 +69,9 @@ run_context_free (RunContext *ctx) g_assert (ctx->qmi_device); qmi_device_release_client (ctx->qmi_device, QMI_CLIENT (ctx->qmi_client), - QMI_DEVICE_RELEASE_CLIENT_FLAGS_RELEASE_CID, + (ctx->ignore_release_cid ? + QMI_DEVICE_RELEASE_CLIENT_FLAGS_NONE : + QMI_DEVICE_RELEASE_CLIENT_FLAGS_RELEASE_CID), 10, NULL, NULL, NULL); g_object_unref (ctx->qmi_client); } @@ -179,6 +182,7 @@ run_context_step_at (GTask *task) /* Success! */ g_debug ("[qfu-reseter] successfully run 'at boothold' operation"); + ctx->ignore_release_cid = TRUE; g_task_return_boolean (task, TRUE); g_object_unref (task); } @@ -190,6 +194,9 @@ set_firmware_id_ready (QmiClientDms *client, { QmiMessageDmsSetFirmwareIdOutput *output; GError *error = NULL; + RunContext *ctx; + + ctx = (RunContext *) g_task_get_task_data (task); output = qmi_client_dms_set_firmware_id_finish (client, res, &error); if (!output || !qmi_message_dms_set_firmware_id_output_get_result (output, &error)) { @@ -203,6 +210,7 @@ set_firmware_id_ready (QmiClientDms *client, } g_debug ("[qfu-reseter] successfully run 'set firmware id' operation"); + ctx->ignore_release_cid = TRUE; g_task_return_boolean (task, TRUE); g_object_unref (task); } diff --git a/src/qmi-firmware-update/qfu-updater.c b/src/qmi-firmware-update/qfu-updater.c index 328b583..750d487 100644 --- a/src/qmi-firmware-update/qfu-updater.c +++ b/src/qmi-firmware-update/qfu-updater.c @@ -116,6 +116,8 @@ run_context_free (RunContext *ctx) g_object_unref (&ctx->qdl_device); if (ctx->qmi_client) { g_assert (ctx->qmi_device); + /* This release only happens when cleaning up from an error, + * therefore always release CID */ qmi_device_release_client (ctx->qmi_device, QMI_CLIENT (ctx->qmi_client), QMI_DEVICE_RELEASE_CLIENT_FLAGS_RELEASE_CID, @@ -436,28 +438,24 @@ run_context_step_wait_for_tty (GTask *task) } static void -qmi_client_release_ready (QmiDevice *device, - GAsyncResult *res, - GTask *task) +run_context_step_cleanup_qmi_device (GTask *task) { RunContext *ctx; - GError *error = NULL; ctx = (RunContext *) g_task_get_task_data (task); - if (!qmi_device_release_client_finish (device, res, &error)) { - g_debug ("[qfu-updater] error (ignored): couldn't release DMS QMI client: %s", error->message); - g_clear_error (&error); - } else - g_debug ("[qfu-updater] DMS QMI client released"); + g_debug ("[qfu-updater] cleaning up QMI device..."); - if (!qmi_device_close (ctx->qmi_device, &error)) { - g_debug ("[qfu-updater] error (ignored): couldn't close QMI device: %s", error->message); - g_clear_error (&error); - } else - g_debug ("[qfu-updater] QMI device closed"); + /* We don't release CID as we're going to reset anyway */ + qmi_device_release_client (ctx->qmi_device, + QMI_CLIENT (ctx->qmi_client), + QMI_DEVICE_RELEASE_CLIENT_FLAGS_NONE, + 10, NULL, NULL, NULL); + g_clear_object (&ctx->qmi_client); + qmi_device_close (ctx->qmi_device, NULL); g_clear_object (&ctx->qmi_device); + g_clear_object (&ctx->cdc_wdm_file); /* If nothing to download, we're done */ @@ -471,25 +469,6 @@ qmi_client_release_ready (QmiDevice *device, } static void -run_context_step_cleanup_qmi_device (GTask *task) -{ - RunContext *ctx; - - ctx = (RunContext *) g_task_get_task_data (task); - - g_debug ("[qfu-updater] releasing DMS QMI client..."); - qmi_device_release_client (ctx->qmi_device, - QMI_CLIENT (ctx->qmi_client), - QMI_DEVICE_RELEASE_CLIENT_FLAGS_RELEASE_CID, - 10, - g_task_get_cancellable (task), - (GAsyncReadyCallback) qmi_client_release_ready, - task); - - g_clear_object (&ctx->qmi_client); -} - -static void reset_or_offline_ready (QmiClientDms *client, GAsyncResult *res, GTask *task) |