aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Schrock <steve.schrock@getcruise.com>2024-02-21 22:17:20 +0000
committerDenis Kenzior <denkenz@gmail.com>2024-02-21 16:22:06 -0600
commit1efef179f0880893f38af975b7ce4da602f9ff05 (patch)
treed0f030580af9600273b880cb4303eb56061e3203
parent2cfc037e723b1ca0e3137b1b296a75d20474bc82 (diff)
downloadofono-1efef179f0880893f38af975b7ce4da602f9ff05.tar.gz
qmimodem: Use l_queue_remove_if to eliminate double lookup
-rw-r--r--drivers/qmimodem/qmi.c50
1 files changed, 19 insertions, 31 deletions
diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index a2f5902fc..d2d4eefaa 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -793,12 +793,9 @@ static void handle_packet(struct qmi_device *device,
return;
}
- req = l_queue_find(device->control_queue, __request_compare,
- GUINT_TO_POINTER(tid));
- if (!req)
- return;
-
- l_queue_remove(device->control_queue, req);
+ req = l_queue_remove_if(device->control_queue,
+ __request_compare,
+ GUINT_TO_POINTER(tid));
} else {
const struct qmi_service_hdr *service = buf;
const struct qmi_message_hdr *msg;
@@ -819,14 +816,14 @@ static void handle_packet(struct qmi_device *device,
return;
}
- req = l_queue_find(device->service_queue, __request_compare,
- GUINT_TO_POINTER(tid));
- if (!req)
- return;
-
- l_queue_remove(device->service_queue, req);
+ req = l_queue_remove_if(device->service_queue,
+ __request_compare,
+ GUINT_TO_POINTER(tid));
}
+ if (!req)
+ return;
+
if (req->callback)
req->callback(message, length, data, req->user_data);
@@ -1244,19 +1241,13 @@ static struct qmi_request *find_control_request(struct qmi_device *device,
unsigned int _tid = tid;
if (_tid != 0) {
- req = l_queue_find(device->req_queue, __request_compare,
- GUINT_TO_POINTER(_tid));
-
- if (req)
- l_queue_remove(device->req_queue, req);
- else {
- req = l_queue_find(device->control_queue,
- __request_compare,
+ req = l_queue_remove_if(device->req_queue, __request_compare,
GUINT_TO_POINTER(_tid));
- if (req)
- l_queue_remove(device->control_queue, req);
- }
+ if (!req)
+ req = l_queue_remove_if(device->control_queue,
+ __request_compare,
+ GUINT_TO_POINTER(_tid));
}
return req;
@@ -2375,17 +2366,14 @@ bool qmi_service_cancel(struct qmi_service *service, uint16_t id)
if (!device)
return false;
- req = l_queue_find(device->req_queue, __request_compare,
- GUINT_TO_POINTER(tid));
- if (req)
- l_queue_remove(device->req_queue, req);
- else {
- req = l_queue_find(device->service_queue, __request_compare,
+ req = l_queue_remove_if(device->req_queue, __request_compare,
GUINT_TO_POINTER(tid));
+ if (!req) {
+ req = l_queue_remove_if(device->service_queue,
+ __request_compare,
+ GUINT_TO_POINTER(tid));
if (!req)
return false;
-
- l_queue_remove(device->service_queue, req);
}
service_send_free(req->user_data);