Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Jan 2024 17:09:54 GMT
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 870bcb954ee3 - stable/13 - iichid(4): Unify two taskqueue tasks
Message-ID:  <202401191709.40JH9sCL079709@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=870bcb954ee3db3c6670949638883a4b6b7d362c

commit 870bcb954ee3db3c6670949638883a4b6b7d362c
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2023-12-27 00:28:56 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2024-01-19 17:08:14 +0000

    iichid(4): Unify two taskqueue tasks
    
    taskqueue_enqueue_timeout(0) is equivalent to taskqueue_enqueue(),
    so no need to create a separate periodic_task and event_task to run
    exactly the same handler.
    
    MFC after:      1 month
    
    (cherry picked from commit a8f80c0c16c7fb38c46ddccd7e1b06dc46c407b1)
---
 sys/dev/iicbus/iichid.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/sys/dev/iicbus/iichid.c b/sys/dev/iicbus/iichid.c
index 99ec402c3590..a0e11b8500b6 100644
--- a/sys/dev/iicbus/iichid.c
+++ b/sys/dev/iicbus/iichid.c
@@ -182,8 +182,7 @@ struct iichid_softc {
 	bool			callout_setup;		/* iicbus lock */
 	uint8_t			*dup_buf;
 	struct taskqueue	*taskqueue;
-	struct timeout_task	periodic_task;		/* iicbus lock */
-	struct task		event_task;
+	struct timeout_task	sampling_task;		/* iicbus lock */
 #endif
 
 	struct task		suspend_task;
@@ -520,7 +519,7 @@ iichid_cmd_set_report(struct iichid_softc* sc, const void *buf,
 
 #ifdef IICHID_SAMPLING
 static void
-iichid_event_task(void *context, int pending)
+iichid_sampling_task(void *context, int pending)
 {
 	struct iichid_softc *sc;
 	device_t parent;
@@ -566,7 +565,7 @@ rearm:
 			rate = sc->sampling_rate_slow;
 		else
 			rate = sc->sampling_rate_fast;
-		taskqueue_enqueue_timeout_sbt(sc->taskqueue, &sc->periodic_task,
+		taskqueue_enqueue_timeout_sbt(sc->taskqueue, &sc->sampling_task,
 		    SBT_1S / MAX(rate, 1), 0, C_PREL(2));
 	}
 out:
@@ -742,7 +741,7 @@ iichid_reset_callout(struct iichid_softc *sc)
 	sc->missing_samples = sc->sampling_hysteresis;
 	sc->dup_samples = 0;
 	sc->dup_size = 0;
-	taskqueue_enqueue(sc->taskqueue, &sc->event_task);
+	taskqueue_enqueue_timeout(sc->taskqueue, &sc->sampling_task, 0);
 
 	return (0);
 }
@@ -752,7 +751,7 @@ iichid_teardown_callout(struct iichid_softc *sc)
 {
 
 	sc->callout_setup = false;
-	taskqueue_cancel_timeout(sc->taskqueue, &sc->periodic_task, NULL);
+	taskqueue_cancel_timeout(sc->taskqueue, &sc->sampling_task, NULL);
 	DPRINTF(sc, "tore callout down\n");
 }
 
@@ -1130,12 +1129,10 @@ iichid_attach(device_t dev)
 
 	TASK_INIT(&sc->suspend_task, 0, iichid_suspend_task, sc);
 #ifdef IICHID_SAMPLING
-	TASK_INIT(&sc->event_task, 0, iichid_event_task, sc);
-	/* taskqueue_create can't fail with M_WAITOK mflag passed. */
 	sc->taskqueue = taskqueue_create("iichid_tq", M_WAITOK | M_ZERO,
 	    taskqueue_thread_enqueue, &sc->taskqueue);
-	TIMEOUT_TASK_INIT(sc->taskqueue, &sc->periodic_task, 0,
-	    iichid_event_task, sc);
+	TIMEOUT_TASK_INIT(sc->taskqueue, &sc->sampling_task, 0,
+	    iichid_sampling_task, sc);
 
 	sc->sampling_rate_slow = -1;
 	sc->sampling_rate_fast = IICHID_SAMPLING_RATE_FAST;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401191709.40JH9sCL079709>