diff mbox series

[01/13] qmi: Introduce SERVICE_VERSION macro

Message ID 20240624193315.1164943-1-denkenz@gmail.com (mailing list archive)
State Superseded
Headers show
Series [01/13] qmi: Introduce SERVICE_VERSION macro | expand

Commit Message

Denis Kenzior June 24, 2024, 7:32 p.m. UTC
This will make it easier to compare service major.minor versions in a
more readable manner.
---
 drivers/qmimodem/qmi.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index e3a8b225140f..5f29c4384803 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -36,6 +36,9 @@ 
 	l_util_debug((debug)->func, (debug)->user_data, "%s:%i " fmt,	\
 			__func__, __LINE__, ## args)
 
+#define SERVICE_VERSION(major, minor)				\
+	(((major) << 16) | (minor))
+
 struct qmi_device;
 struct qmi_request;
 
@@ -1199,6 +1202,7 @@  static void qmux_discover_callback(struct qmi_request *req, uint16_t message,
 	const void *ptr;
 	uint16_t len;
 	unsigned int i;
+	uint32_t control_version = 0;
 
 	result_code = tlv_get(buffer, length, 0x02, &len);
 	if (!result_code)
@@ -1233,6 +1237,7 @@  static void qmux_discover_callback(struct qmi_request *req, uint16_t message,
 		if (type == QMI_SERVICE_CONTROL) {
 			qmux->control_major = major;
 			qmux->control_minor = minor;
+			control_version = SERVICE_VERSION(major, minor);
 			continue;
 		}
 
@@ -1257,8 +1262,7 @@  done:
 	 * invoke it to reset the state, including release all previously
 	 * allocated clients
 	 */
-	if ((qmux->control_major == 1 && qmux->control_minor >= 5) ||
-			qmux->control_major > 1) {
+	if (control_version >= SERVICE_VERSION(1, 5)) {
 		struct qmi_request *req =
 			__control_request_alloc(QMI_CTL_SYNC, NULL, 0, 0);