diff mbox series

[v2,1/4] qmi: Create a method to find a service by type

Message ID 20240229153151.36410-1-steve.schrock@getcruise.com (mailing list archive)
State Accepted
Commit fa411b89f282f93da6b75f6f5d824d286e897414
Headers show
Series [v2,1/4] qmi: Create a method to find a service by type | expand

Commit Message

Steve Schrock Feb. 29, 2024, 3:31 p.m. UTC
---
 drivers/qmimodem/qmi.c | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

Comments

patchwork-bot+ofono@kernel.org Feb. 29, 2024, 4:40 p.m. UTC | #1
Hello:

This series was applied to ofono.git (master)
by Denis Kenzior <denkenz@gmail.com>:

On Thu, 29 Feb 2024 09:31:38 -0600 you wrote:
> ---
>  drivers/qmimodem/qmi.c | 41 ++++++++++++++++++++++-------------------
>  1 file changed, 22 insertions(+), 19 deletions(-)

Here is the summary with links:
  - [v2,1/4] qmi: Create a method to find a service by type
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=fa411b89f282
  - [v2,2/4] qmi: Add more service info to qmi_service
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=8cdc1511f519
  - [v2,3/4] qmi: Allow for 16-bit service types in the type hash
    (no matching commit)
  - [v2,4/4] qmi: Enable basic client creation if it is not subclassed
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=03160ab1fc34

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index ffb26326..d65a1c15 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -953,39 +953,42 @@  static const void *tlv_get(const void *data, uint16_t size,
 	return NULL;
 }
 
-bool qmi_device_get_service_version(struct qmi_device *device, uint16_t type,
-					uint16_t *major, uint16_t *minor)
+static const struct qmi_service_info *__find_service_info_by_type(
+				struct qmi_device *device, uint16_t type)
 {
+	const struct qmi_service_info *info = NULL;
 	const struct l_queue_entry *entry;
 
 	for (entry = l_queue_get_entries(device->service_infos);
 						entry; entry = entry->next) {
-		const struct qmi_service_info *info = entry->data;
-
-		if (info->service_type != type)
-			continue;
+		struct qmi_service_info *data = entry->data;
 
-		*major = info->major;
-		*minor = info->minor;
-		return true;
+		if (data->service_type == type) {
+			info = data;
+			break;
+		}
 	}
 
-	return false;
+	return info;
 }
 
-bool qmi_device_has_service(struct qmi_device *device, uint16_t type)
+bool qmi_device_get_service_version(struct qmi_device *device, uint16_t type,
+					uint16_t *major, uint16_t *minor)
 {
-	const struct l_queue_entry *entry;
+	const struct qmi_service_info *info;
 
-	for (entry = l_queue_get_entries(device->service_infos);
-						entry; entry = entry->next) {
-		const struct qmi_service_info *info = entry->data;
+	info = __find_service_info_by_type(device, type);
+	if (!info)
+		return false;
 
-		if (info->service_type == type)
-			return true;
-	}
+	*major = info->major;
+	*minor = info->minor;
+	return true;
+}
 
-	return false;
+bool qmi_device_has_service(struct qmi_device *device, uint16_t type)
+{
+	return __find_service_info_by_type(device, type);
 }
 
 struct discover_data {