Index: sys/dev/led/led.c =================================================================== --- sys/dev/led/led.c (revision 221961) +++ sys/dev/led/led.c (working copy) @@ -39,7 +39,6 @@ }; static struct unrhdr *led_unit; -static struct mtx led_mtx; static struct sx led_sx; static LIST_HEAD(, ledsc) led_list = LIST_HEAD_INITIALIZER(led_list); static struct callout led_ch; @@ -51,7 +50,7 @@ { struct ledsc *sc; - mtx_lock(&led_mtx); + sx_xlock(&led_sx); LIST_FOREACH(sc, &led_list, list) { if (sc->ptr == NULL) continue; @@ -78,7 +77,7 @@ if (*sc->ptr == '\0') sc->ptr = sc->str; } - mtx_unlock(&led_mtx); + sx_xunlock(&led_sx); callout_reset(&led_ch, hz / 10, led_timeout, p); return; } @@ -221,11 +220,11 @@ free(s, M_DEVBUF); if (error) return (error); - mtx_lock(&led_mtx); + sx_xlock(&led_sx); sc = dev->si_drv1; if (sc != NULL) error = led_state(sc, &sb, state); - mtx_unlock(&led_mtx); + sx_xunlock(&led_sx); if (sb != NULL) sbuf_delete(sb); return (error); @@ -241,7 +240,7 @@ error = led_parse(cmd, &sb, &state); if (error) return (error); - mtx_lock(&led_mtx); + sx_xlock(&led_sx); LIST_FOREACH(sc, &led_list, list) { if (strcmp(sc->name, name) == 0) break; @@ -250,7 +249,7 @@ error = led_state(sc, &sb, state); else error = ENOENT; - mtx_unlock(&led_mtx); + sx_xunlock(&led_sx); if (sb != NULL) sbuf_delete(sb); return (0); @@ -282,15 +281,13 @@ sc->func = func; sc->dev = make_dev(&led_cdevsw, sc->unit, UID_ROOT, GID_WHEEL, 0600, "led/%s", name); - sx_xunlock(&led_sx); - mtx_lock(&led_mtx); sc->dev->si_drv1 = sc; if (LIST_EMPTY(&led_list)) callout_reset(&led_ch, hz / 10, led_timeout, NULL); LIST_INSERT_HEAD(&led_list, sc, list); sc->func(sc->private, state != 0); - mtx_unlock(&led_mtx); + sx_xunlock(&led_sx); return (sc->dev); } @@ -300,16 +297,14 @@ { struct ledsc *sc; - mtx_lock(&led_mtx); + sx_xlock(&led_sx); sc = dev->si_drv1; dev->si_drv1 = NULL; LIST_REMOVE(sc, list); if (LIST_EMPTY(&led_list)) callout_stop(&led_ch); - mtx_unlock(&led_mtx); - sx_xlock(&led_sx); free_unr(led_unit, sc->unit); destroy_dev(dev); if (sc->spec != NULL) @@ -324,7 +319,6 @@ { led_unit = new_unrhdr(0, INT_MAX, NULL); - mtx_init(&led_mtx, "LED mtx", NULL, MTX_DEF); sx_init(&led_sx, "LED sx"); callout_init(&led_ch, CALLOUT_MPSAFE); }