diff mbox series

[3/7] qmimodem: Use l_idle for shutdown instead of g_timeout

Message ID 20240221212212.181401-3-steve.schrock@getcruise.com (mailing list archive)
State Superseded
Headers show
Series [1/7] qmimodem: Use l_queue_remove_if to eliminate double lookup | expand

Commit Message

Steve Schrock Feb. 21, 2024, 9:22 p.m. UTC
---
 drivers/qmimodem/qmi.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index 5694b927..eed69178 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -93,7 +93,7 @@  struct qmi_device_qmux {
 	qmi_shutdown_func_t shutdown_func;
 	void *shutdown_user_data;
 	qmi_destroy_func_t shutdown_destroy;
-	guint shutdown_source;
+	struct l_idle *shutdown_idle;
 };
 
 struct qmi_service {
@@ -1529,24 +1529,24 @@  done:
 	return res;
 }
 
-static void qmux_shutdown_destroy(gpointer user_data)
+static void qmux_shutdown_destroy(void *user_data)
 {
 	struct qmi_device_qmux *qmux = user_data;
 
 	if (qmux->shutdown_destroy)
 		qmux->shutdown_destroy(qmux->shutdown_user_data);
 
-	qmux->shutdown_source = 0;
+	qmux->shutdown_idle = NULL;
 
 	__qmi_device_shutdown_finished(&qmux->super);
 }
 
-static gboolean qmux_shutdown_callback(gpointer user_data)
+static void qmux_shutdown_callback(struct l_idle *idle, void *user_data)
 {
 	struct qmi_device_qmux *qmux = user_data;
 
 	if (qmux->super.release_users > 0)
-		return TRUE;
+		return;
 
 	qmux->super.shutting_down = true;
 
@@ -1555,7 +1555,7 @@  static gboolean qmux_shutdown_callback(gpointer user_data)
 
 	qmux->super.shutting_down = false;
 
-	return FALSE;
+	l_idle_remove(qmux->shutdown_idle);
 }
 
 static int qmi_device_qmux_shutdown(struct qmi_device *device,
@@ -1566,15 +1566,15 @@  static int qmi_device_qmux_shutdown(struct qmi_device *device,
 	struct qmi_device_qmux *qmux =
 		l_container_of(device, struct qmi_device_qmux, super);
 
-	if (qmux->shutdown_source > 0)
+	if (qmux->shutdown_idle)
 		return -EALREADY;
 
 	__debug_device(&qmux->super, "device %p shutdown", &qmux->super);
 
-	qmux->shutdown_source = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT,
-						0, qmux_shutdown_callback,
-						qmux, qmux_shutdown_destroy);
-	if (qmux->shutdown_source == 0)
+	qmux->shutdown_idle = l_idle_create(qmux_shutdown_callback, qmux,
+						qmux_shutdown_destroy);
+
+	if (!qmux->shutdown_idle)
 		return -EIO;
 
 	qmux->shutdown_func = func;
@@ -1589,8 +1589,8 @@  static void qmi_device_qmux_destroy(struct qmi_device *device)
 	struct qmi_device_qmux *qmux =
 		l_container_of(device, struct qmi_device_qmux, super);
 
-	if (qmux->shutdown_source)
-		g_source_remove(qmux->shutdown_source);
+	if (qmux->shutdown_idle)
+		l_idle_remove(qmux->shutdown_idle);
 
 	l_free(qmux->version_str);
 	l_free(qmux);