diff mbox series

[1/2] uqmi: improve response detection

Message ID 20231205101238.1770995-1-jean.thomas@wifirst.fr
State Accepted
Delegated to: Daniel Golle
Headers show
Series [1/2] uqmi: improve response detection | expand

Commit Message

Jean Thomas Dec. 5, 2023, 10:12 a.m. UTC
Create a helper which checks the flags depending on the service
indicated in the received message, as the response flag is not the same
for the CTL service and the other services. This avoids considering
a CTL indication as a valid response.

Also use a mask in order to check the flags, as they are a bitmap.

Signed-off-by: Jean Thomas <jean.thomas@wifirst.fr>
---
 dev.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/dev.c b/dev.c
index bd10207..2d1597c 100644
--- a/dev.c
+++ b/dev.c
@@ -62,6 +62,20 @@  qmi_get_service_idx(QmiService svc)
 	return -1;
 }
 
+static bool qmi_message_is_response(struct qmi_msg *msg)
+{
+	if (msg->qmux.service == QMI_SERVICE_CTL) {
+		if (msg->flags & QMI_CTL_FLAG_RESPONSE)
+			return true;
+	}
+	else {
+		if (msg->flags & QMI_SERVICE_FLAG_RESPONSE)
+			return true;
+	}
+
+	return false;
+}
+
 static void __qmi_request_complete(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
 {
 	void *tlv_buf;
@@ -96,7 +110,7 @@  static void qmi_process_msg(struct qmi_dev *qmi, struct qmi_msg *msg)
 	struct qmi_request *req;
 	uint16_t tid;
 
-	if (msg->flags != QMI_CTL_FLAG_RESPONSE && msg->flags != QMI_SERVICE_FLAG_RESPONSE)
+	if (!qmi_message_is_response(msg))
 		return;
 
 	if (msg->qmux.service == QMI_SERVICE_CTL)