Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Convert ppp_list_lock to mutex(9).
details: https://anonhg.NetBSD.org/src/rev/1a956953adc4
branches: trunk
changeset: 768065:1a956953adc4
user: rmind <rmind%NetBSD.org@localhost>
date: Sun Aug 07 13:51:37 2011 +0000
description:
Convert ppp_list_lock to mutex(9).
diffstat:
sys/net/if_ppp.c | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
diffs (102 lines):
diff -r 4acf8fce7c62 -r 1a956953adc4 sys/net/if_ppp.c
--- a/sys/net/if_ppp.c Sun Aug 07 13:45:46 2011 +0000
+++ b/sys/net/if_ppp.c Sun Aug 07 13:51:37 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ppp.c,v 1.133 2011/04/02 08:11:32 mbalmer Exp $ */
+/* $NetBSD: if_ppp.c,v 1.134 2011/08/07 13:51:37 rmind Exp $ */
/* Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp */
/*
@@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.133 2011/04/02 08:11:32 mbalmer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.134 2011/08/07 13:51:37 rmind Exp $");
#include "ppp.h"
@@ -130,7 +130,6 @@
#include <sys/conf.h>
#include <sys/kauth.h>
#include <sys/intr.h>
-#include <sys/simplelock.h>
#include <sys/socketvar.h>
#include <net/if.h>
@@ -205,12 +204,11 @@
static struct ppp_softc *ppp_create(const char *, int);
static LIST_HEAD(, ppp_softc) ppp_softc_list;
+static kmutex_t ppp_list_lock;
struct if_clone ppp_cloner =
IF_CLONE_INITIALIZER("ppp", ppp_clone_create, ppp_clone_destroy);
-static struct simplelock ppp_list_mutex = SIMPLELOCK_INITIALIZER;
-
#ifdef PPP_COMPRESS
ONCE_DECL(ppp_compressor_mtx_init);
static LIST_HEAD(, compressor) ppp_compressors = { NULL };
@@ -232,6 +230,8 @@
if (ttyldisc_attach(&ppp_disc) != 0)
panic("pppattach");
+
+ mutex_init(&ppp_list_lock, MUTEX_DEFAULT, IPL_NONE);
LIST_INIT(&ppp_softc_list);
if_clone_attach(&ppp_cloner);
RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init);
@@ -244,7 +244,7 @@
sc = malloc(sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO);
- simple_lock(&ppp_list_mutex);
+ mutex_enter(&ppp_list_lock);
if (unit == -1) {
int i = 0;
LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) {
@@ -280,7 +280,7 @@
else
LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_iflist);
- simple_unlock(&ppp_list_mutex);
+ mutex_exit(&ppp_list_lock);
if_initname(&sc->sc_if, name, sc->sc_unit = unit);
callout_init(&sc->sc_timo_ch, 0);
@@ -322,9 +322,9 @@
if (sc->sc_devp != NULL)
return EBUSY; /* Not removing it */
- simple_lock(&ppp_list_mutex);
+ mutex_enter(&ppp_list_lock);
LIST_REMOVE(sc, sc_iflist);
- simple_unlock(&ppp_list_mutex);
+ mutex_exit(&ppp_list_lock);
bpf_detach(ifp);
if_detach(ifp);
@@ -342,18 +342,17 @@
struct ppp_softc *sc = NULL, *scf;
int i;
- simple_lock(&ppp_list_mutex);
- for (scf = LIST_FIRST(&ppp_softc_list); scf != NULL;
- scf = LIST_NEXT(scf, sc_iflist)) {
+ mutex_enter(&ppp_list_lock);
+ LIST_FOREACH(scf, &ppp_softc_list, sc_iflist) {
if (scf->sc_xfer == pid) {
scf->sc_xfer = 0;
- simple_unlock(&ppp_list_mutex);
+ mutex_exit(&ppp_list_lock);
return scf;
}
if (scf->sc_devp == NULL && sc == NULL)
sc = scf;
}
- simple_unlock(&ppp_list_mutex);
+ mutex_exit(&ppp_list_lock);
if (sc == NULL)
sc = ppp_create(ppp_cloner.ifc_name, -1);
Home |
Main Index |
Thread Index |
Old Index