diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2012-06-24 23:20:25 -0700 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-06-24 23:20:25 -0700 |
commit | 29067f75bc8a873febe3a8d90edce4ccf4070169 (patch) | |
tree | 9117569720c9de31d07623efbaa468c19212b1e8 /drivers/qmimodem | |
parent | d4d639f40e06511059512dde49d23fb73143074f (diff) |
qmimodem: Add support for canceling service requests
Diffstat (limited to 'drivers/qmimodem')
-rw-r--r-- | drivers/qmimodem/qmi.c | 44 | ||||
-rw-r--r-- | drivers/qmimodem/qmi.h | 2 |
2 files changed, 46 insertions, 0 deletions
diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 0ebebe5d..24aed4ef 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1670,6 +1670,50 @@ uint16_t qmi_service_send(struct qmi_service *service, return hdr->transaction; } +bool qmi_service_cancel(struct qmi_service *service, uint16_t tid) +{ + struct qmi_device *device; + struct service_send_data *data; + struct qmi_request *req; + GList *list; + + if (!service || !tid) + return false; + + if (!service->client_id) + return false; + + device = service->device; + if (!device) + return false; + + list = g_queue_find_custom(device->req_queue, + GUINT_TO_POINTER(tid), __request_compare); + if (list) { + req = list->data; + + g_queue_delete_link(device->req_queue, list); + } else { + list = g_queue_find_custom(device->service_queue, + GUINT_TO_POINTER(tid), __request_compare); + if (!list) + return false; + + req = list->data; + + g_queue_delete_link(device->service_queue, list); + } + + data = req->user_data; + + if (data->destroy) + data->destroy(data->user_data); + + __request_free(req, NULL); + + return true; +} + uint16_t qmi_service_register(struct qmi_service *service, uint16_t message, qmi_result_func_t func, void *user_data, qmi_destroy_func_t destroy) diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index f42da7c0..1bf139cc 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -139,6 +139,8 @@ uint16_t qmi_service_send(struct qmi_service *service, uint16_t message, struct qmi_param *param, qmi_result_func_t func, void *user_data, qmi_destroy_func_t destroy); +bool qmi_service_cancel(struct qmi_service *service, uint16_t tid); + uint16_t qmi_service_register(struct qmi_service *service, uint16_t message, qmi_result_func_t func, void *user_data, qmi_destroy_func_t destroy); |