Module Name:    src
Committed By:   rmind
Date:           Sat May 14 02:58:27 UTC 2011

Modified Files:
        src/sys/dev/ic: lcdkp_subr.c lcdkp_subr.h

Log Message:
Convert to mutex(9).  Replace ltsleep with mtsleep.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/lcdkp_subr.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/lcdkp_subr.h

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/ic/lcdkp_subr.c
diff -u src/sys/dev/ic/lcdkp_subr.c:1.6 src/sys/dev/ic/lcdkp_subr.c:1.7
--- src/sys/dev/ic/lcdkp_subr.c:1.6	Sat Mar 14 15:36:17 2009
+++ src/sys/dev/ic/lcdkp_subr.c	Sat May 14 02:58:27 2011
@@ -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;
 }

Index: src/sys/dev/ic/lcdkp_subr.h
diff -u src/sys/dev/ic/lcdkp_subr.h:1.2 src/sys/dev/ic/lcdkp_subr.h:1.3
--- src/sys/dev/ic/lcdkp_subr.h:1.2	Mon Jun 23 11:01:58 2003
+++ src/sys/dev/ic/lcdkp_subr.h	Sat May 14 02:58:27 2011
@@ -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 *);

Reply via email to