@@ -953,39 +953,44 @@ 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;
+ info = entry->data;
- *major = info->major;
- *minor = info->minor;
- return true;
+ if (info->service_type == type)
+ 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)
+{
+ const struct qmi_service_info *info;
+
+ info = __find_service_info_by_type(device, type);
+
+ return info != NULL;
}
struct discover_data {