diff mbox series

[20/27] qmi: split qmi_device_has_service into QRTR and QMUX version

Message ID 20240614185300.1086701-20-denkenz@gmail.com (mailing list archive)
State Superseded
Headers show
Series [01/27] qmi: Remove qmi_free() | expand

Commit Message

Denis Kenzior June 14, 2024, 6:52 p.m. UTC
---
 drivers/qmimodem/qmi.c | 13 ++++++++++++-
 drivers/qmimodem/qmi.h |  4 ++--
 plugins/gobi.c         | 14 +++++++-------
 plugins/qrtrqmi.c      | 10 +++++-----
 4 files changed, 26 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index f1b2247b4178..f4d32bd702b1 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -988,8 +988,11 @@  bool qmi_qmux_device_get_service_version(struct qmi_device *device,
 	return true;
 }
 
-bool qmi_device_has_service(struct qmi_device *device, uint16_t type)
+bool qmi_qmux_device_has_service(struct qmi_device *device, uint16_t type)
 {
+	if (!device)
+		return false;
+
 	return __find_service_info_by_type(device, type);
 }
 
@@ -2266,6 +2269,14 @@  done:
 	return service_create(family);
 }
 
+bool qmi_qrtr_node_has_service(struct qmi_device *device, uint16_t type)
+{
+	if (!device)
+		return false;
+
+	return __find_service_info_by_type(device, type);
+}
+
 struct qmi_param *qmi_param_new(void)
 {
 	return l_new(struct qmi_param, 1);
diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h
index 68d5cca6d9d2..b255d9b83a3e 100644
--- a/drivers/qmimodem/qmi.h
+++ b/drivers/qmimodem/qmi.h
@@ -81,6 +81,7 @@  bool qmi_qmux_device_create_client(struct qmi_device *device,
 bool qmi_qmux_device_get_service_version(struct qmi_device *device,
 					uint16_t type,
 					uint16_t *major, uint16_t *minor);
+bool qmi_qmux_device_has_service(struct qmi_device *device, uint16_t type);
 
 void qmi_device_set_debug(struct qmi_device *device,
 				qmi_debug_func_t func, void *user_data);
@@ -90,8 +91,6 @@  int qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func,
 int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func,
 				void *user_data, qmi_destroy_func_t destroy);
 
-bool qmi_device_has_service(struct qmi_device *device, uint16_t type);
-
 enum qmi_device_expected_data_format qmi_device_get_expected_data_format(
 						struct qmi_device *device);
 bool qmi_device_set_expected_data_format(struct qmi_device *device,
@@ -104,6 +103,7 @@  int qmi_qrtr_node_lookup(struct qmi_device *device,
 			void *user_data, qmi_destroy_func_t destroy);
 struct qmi_service *qmi_qrtr_node_get_service(struct qmi_device *device,
 						uint32_t type);
+bool qmi_qrtr_node_has_service(struct qmi_device *device, uint16_t type);
 
 struct qmi_param;
 
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 49d3ae2d304e..bb972977ce0a 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -446,19 +446,19 @@  static void discover_cb(void *user_data)
 
 	DBG("");
 
-	if (qmi_device_has_service(data->device, QMI_SERVICE_DMS))
+	if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_DMS))
 		data->features |= GOBI_DMS;
-	if (qmi_device_has_service(data->device, QMI_SERVICE_NAS))
+	if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_NAS))
 		data->features |= GOBI_NAS;
-	if (qmi_device_has_service(data->device, QMI_SERVICE_WDS))
+	if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_WDS))
 		data->features |= GOBI_WDS;
-	if (qmi_device_has_service(data->device, QMI_SERVICE_WDA))
+	if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_WDA))
 		data->features |= GOBI_WDA;
-	if (qmi_device_has_service(data->device, QMI_SERVICE_PDS))
+	if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_PDS))
 		data->features |= GOBI_PDS;
-	if (qmi_device_has_service(data->device, QMI_SERVICE_UIM))
+	if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_UIM))
 		data->features |= GOBI_UIM;
-	if (qmi_device_has_service(data->device, QMI_SERVICE_VOICE))
+	if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_VOICE))
 			data->features |= GOBI_VOICE;
 
 	if (qmi_qmux_device_get_service_version(data->device, QMI_SERVICE_WMS,
diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c
index 6765f0644e98..d3aee5f4f4ff 100644
--- a/plugins/qrtrqmi.c
+++ b/plugins/qrtrqmi.c
@@ -184,10 +184,10 @@  static void lookup_done(void *user_data)
 
 	DBG("");
 
-	if (!qmi_device_has_service(node, QMI_SERVICE_DMS) ||
-			!qmi_device_has_service(node, QMI_SERVICE_UIM) ||
-			!qmi_device_has_service(node, QMI_SERVICE_WDS) ||
-			!qmi_device_has_service(node, QMI_SERVICE_NAS))
+	if (!qmi_qrtr_node_has_service(node, QMI_SERVICE_DMS) ||
+			!qmi_qrtr_node_has_service(node, QMI_SERVICE_UIM) ||
+			!qmi_qrtr_node_has_service(node, QMI_SERVICE_WDS) ||
+			!qmi_qrtr_node_has_service(node, QMI_SERVICE_NAS))
 		goto error;
 
 	data->dms = qmi_qrtr_node_get_service(node, QMI_SERVICE_DMS);
@@ -323,7 +323,7 @@  static void qrtrqmi_post_sim(struct ofono_modem *modem)
 
 		ofono_sms_create(modem, 0, "qmimodem", wms);
 
-		if (qmi_device_has_service(node, QMI_SERVICE_UIM))
+		if (qmi_qrtr_node_has_service(node, QMI_SERVICE_UIM))
 			mw = ofono_message_waiting_create(modem);
 
 		if (mw)