diff mbox series

[v2,3/6] qmimodem: Use l_idle for shutdown instead of g_timeout

Message ID 20240221221725.185480-3-steve.schrock@getcruise.com (mailing list archive)
State Accepted
Commit 4947c7980add2dffaf0f43e622fae609362b3bbb
Headers show
Series [v2,1/6] qmimodem: Use l_queue_remove_if to eliminate double lookup | expand

Commit Message

Steve Schrock Feb. 21, 2024, 10:17 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 6880dc45..1e127d60 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 {
@@ -1551,24 +1551,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;
 
@@ -1577,7 +1577,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,
@@ -1588,15 +1588,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;
@@ -1611,8 +1611,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);