Module Name:    src
Committed By:   hkenken
Date:           Mon Dec 14 10:31:38 UTC 2015

Modified Files:
        src/sys/dev/spi: oj6sh.c

Log Message:
use workqueue(9)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/spi/oj6sh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/spi/oj6sh.c
diff -u src/sys/dev/spi/oj6sh.c:1.1 src/sys/dev/spi/oj6sh.c:1.2
--- src/sys/dev/spi/oj6sh.c:1.1	Sat Mar 29 12:00:27 2014
+++ src/sys/dev/spi/oj6sh.c	Mon Dec 14 10:31:38 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: oj6sh.c,v 1.1 2014/03/29 12:00:27 hkenken Exp $	*/
+/*	$NetBSD: oj6sh.c,v 1.2 2015/12/14 10:31:38 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014  Genetec Corporation.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: oj6sh.c,v 1.1 2014/03/29 12:00:27 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: oj6sh.c,v 1.2 2015/12/14 10:31:38 hkenken Exp $");
 
 #include "opt_oj6sh.h"
 
@@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: oj6sh.c,v 1.
 #include <sys/callout.h>
 #include <sys/bus.h>
 #include <sys/mutex.h>
+#include <sys/workqueue.h>
 
 #include <dev/wscons/wsconsio.h>
 #include <dev/wscons/wsmousevar.h>
@@ -83,6 +84,9 @@ struct oj6sh_softc {
 	struct callout sc_c;
 
 	kmutex_t sc_lock;
+	struct workqueue *sc_wq;
+	struct work sc_wk;
+
 	int sc_enabled;
 
 	device_t sc_wsmousedev;
@@ -108,8 +112,9 @@ static bool oj6sh_shuttrer(struct spi_ha
 static int oj6sh_readdelta(struct spi_handle *, struct oj6sh_delta *);
 
 static void oj6sh_poll(void *);
-static int oj6sh_enable(void *v);
-static void oj6sh_disable(void *v);
+static void oj6sh_cb(struct work *, void *);
+static int oj6sh_enable(void *);
+static void oj6sh_disable(void *);
 static int oj6sh_ioctl(void *, u_long, void *, int, struct lwp *);
 
 static bool oj6sh_resume(device_t, const pmf_qual_t *);
@@ -183,6 +188,8 @@ oj6sh_attach(device_t parent, device_t s
 	sc->sc_enabled = 0;
 
 	callout_init(&sc->sc_c, 0);
+	workqueue_create(&sc->sc_wq, "oj6sh",
+	    oj6sh_cb, sc, PRI_NONE, IPL_BIO, 0);
 
 	sc->sc_sh = sa->sa_handle;
 
@@ -198,6 +205,19 @@ static void
 oj6sh_poll(void *arg)
 {
 	struct oj6sh_softc *sc = (struct oj6sh_softc *)arg;
+
+	workqueue_enqueue(sc->sc_wq, &sc->sc_wk, NULL);
+
+	if (sc->sc_enabled)
+		callout_reset(&sc->sc_c, POLLRATE, oj6sh_poll, sc);
+
+	return;
+}
+
+static void
+oj6sh_cb(struct work *wk, void *arg)
+{
+	struct oj6sh_softc *sc = (struct oj6sh_softc *)arg;
 	struct oj6sh_delta delta = {0, 0};
 	uint32_t buttons = 0;
 	int s;
@@ -234,11 +254,6 @@ oj6sh_poll(void *arg)
 	splx(s);
 out:
 	mutex_exit(&sc->sc_lock);
-
-	if (sc->sc_enabled)
-		callout_reset(&sc->sc_c, POLLRATE, oj6sh_poll, sc);
-
-	return;
 }
 
 static uint8_t

Reply via email to