Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Convert to mutex(9). Replace ltsleep with mtsleep.
details: https://anonhg.NetBSD.org/src/rev/bdf33cfd6ea9
branches: trunk
changeset: 764955:bdf33cfd6ea9
user: rmind <rmind%NetBSD.org@localhost>
date: Sat May 14 02:58:27 2011 +0000
description:
Convert to mutex(9). Replace ltsleep with mtsleep.
diffstat:
sys/dev/ic/lcdkp_subr.c | 44 +++++++++++++++++++++++++-------------------
sys/dev/ic/lcdkp_subr.h | 20 ++------------------
2 files changed, 27 insertions(+), 37 deletions(-)
diffs (145 lines):
diff -r 699a2fa2832e -r bdf33cfd6ea9 sys/dev/ic/lcdkp_subr.c
--- a/sys/dev/ic/lcdkp_subr.c Sat May 14 02:27:35 2011 +0000
+++ b/sys/dev/ic/lcdkp_subr.c Sat May 14 02:58:27 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lcdkp_subr.c,v 1.6 2009/03/14 15:36:17 dsl Exp $ */
+/* $NetBSD: lcdkp_subr.c,v 1.7 2011/05/14 02:58:27 rmind Exp $ */
/*
* Copyright (c) 2002 Dennis I. Chernoivanov
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lcdkp_subr.c,v 1.6 2009/03/14 15:36:17 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lcdkp_subr.c,v 1.7 2011/05/14 02:58:27 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -58,8 +58,9 @@
void
lcdkp_attach_subr(struct lcdkp_chip *sc)
{
+
sc->sc_flags = 0x0;
- lcdkp_lock_init(sc);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
}
/*
@@ -73,7 +74,7 @@
if ((sc->sc_knum == 0) || (sc->sc_kpad == NULL))
return 0;
- lcdkp_lock(sc);
+ mutex_enter(&sc->sc_lock);
if (!(sc->sc_flags & LCDKP_HAS_BUF)) {
u_int8_t b;
if (lcdkp_scan(sc, &b) != 0) {
@@ -82,7 +83,7 @@
}
}
ret = (sc->sc_flags & LCDKP_HAS_BUF);
- lcdkp_unlock(sc);
+ mutex_exit(&sc->sc_lock);
return ret;
}
@@ -98,12 +99,12 @@
if ((sc->sc_knum == 0) || (sc->sc_kpad == NULL))
return EIO;
- lcdkp_lock(sc);
+ mutex_enter(&sc->sc_lock);
if ( (error = lcdkp_poll(sc)) == 0) {
*result = sc->sc_buf;
sc->sc_flags &= ~LCDKP_HAS_BUF;
}
- lcdkp_unlock(sc);
+ mutex_exit(&sc->sc_lock);
return 0;
}
@@ -133,19 +134,24 @@
static int
lcdkp_poll(struct lcdkp_chip *sc)
{
- if (!(sc->sc_flags & LCDKP_HAS_BUF)) {
- u_int8_t b;
- while(lcdkp_scan(sc, &b) == 0) {
- int err = ltsleep((void*)sc, PRIBIO | PCATCH, "kppoll",
- HD_POLL_RATE, lcdkp_lockaddr(sc));
- if (err != EWOULDBLOCK) {
- if (lcdkp_scan(sc, &b) != 0)
- break;
- return EINTR;
- }
+ int error;
+ uint8_t b;
+
+ KASSERT(mutex_owned(&sc->sc_lock));
+
+ if (sc->sc_flags & LCDKP_HAS_BUF) {
+ return 0;
+ }
+ while (lcdkp_scan(sc, &b) == 0) {
+ error = mtsleep((void*)sc, PRIBIO | PCATCH, "kppoll",
+ HD_POLL_RATE, &sc->sc_lock);
+ if (error != EWOULDBLOCK) {
+ if (lcdkp_scan(sc, &b) != 0)
+ break;
+ return EINTR;
}
- sc->sc_buf = b;
- sc->sc_flags |= LCDKP_HAS_BUF;
}
+ sc->sc_buf = b;
+ sc->sc_flags |= LCDKP_HAS_BUF;
return 0;
}
diff -r 699a2fa2832e -r bdf33cfd6ea9 sys/dev/ic/lcdkp_subr.h
--- a/sys/dev/ic/lcdkp_subr.h Sat May 14 02:27:35 2011 +0000
+++ b/sys/dev/ic/lcdkp_subr.h Sat May 14 02:58:27 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lcdkp_subr.h,v 1.2 2003/06/23 11:01:58 martin Exp $ */
+/* $NetBSD: lcdkp_subr.h,v 1.3 2011/05/14 02:58:27 rmind Exp $ */
/*
* Copyright (c) 2002 Dennis I. Chernoivanov
@@ -31,8 +31,6 @@
#define _DEV_IC_LCDKP_SUBR_H_
#ifdef _KERNEL
-#include "opt_multiprocessor.h"
-#include <sys/lock.h>
/* Key code translation */
struct lcdkp_xlate {
@@ -54,26 +52,12 @@
u_int8_t (* sc_rread)(bus_space_tag_t, bus_space_handle_t);
-#if defined(MULTIPROCESSOR)
- struct simplelock sc_lock;
-#endif
+ kmutex_t sc_lock;
};
#define lcdkp_dr_read(sc) \
(sc)->sc_rread((sc)->sc_iot, (sc)->sc_ioh);
-#if defined(MULTIPROCESSOR)
-#define lcdkp_lock(sc) simple_lock(&(sc)->sc_lock)
-#define lcdkp_unlock(sc) simple_unlock(&(sc)->sc_lock)
-#define lcdkp_lockaddr(sc) (&(sc)->sc_lock)
-#define lcdkp_lock_init(sc) simple_lock_init(&(sc)->sc_lock)
-#else
-#define lcdkp_lock(sc) ((void)0)
-#define lcdkp_unlock(sc) ((void)0)
-#define lcdkp_lockaddr(sc) (NULL)
-#define lcdkp_lock_init(sc) ((void)0)
-#endif
-
void lcdkp_attach_subr(struct lcdkp_chip *);
int lcdkp_scankey(struct lcdkp_chip *);
int lcdkp_readkey(struct lcdkp_chip *, u_int8_t *);
Home |
Main Index |
Thread Index |
Old Index