Skip to contentSkip to conversation

qmi/discovery: remove useless code

PATCH In review Alexander Couzens 2 participants 5 messages Dec 5, 2017 – Dec 6, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 qmi/discovery: remove useless code

---
 drivers/qmimodem/qmi.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/qmimodem/qmi.c +0 -7
index a0632ca54025..5b29b761686a 100644
@@ -1161,13 +1161,6 @@ static void discover_callback(uint16_t message, uint16_t length,
 
 	device->version_str = strndup(ptr + 1, *((uint8_t *) ptr));
 
-	service_list = ptr + *((uint8_t *) ptr) + 1;
-
-	for (i = 0; i < service_list->count; i++) {
-		if (service_list->services[i].type == QMI_SERVICE_CONTROL)
-			continue;
-	}
-
 done:
 	device->version_list = list;
 	device->version_count = count;
Signature · 1 line
2.15.1
#1 lore raw

PATCH v2 2/4 qmi: include the CTL in the debug output

The CTL version is important for certain calls. This is a useful information for debugging.

---
 drivers/qmimodem/qmi.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/qmimodem/qmi.c +7 -7
index 5b29b761686a..0269f7729be0 100644
@@ -1134,6 +1134,13 @@ static void discover_callback(uint16_t message, uint16_t length,
 		uint8_t type = service_list->services[i].type;
 		const char *name = __service_type_to_string(type);
 
+		if (name)
+			__debug_device(device, "found service [%s %d.%d]",
+				       name, major, minor);
+		else
+			__debug_device(device, "found service [%d %d.%d]",
+				       type, major, minor);
+
 		if (type == QMI_SERVICE_CONTROL) {
 			device->control_major = major;
 			device->control_minor = minor;
@@ -1146,13 +1153,6 @@ static void discover_callback(uint16_t message, uint16_t length,
 		list[count].name = name;
 
 		count++;
-
-		if (name)
-			__debug_device(device, "found service [%s %d.%d]",
-							name, major, minor);
-		else
-			__debug_device(device, "found service [%d %d.%d]",
-							type, major, minor);
 	}
 
 	ptr = tlv_get(buffer, length, 0x10, &len);
Signature · 1 line
2.15.1
#2 lore raw

PATCH v2 3/4 qmi: implement the control sync command

In reply to Alexander Couzens

The sync command resets the QMI interface state. It will flushs all previous assigned sessions and transactions.

---
 drivers/qmimodem/qmi.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/qmimodem/qmi.h |  6 ++++-
 2 files changed, 64 insertions(+), 1 deletion(-)
drivers/qmimodem/qmi.c +59 -0
index 0269f7729be0..8bb71b0513ed 100644
@@ -1342,6 +1342,65 @@ 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);
+
+	g_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 qmi_control_hdr *hdr;
+	struct sync_data *func_data;
+
+	if (!device)
+		return false;
+
+	__debug_device(device, "Sending sync to reset QMI");
+
+	func_data = g_new0(struct sync_data, 1);
+	func_data->func = func;
+	func_data->user_data = user_data;
+
+	req = __request_alloc(QMI_SERVICE_CONTROL, 0x00,
+			QMI_CTL_SYNC, QMI_CONTROL_HDR_SIZE,
+			NULL, 0,
+			qmi_device_sync_callback, func_data, (void **) &hdr);
+
+	if (device->next_control_tid < 1)
+		device->next_control_tid = 1;
+
+	hdr->type = 0x00;
+	hdr->transaction = device->next_control_tid++;
+
+	__request_submit(device, req, hdr->transaction);
+
+	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)
 {
drivers/qmimodem/qmi.h +5 -1
index b4955b40b1fb..40d398229af8 100644
@@ -76,7 +76,7 @@ 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)(uint8_t count,
 			const struct qmi_version *list, void *user_data);
@@ -96,6 +96,10 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func,
 bool qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func,
 				void *user_data, qmi_destroy_func_t destroy);
 
+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,
Signature · 1 line
2.15.1
#3 lore raw

PATCH v2 4/4 plugins/gobi: reset the qmi interface when enabling the modem

In reply to Alexander Couzens
---
 plugins/gobi.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
plugins/gobi.c +13 -2
index 516b55e9411d..17900010d1db 100644
@@ -254,6 +254,15 @@ error:
 	shutdown_device(modem);
 }
 
+static void create_shared_dms(void *user_data)
+{
+	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);
+}
+
 static void discover_cb(uint8_t count, const struct qmi_version *list,
 							void *user_data)
 {
@@ -316,8 +325,10 @@ static void discover_cb(uint8_t count, const struct qmi_version *list,
 		return;
 	}
 
-	qmi_service_create_shared(data->device, QMI_SERVICE_DMS,
-						create_dms_cb, modem, NULL);
+	if (qmi_device_is_sync_supported(data->device))
+		qmi_device_sync(data->device, create_shared_dms, modem);
+	else
+		create_shared_dms(modem);
 }
 
 static int gobi_enable(struct ofono_modem *modem)
Signature · 1 line
2.15.1