($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: Steve Schrock <steve.schrock@getcruise.com>
To: ofono@lists.linux.dev
Cc: Steve Schrock <steve.schrock@getcruise.com>
Subject: [PATCH v2 1/6] qmimodem: Use l_queue_remove_if to eliminate double lookup
Date: Wed, 21 Feb 2024 22:17:20 +0000	[thread overview]
Message-ID: <20240221221725.185480-1-steve.schrock@getcruise.com> (raw)

---
 drivers/qmimodem/qmi.c | 50 ++++++++++++++++--------------------------
 1 file changed, 19 insertions(+), 31 deletions(-)

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index a2f5902f..d2d4eefa 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);
-- 
2.40.1


-- 


*Confidentiality Note:* We care about protecting our proprietary 
information, confidential material, and trade secrets. This message may 
contain some or all of those things. Cruise will suffer material harm if 
anyone other than the intended recipient disseminates or takes any action 
based on this message. If you have received this message (including any 
attachments) in error, please delete it immediately and notify the sender 
promptly.

             reply	other threads:[~2024-02-21 22:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 22:17 Steve Schrock [this message]
2024-02-21 22:17 ` [PATCH v2 2/6] qmimodem: Use l_timeout and l_idle for discovery Steve Schrock
2024-02-21 22:17 ` [PATCH v2 3/6] qmimodem: Use l_idle for shutdown instead of g_timeout Steve Schrock
2024-02-21 22:17 ` [PATCH v2 4/6] qmimodem: Use l_idle and l_timeout for service creation Steve Schrock
2024-02-21 22:17 ` [PATCH v2 5/6] qmimodem: Eliminate glib macros Steve Schrock
2024-02-21 22:17 ` [PATCH v2 6/6] qmimodem: Use l_free in qmi_free for consistency Steve Schrock
2024-02-21 23:00 ` [PATCH v2 1/6] qmimodem: Use l_queue_remove_if to eliminate double lookup patchwork-bot+ofono

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240221221725.185480-1-steve.schrock@getcruise.com \
    --to=steve.schrock@getcruise.com \
    --cc=ofono@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).