Module Name: src Committed By: rmind Date: Sun Aug 7 13:51:37 UTC 2011
Modified Files: src/sys/net: if_ppp.c Log Message: Convert ppp_list_lock to mutex(9). To generate a diff of this commit: cvs rdiff -u -r1.133 -r1.134 src/sys/net/if_ppp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/if_ppp.c diff -u src/sys/net/if_ppp.c:1.133 src/sys/net/if_ppp.c:1.134 --- src/sys/net/if_ppp.c:1.133 Sat Apr 2 08:11:32 2011 +++ src/sys/net/if_ppp.c Sun Aug 7 13:51:37 2011 @@ -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);