aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2024-02-20 10:02:42 -0600
committerDenis Kenzior <denkenz@gmail.com>2024-02-21 10:28:19 -0600
commit9e8452edbc614a838997d1d8506ac2693aed1797 (patch)
tree9040d5688e9d9346acf4b49aad574f2cfdeb6bd1
parent2ea7f60e15306d0d320beabe3e876308583cdd74 (diff)
downloadofono-9e8452edbc614a838997d1d8506ac2693aed1797.tar.gz
qmi: Remove qmi_device_sync
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.
-rw-r--r--drivers/qmimodem/qmi.c88
-rw-r--r--drivers/qmimodem/qmi.h5
-rw-r--r--plugins/gobi.c10
3 files changed, 38 insertions, 65 deletions
diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index 30c396035..72b55cd71 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,34 @@ 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 +1220,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 +1386,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 21537a76c..fc2a30957 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 76c9d68d2..020d6ba26 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)