diff mbox series

[v2,17/33] qmi: Rework qmi_service_get_version

Message ID 20240618200231.1129282-17-denkenz@gmail.com (mailing list archive)
State Superseded
Headers show
Series [v2,01/33] qmi: Remove qmi_free() | expand

Commit Message

Denis Kenzior June 18, 2024, 8:01 p.m. UTC
With the introduction of QRTR support, qmi_service_get_version became
somewhat confusing.  It still returns the minor version, however QRTR
does not have such a concept.  Additionally, QRTR is limited to 8 bit
service versions.  Rework qmi_service_get_version API to make this
clearer.  While here, add some documentation and update the unit test to
the new API.
---
 drivers/qmimodem/qmi.c   | 22 +++++++++++++++-------
 drivers/qmimodem/qmi.h   |  3 +--
 unit/test-qmimodem-qmi.c |  7 +++----
 3 files changed, 19 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index a56e5588c698..6d605d58ad65 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -2538,17 +2538,25 @@  const char *qmi_service_get_identifier(struct qmi_service *service)
 	return __service_type_to_string(service->family->info.service_type);
 }
 
-bool qmi_service_get_version(struct qmi_service *service,
-					uint16_t *major, uint16_t *minor)
+/**
+ * qmi_service_get_version:
+ * @service: lightweight service handle
+ * @out_version: version output
+ *
+ * Returns the version of the service this handle is currently referring to.
+ * On QMUX this corresponds to the 'major' version of the service.  On QRTR,
+ * this corresponds to the lower 8 bits of the 'instance' attribute and is thus
+ * limited to uint8_t.
+ *
+ * Returns: #false if the service handle is NULL, #true on success.
+ */
+bool qmi_service_get_version(struct qmi_service *service, uint8_t *out_version)
 {
 	if (!service)
 		return false;
 
-	if (major)
-		*major = service->family->info.major;
-
-	if (minor)
-		*minor = service->family->info.minor;
+	if (out_version)
+		*out_version = service->family->info.major;
 
 	return true;
 }
diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h
index da245e50ea50..4de9d7bd0037 100644
--- a/drivers/qmimodem/qmi.h
+++ b/drivers/qmimodem/qmi.h
@@ -142,8 +142,7 @@  struct qmi_service *qmi_service_clone(struct qmi_service *service);
 void qmi_service_free(struct qmi_service *service);
 
 const char *qmi_service_get_identifier(struct qmi_service *service);
-bool qmi_service_get_version(struct qmi_service *service,
-					uint16_t *major, uint16_t *minor);
+bool qmi_service_get_version(struct qmi_service *service, uint8_t *out_version);
 
 uint16_t qmi_service_send(struct qmi_service *service,
 				uint16_t message, struct qmi_param *param,
diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c
index c40e9bb1d8af..4ea9c736c284 100644
--- a/unit/test-qmimodem-qmi.c
+++ b/unit/test-qmimodem-qmi.c
@@ -232,15 +232,14 @@  static void test_create_services(const void *data)
 
 	for (i = 0; i < TEST_SERVICE_COUNT; i++) {
 		struct qmi_service *service;
-		uint16_t major, minor;
+		uint8_t version;
 
 		service_type = unique_service_type(i);
 		service = qmi_qrtr_node_get_service(info->node, service_type);
 		assert(service);
 
-		assert(qmi_service_get_version(service, &major, &minor));
-		assert(major == unique_service_version(i));
-		assert(minor == 0);
+		assert(qmi_service_get_version(service, &version));
+		assert(version == unique_service_version(i));
 
 		qmi_service_free(service);
 	}