diff options
author | Denis Kenzior <denkenz@gmail.com> | 2024-02-22 13:55:28 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2024-02-22 14:03:51 -0600 |
commit | 365293bf04514959b258fef37e34a5c0200788b1 (patch) | |
tree | e9607124b77804d72276e7e5d0c3357efb1eb961 | |
parent | ff521505001983c7f57ed925de921043dd7d998c (diff) | |
download | ofono-365293bf04514959b258fef37e34a5c0200788b1.tar.gz |
qmimodem: Fail early if discovery already complete
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.
-rw-r--r-- | drivers/qmimodem/qmi.c | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 2a6e79efe..268db1f76 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); |