diff mbox series

[v2,1/7] qmi: Remove qmi_device_sync

Message ID 20240221162335.1258315-1-denkenz@gmail.com (mailing list archive)
State Accepted
Headers show
Series [v2,1/7] qmi: Remove qmi_device_sync | expand

Commit Message

Denis Kenzior Feb. 21, 2024, 4:23 p.m. UTC
This is an implementation detail of the QMUX/CTL interface.  Since the
only caller always invokes SYNC after discovery if supported, simplify
the SYNC operation to be part of the discovery procedure and remove the
relevant APIs from qmi_device.
---
 drivers/qmimodem/qmi.c | 89 +++++++++++++++++-------------------------
 drivers/qmimodem/qmi.h |  5 ---
 plugins/gobi.c         | 10 ++---
 3 files changed, 39 insertions(+), 65 deletions(-)

Comments

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

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

On Wed, 21 Feb 2024 10:23:14 -0600 you wrote:
> This is an implementation detail of the QMUX/CTL interface.  Since the
> only caller always invokes SYNC after discovery if supported, simplify
> the SYNC operation to be part of the discovery procedure and remove the
> relevant APIs from qmi_device.
> ---
>  drivers/qmimodem/qmi.c | 89 +++++++++++++++++-------------------------
>  drivers/qmimodem/qmi.h |  5 ---
>  plugins/gobi.c         | 10 ++---
>  3 files changed, 39 insertions(+), 65 deletions(-)

Here is the summary with links:
  - [v2,1/7] qmi: Remove qmi_device_sync
    (no matching commit)
  - [v2,2/7] qmi: Introduce qmi_device_new_qmux
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=7cf914bdd495
  - [v2,3/7] qmi: Remove qmi_device_set_close_on_unref
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=63420ccbefb4
  - [v2,4/7] qmi: Move control_{major|minor} to qmux sublcass
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=0382434d8879
  - [v2,5/7] qmi: Move version_str to qmux subclass
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=6cb6953abbe3
  - [v2,6/7] qmi: Introduce shutdown operation
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=34d0183a9ff7
  - [v2,7/7] gobi: Fail if device could not be created
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=2cfc037e723b

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index 30c396035593..768fcf12f1eb 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -1038,7 +1038,6 @@  void qmi_result_print_tlvs(struct qmi_result *result)
 	}
 }
 
-
 static const void *tlv_get(const void *data, uint16_t size,
 					uint8_t type, uint16_t *length)
 {
@@ -1122,6 +1121,35 @@  static void discover_data_free(gpointer user_data)
 	l_free(data);
 }
 
+static void qmi_device_sync_callback(uint16_t message, uint16_t length,
+					const void *buffer, void *user_data)
+{
+	struct discover_data *data = user_data;
+
+	if (data->func)
+		data->func(data->user_data);
+
+	__qmi_device_discovery_complete(data->device, &data->super);
+}
+
+/* sync will release all previous clients */
+static bool qmi_device_sync(struct qmi_device *device,
+				struct discover_data *data)
+{
+	struct qmi_request *req;
+
+	__debug_device(device, "Sending sync to reset QMI");
+
+	req = __request_alloc(QMI_SERVICE_CONTROL, 0x00,
+				QMI_CTL_SYNC, NULL, 0,
+				qmi_device_sync_callback, data);
+
+	__request_submit(device, req);
+
+	return true;
+}
+
+
 static void discover_callback(uint16_t message, uint16_t length,
 					const void *buffer, void *user_data)
 {
@@ -1193,6 +1221,13 @@  done:
 	device->version_list = list;
 	device->version_count = count;
 
+	/* if the device support the QMI call SYNC over the CTL interface */
+	if ((device->control_major == 1 && device->control_minor >= 5) ||
+			device->control_major > 1) {
+		qmi_device_sync(data->device, data);
+		return;
+	}
+
 	if (data->func)
 		data->func(data->user_data);
 
@@ -1352,58 +1387,6 @@  bool qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func,
 	return true;
 }
 
-struct sync_data {
-	qmi_sync_func_t func;
-	void *user_data;
-};
-
-static void qmi_device_sync_callback(uint16_t message, uint16_t length,
-				     const void *buffer, void *user_data)
-{
-	struct sync_data *data = user_data;
-
-	if (data->func)
-		data->func(data->user_data);
-
-	l_free(data);
-}
-
-/* sync will release all previous clients */
-bool qmi_device_sync(struct qmi_device *device,
-		     qmi_sync_func_t func, void *user_data)
-{
-	struct qmi_request *req;
-	struct sync_data *func_data;
-
-	if (!device)
-		return false;
-
-	__debug_device(device, "Sending sync to reset QMI");
-
-	func_data = l_new(struct sync_data, 1);
-	func_data->func = func;
-	func_data->user_data = user_data;
-
-	req = __request_alloc(QMI_SERVICE_CONTROL, 0x00,
-			QMI_CTL_SYNC,
-			NULL, 0,
-			qmi_device_sync_callback, func_data);
-
-	__request_submit(device, req);
-
-	return true;
-}
-
-/* if the device support the QMI call SYNC over the CTL interface */
-bool qmi_device_is_sync_supported(struct qmi_device *device)
-{
-	if (device == NULL)
-		return false;
-
-	return (device->control_major > 1 ||
-		(device->control_major == 1 && device->control_minor >= 5));
-}
-
 static bool get_device_file_name(struct qmi_device *device,
 					char *file_name, int size)
 {
diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h
index 21537a76c64e..fc2a309578c4 100644
--- a/drivers/qmimodem/qmi.h
+++ b/drivers/qmimodem/qmi.h
@@ -78,7 +78,6 @@  typedef void (*qmi_destroy_func_t)(void *user_data);
 struct qmi_device;
 
 typedef void (*qmi_debug_func_t)(const char *str, void *user_data);
-typedef void (*qmi_sync_func_t)(void *user_data);
 typedef void (*qmi_shutdown_func_t)(void *user_data);
 typedef void (*qmi_discover_func_t)(void *user_data);
 
@@ -101,10 +100,6 @@  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);
 
-bool qmi_device_sync(struct qmi_device *device,
-		     qmi_sync_func_t func, void *user_data);
-bool qmi_device_is_sync_supported(struct qmi_device *device);
-
 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,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 76c9d68d2df5..020d6ba2685e 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -364,13 +364,12 @@  error:
 	shutdown_device(modem);
 }
 
-static void create_shared_dms(void *user_data)
+static void create_shared_dms(struct ofono_modem *modem)
 {
-	struct ofono_modem *modem = user_data;
 	struct gobi_data *data = ofono_modem_get_data(modem);
 
 	qmi_service_create_shared(data->device, QMI_SERVICE_DMS,
-				  create_dms_cb, modem, NULL);
+						create_dms_cb, modem, NULL);
 }
 
 static void discover_cb(void *user_data)
@@ -417,10 +416,7 @@  static void discover_cb(void *user_data)
 		return;
 	}
 
-	if (qmi_device_is_sync_supported(data->device))
-		qmi_device_sync(data->device, create_shared_dms, modem);
-	else
-		create_shared_dms(modem);
+	create_shared_dms(modem);
 }
 
 static int gobi_enable(struct ofono_modem *modem)