diff mbox series

[3/4] qmimodem: Fail early if discovery already complete

Message ID 20240222201559.1293947-3-denkenz@gmail.com (mailing list archive)
State Accepted
Commit 365293bf04514959b258fef37e34a5c0200788b1
Headers show
Series [1/4] qmi: Introduce discover() driver method | expand

Commit Message

Denis Kenzior Feb. 22, 2024, 8:15 p.m. UTC
If discovery has been completed successfully, tell the caller right away
by returning a -EALREADY return code instead of scheduling for the
discover callback to be invoked via the idle callback.  Such logic has
no real effect as the underlying CTL service is not queried again.
---
 drivers/qmimodem/qmi.c | 27 +++------------------------
 1 file changed, 3 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index 2a6e79efeed2..268db1f76cc5 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -1095,7 +1095,6 @@  struct discover_data {
 	qmi_destroy_func_t destroy;
 	uint16_t tid;
 	struct l_timeout *timeout;
-	struct l_idle *idle;
 };
 
 static void discover_data_free(void *user_data)
@@ -1105,9 +1104,6 @@  static void discover_data_free(void *user_data)
 	if (data->timeout)
 		l_timeout_remove(data->timeout);
 
-	if (data->idle)
-		l_idle_remove(data->idle);
-
 	if (data->destroy)
 		data->destroy(data->user_data);
 
@@ -1524,20 +1520,6 @@  done:
 	__qmi_device_discovery_complete(data->device, &data->super);
 }
 
-static void qmux_discover_reply_idle(struct l_idle *idle, void *user_data)
-{
-	struct discover_data *data = user_data;
-	struct qmi_device *device = data->device;
-
-	l_idle_remove(data->idle);
-	data->idle = NULL;
-
-	if (data->func)
-		data->func(data->user_data);
-
-	__qmi_device_discovery_complete(device, &data->super);
-}
-
 static void qmux_discover_reply_timeout(struct l_timeout *timeout,
 							void *user_data)
 {
@@ -1570,6 +1552,9 @@  static int qmi_device_qmux_discover(struct qmi_device *device,
 
 	__debug_device(device, "device %p discover", device);
 
+	if (device->version_list)
+		return -EALREADY;
+
 	data = l_new(struct discover_data, 1);
 
 	data->super.destroy = discover_data_free;
@@ -1578,12 +1563,6 @@  static int qmi_device_qmux_discover(struct qmi_device *device,
 	data->user_data = user_data;
 	data->destroy = destroy;
 
-	if (device->version_list) {
-		data->idle = l_idle_create(qmux_discover_reply_idle, data, NULL);
-		__qmi_device_discovery_started(device, &data->super);
-		return 0;
-	}
-
 	req = __request_alloc(QMI_SERVICE_CONTROL, 0x00,
 			QMI_CTL_GET_VERSION_INFO,
 			NULL, 0, qmux_discover_callback, data);