diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/kbd/kbd.c | 17 | ||||
-rw-r--r-- | sys/dev/kbd/kbdreg.h | 1 |
2 files changed, 6 insertions, 12 deletions
diff --git a/sys/dev/kbd/kbd.c b/sys/dev/kbd/kbd.c index 9ab4c5b..1e8785d 100644 --- a/sys/dev/kbd/kbd.c +++ b/sys/dev/kbd/kbd.c @@ -447,20 +447,16 @@ static struct cdevsw kbd_cdevsw = { int kbd_attach(keyboard_t *kbd) { - dev_t dev; if (kbd->kb_index >= keyboards) return EINVAL; if (keyboard[kbd->kb_index] != kbd) return EINVAL; - dev = make_dev(&kbd_cdevsw, kbd->kb_index, UID_ROOT, GID_WHEEL, 0600, + kbd->kb_dev = make_dev(&kbd_cdevsw, kbd->kb_index, UID_ROOT, GID_WHEEL, 0600, "kbd%r", kbd->kb_index); - if (dev->si_drv1 == NULL) - dev->si_drv1 = malloc(sizeof(genkbd_softc_t), M_DEVBUF, - M_WAITOK); - bzero(dev->si_drv1, sizeof(genkbd_softc_t)); - + kbd->kb_dev->si_drv1 = malloc(sizeof(genkbd_softc_t), M_DEVBUF, + M_WAITOK | M_ZERO); printf("kbd%d at %s%d\n", kbd->kb_index, kbd->kb_name, kbd->kb_unit); return 0; } @@ -468,17 +464,14 @@ kbd_attach(keyboard_t *kbd) int kbd_detach(keyboard_t *kbd) { - dev_t dev; if (kbd->kb_index >= keyboards) return EINVAL; if (keyboard[kbd->kb_index] != kbd) return EINVAL; - dev = makedev(kbd_cdevsw.d_maj, kbd->kb_index); - if (dev->si_drv1) - free(dev->si_drv1, M_DEVBUF); - destroy_dev(dev); + free(kbd->kb_dev->si_drv1, M_DEVBUF); + destroy_dev(kbd->kb_dev); return 0; } diff --git a/sys/dev/kbd/kbdreg.h b/sys/dev/kbd/kbdreg.h index 2aefefd..05fb895 100644 --- a/sys/dev/kbd/kbdreg.h +++ b/sys/dev/kbd/kbdreg.h @@ -90,6 +90,7 @@ struct keyboard { #define KB_DELAY2 100 unsigned long kb_count; /* # of processed key strokes */ u_char kb_lastact[NUM_KEYS/2]; + dev_t kb_dev; }; #define KBD_IS_VALID(k) ((k)->kb_flags & KB_VALID) |