Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/spi use workqueue(9)



details:   https://anonhg.NetBSD.org/src/rev/68f659a7add4
branches:  trunk
changeset: 342278:68f659a7add4
user:      hkenken <hkenken%NetBSD.org@localhost>
date:      Mon Dec 14 10:31:38 2015 +0000

description:
use workqueue(9)

diffstat:

 sys/dev/spi/oj6sh.c |  33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)

diffs (89 lines):

diff -r d22cb7a59cda -r 68f659a7add4 sys/dev/spi/oj6sh.c
--- a/sys/dev/spi/oj6sh.c       Mon Dec 14 10:12:45 2015 +0000
+++ b/sys/dev/spi/oj6sh.c       Mon Dec 14 10:31:38 2015 +0000
@@ -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 @@
 #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 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 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 @@
        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 @@
 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 @@
        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



Home | Main Index | Thread Index | Old Index