diff mbox series

[5/7] qmi: Move version_str to qmux subclass

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

Commit Message

Denis Kenzior Feb. 20, 2024, 10:40 p.m. UTC
The version_str member is only available on QMUX based devices, and only
on certain ones.  Move this member out to the qmux subclass and add a
debug statement to print it out if available.
---
 drivers/qmimodem/qmi.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index dae540251118..47a9bbe2cb59 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -73,7 +73,6 @@  struct qmi_device {
 	uint16_t next_service_tid;
 	qmi_debug_func_t debug_func;
 	void *debug_data;
-	char *version_str;
 	struct qmi_version *version_list;
 	uint8_t version_count;
 	GHashTable *service_list;
@@ -91,6 +90,7 @@  struct qmi_device_qmux {
 	struct qmi_device super;
 	uint16_t control_major;
 	uint16_t control_minor;
+	char *version_str;
 };
 
 struct qmi_service {
@@ -1052,7 +1052,6 @@  void qmi_device_unref(struct qmi_device *device)
 
 	g_hash_table_destroy(device->service_list);
 
-	g_free(device->version_str);
 	g_free(device->version_list);
 
 	if (device->shutting_down)
@@ -1269,7 +1268,8 @@  static void discover_callback(uint16_t message, uint16_t length,
 	if (!ptr)
 		goto done;
 
-	device->version_str = strndup(ptr + 1, *((uint8_t *) ptr));
+	qmux->version_str = l_strndup(ptr + 1, *((uint8_t *) ptr));
+	__debug_device(device, "version string: %s", qmux->version_str);
 
 done:
 	device->version_list = list;
@@ -1648,6 +1648,7 @@  static void qmi_device_qmux_destroy(struct qmi_device *device)
 	struct qmi_device_qmux *qmux =
 		l_container_of(device, struct qmi_device_qmux, super);
 
+	l_free(qmux->version_str);
 	l_free(qmux);
 }