From 5941740892046de204f4bc36b748061780d4e47b Mon Sep 17 00:00:00 2001 From: ad Date: Sun, 11 Mar 2007 22:16:32 +0000 Subject: [PATCH] Remove a use of lockmgr/LOCK_INITIALIZER. --- sys/dev/ic/icp.c | 7 ++++--- sys/dev/ic/icp_ioctl.c | 14 ++++++-------- sys/dev/ic/icpvar.h | 6 +++++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/sys/dev/ic/icp.c b/sys/dev/ic/icp.c index 76d777aea304..fc10505a8375 100644 --- a/sys/dev/ic/icp.c +++ b/sys/dev/ic/icp.c @@ -1,4 +1,4 @@ -/* $NetBSD: icp.c,v 1.23 2007/03/04 06:01:56 christos Exp $ */ +/* $NetBSD: icp.c,v 1.24 2007/03/11 22:16:32 ad Exp $ */ /*- * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. @@ -83,7 +83,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: icp.c,v 1.23 2007/03/04 06:01:56 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: icp.c,v 1.24 2007/03/11 22:16:32 ad Exp $"); #include #include @@ -416,7 +416,8 @@ icp_init(struct icp_softc *icp, const char *intrstr) /* * Count the controller, and we're done! */ - icp_count++; + if (icp_count++ == 0) + mutex_init(&icp_ioctl_mutex, MUTEX_DEFAULT, IPL_NONE); return (0); diff --git a/sys/dev/ic/icp_ioctl.c b/sys/dev/ic/icp_ioctl.c index 8045c397e4f4..334d9f331bfc 100644 --- a/sys/dev/ic/icp_ioctl.c +++ b/sys/dev/ic/icp_ioctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: icp_ioctl.c,v 1.15 2007/03/04 06:01:56 christos Exp $ */ +/* $NetBSD: icp_ioctl.c,v 1.16 2007/03/11 22:16:32 ad Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: icp_ioctl.c,v 1.15 2007/03/04 06:01:56 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: icp_ioctl.c,v 1.16 2007/03/11 22:16:32 ad Exp $"); #include #include @@ -106,8 +106,7 @@ const struct cdevsw icp_cdevsw = { extern struct cfdriver icp_cd; -static struct lock icp_ioctl_mutex = - LOCK_INITIALIZER(PRIBIO|PCATCH, "icplk", 0, 0); +kmutex_t icp_ioctl_mutex; static int icpopen(dev_t dev, int flag, int mode, struct lwp *l) @@ -123,10 +122,9 @@ static int icpioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { - int error; + int error = 0; - if ((error = lockmgr(&icp_ioctl_mutex, LK_EXCLUSIVE, NULL)) != 0) - return (error); + mutex_enter(&icp_ioctl_mutex); switch (cmd) { case GDT_IOCTL_GENERAL: @@ -295,7 +293,7 @@ icpioctl(dev_t dev, u_long cmd, void *data, int flag, error = ENOTTY; } - (void) lockmgr(&icp_ioctl_mutex, LK_RELEASE, NULL); + mutex_exit(&icp_ioctl_mutex); return (error); } diff --git a/sys/dev/ic/icpvar.h b/sys/dev/ic/icpvar.h index e6d9278095b1..1021bf95f485 100644 --- a/sys/dev/ic/icpvar.h +++ b/sys/dev/ic/icpvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: icpvar.h,v 1.8 2007/03/04 06:01:56 christos Exp $ */ +/* $NetBSD: icpvar.h,v 1.9 2007/03/11 22:16:32 ad Exp $ */ /*- * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. @@ -39,6 +39,8 @@ #ifndef _IC_ICPVAR_H_ #define _IC_ICPVAR_H_ +#include + #include /* @@ -264,4 +266,6 @@ int icp_read_event(struct icp_softc *, int, gdt_evt_str *); void icp_readapp_event(struct icp_softc *, u_int8_t, gdt_evt_str *); void icp_clear_events(struct icp_softc *); +extern kmutex_t icp_ioctl_mutex; + #endif /* !_IC_ICPVAR_H_ */