Support for SIGIO.
This commit is contained in:
parent
eaaf682603
commit
e44f0f1147
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: uhid.c,v 1.36 2000/03/27 12:33:56 augustss Exp $ */
|
||||
/* $NetBSD: uhid.c,v 1.37 2000/04/14 14:12:47 augustss Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/uhid.c,v 1.22 1999/11/17 22:33:43 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -46,6 +46,7 @@
|
|||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/signalvar.h>
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/device.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
@ -103,6 +104,7 @@ struct uhid_softc {
|
|||
|
||||
struct clist sc_q;
|
||||
struct selinfo sc_rsel;
|
||||
struct proc *sc_async; /* process that wants SIGIO */
|
||||
u_char sc_state; /* driver state */
|
||||
#define UHID_OPEN 0x01 /* device is open */
|
||||
#define UHID_ASLP 0x02 /* waiting for device data */
|
||||
|
@ -356,6 +358,10 @@ uhid_intr(xfer, addr, status)
|
|||
wakeup(&sc->sc_q);
|
||||
}
|
||||
selwakeup(&sc->sc_rsel);
|
||||
if (sc->sc_async != NULL) {
|
||||
DPRINTFN(3, ("uhid_intr: sending SIGIO %p\n", sc->sc_async));
|
||||
psignal(sc->sc_async, SIGIO);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -402,6 +408,8 @@ uhidopen(dev, flag, mode, p)
|
|||
|
||||
sc->sc_state &= ~UHID_IMMED;
|
||||
|
||||
sc->sc_async = 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -430,6 +438,8 @@ uhidclose(dev, flag, mode, p)
|
|||
|
||||
sc->sc_state &= ~UHID_OPEN;
|
||||
|
||||
sc->sc_async = 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -591,6 +601,24 @@ uhid_do_ioctl(sc, cmd, addr, flag, p)
|
|||
/* All handled in the upper FS layer. */
|
||||
break;
|
||||
|
||||
case FIOASYNC:
|
||||
if (*(int *)addr) {
|
||||
if (sc->sc_async != NULL)
|
||||
return (EBUSY);
|
||||
sc->sc_async = p;
|
||||
DPRINTF(("uhid_do_ioctl: FIOASYNC %p\n", p));
|
||||
} else
|
||||
sc->sc_async = NULL;
|
||||
break;
|
||||
|
||||
/* XXX this is not the most general solution. */
|
||||
case TIOCSPGRP:
|
||||
if (sc->sc_async == NULL)
|
||||
return (EINVAL);
|
||||
if (*(int *)addr != sc->sc_async->p_pgid)
|
||||
return (EPERM);
|
||||
break;
|
||||
|
||||
case USB_GET_REPORT_DESC:
|
||||
rd = (struct usb_ctl_report_desc *)addr;
|
||||
size = min(sc->sc_repdesc_size, sizeof rd->data);
|
||||
|
|
Loading…
Reference in New Issue