#include <sys/conf.h>
#include <sys/device.h>
#include <sys/malloc.h>
-#include <sys/poll.h>
#include <sys/vnode.h>
#include <sys/devicestat.h>
#include <sys/thread2.h>
static d_read_t targread;
static d_write_t targwrite;
static d_ioctl_t targioctl;
-static d_poll_t targpoll;
static d_kqfilter_t targkqfilter;
static d_clone_t targclone;
DEVFS_DECLARE_CLONE_BITMAP(targ);
-static void targreadfiltdetach(struct knote *kn);
+static void targfiltdetach(struct knote *kn);
static int targreadfilt(struct knote *kn, long hint);
+static int targwritefilt(struct knote *kn, long hint);
static struct filterops targread_filtops =
- { 1, NULL, targreadfiltdetach, targreadfilt };
+ { 1, NULL, targfiltdetach, targreadfilt };
+static struct filterops targwrite_filtops =
+ { 1, NULL, targfiltdetach, targwritefilt };
#define TARG_CDEV_MAJOR 65
static struct dev_ops targ_ops = {
.d_read = targread,
.d_write = targwrite,
.d_ioctl = targioctl,
- .d_poll = targpoll,
.d_kqfilter = targkqfilter
};
return (targcamstatus(status));
}
-/* Writes are always ready, reads wait for user_ccb_queue or abort_queue */
-static int
-targpoll(struct dev_poll_args *ap)
-{
- struct targ_softc *softc;
- int revents;
-
- softc = (struct targ_softc *)ap->a_head.a_dev->si_drv1;
-
- /* Poll for write() is always ok. */
- revents = ap->a_events & (POLLOUT | POLLWRNORM);
- if ((ap->a_events & (POLLIN | POLLRDNORM)) != 0) {
- /* Poll for read() depends on user and abort queues. */
- cam_periph_lock(softc->periph);
- if (!TAILQ_EMPTY(&softc->user_ccb_queue) ||
- !TAILQ_EMPTY(&softc->abort_queue)) {
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- }
- cam_periph_unlock(softc->periph);
- /* Only sleep if the user didn't poll for write. */
- if (revents == 0)
- selrecord(curthread, &softc->read_select);
- }
- ap->a_events = revents;
- return (0);
-}
-
static int
targkqfilter(struct dev_kqfilter_args *ap)
{
struct targ_softc *softc;
softc = (struct targ_softc *)ap->a_head.a_dev->si_drv1;
- kn->kn_hook = (caddr_t)softc;
- kn->kn_fop = &targread_filtops;
+
+ ap->a_result = 0;
+
+ switch (kn->kn_filter) {
+ case EVFILT_READ:
+ kn->kn_hook = (caddr_t)softc;
+ kn->kn_fop = &targread_filtops;
+ break;
+ case EVFILT_WRITE:
+ kn->kn_hook = (caddr_t)softc;
+ kn->kn_fop = &targwrite_filtops;
+ default:
+ ap->a_result = EOPNOTSUPP;
+ return (0);
+ }
+
crit_enter();
SLIST_INSERT_HEAD(&softc->read_select.si_note, kn, kn_selnext);
crit_exit();
}
static void
-targreadfiltdetach(struct knote *kn)
+targfiltdetach(struct knote *kn)
{
struct targ_softc *softc;
return (retval);
}
+/* write() is always ok */
+static int
+targwritefilt(struct knote *kn, long hint)
+{
+ return (1);
+}
+
/* Send the HBA the enable/disable message */
static cam_status
targendislun(struct cam_path *path, int enable, int grp6_len, int grp7_len)
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/conf.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/bus.h>
static d_open_t fw_open;
static d_close_t fw_close;
static d_ioctl_t fw_ioctl;
-static d_poll_t fw_poll;
static d_kqfilter_t fw_kqfilter;
static d_read_t fw_read; /* for Isochronous packet */
static d_write_t fw_write;
.d_read = fw_read,
.d_write = fw_write,
.d_ioctl = fw_ioctl,
- .d_poll = fw_poll,
.d_kqfilter = fw_kqfilter,
.d_mmap = fw_mmap,
.d_strategy = fw_strategy,
}
return err;
}
-int
-fw_poll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct firewire_softc *sc;
- struct fw_xferq *ir;
- int revents;
- int tmp;
- int unit = DEV2UNIT(dev);
-
- if (DEV_FWMEM(dev))
- return fwmem_poll(ap);
-
- sc = devclass_get_softc(firewire_devclass, unit);
- ir = ((struct fw_drv1 *)dev->si_drv1)->ir;
- revents = 0;
- tmp = POLLIN | POLLRDNORM;
- if (ap->a_events & tmp) {
- if (STAILQ_FIRST(&ir->q) != NULL)
- revents |= tmp;
- else
- selrecord(curthread, &ir->rsel);
- }
- tmp = POLLOUT | POLLWRNORM;
- if (ap->a_events & tmp) {
- /* XXX should be fixed */
- revents |= tmp;
- }
- ap->a_events = revents;
- return(0);
-}
static struct filterops fw_read_filterops =
{ 1, NULL, fwfilt_detach, fwfilt_read };
}
return(err);
}
-int
-fwmem_poll(struct dev_poll_args *ap)
-{
- return EINVAL;
-}
+
int
fwmem_mmap(struct dev_mmap_args *ap)
{
d_ioctl_t fwmem_ioctl;
d_read_t fwmem_read;
d_write_t fwmem_write;
-d_poll_t fwmem_poll;
d_mmap_t fwmem_mmap;
d_strategy_t fwmem_strategy;
#include <sys/proc.h>
#include <sys/conf.h>
#include <sys/device.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/select.h>
#include <sys/vnode.h>
d_close_t usbclose;
d_read_t usbread;
d_ioctl_t usbioctl;
-d_poll_t usbpoll;
d_kqfilter_t usbkqfilter;
static void usbfilt_detach(struct knote *);
.d_close = usbclose,
.d_read = usbread,
.d_ioctl = usbioctl,
- .d_poll = usbpoll,
.d_kqfilter = usbkqfilter
};
return (0);
}
-int
-usbpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- int revents, mask;
- int unit = USBUNIT(dev);
-
- if (unit == USB_DEV_MINOR) {
- revents = 0;
- mask = POLLIN | POLLRDNORM;
-
- crit_enter();
- if (ap->a_events & mask && usb_nevents > 0)
- revents |= ap->a_events & mask;
- if (revents == 0 && ap->a_events & mask)
- selrecord(curthread, &usb_selevent);
- crit_exit();
- ap->a_events = revents;
- return (0);
- } else {
- ap->a_events = 0;
- return (0); /* select/poll never wakes up - back compat */
- }
-}
-
static struct filterops usbfiltops =
{ 1, NULL, usbfilt_detach, usbfilt };
#include <sys/sysctl.h>
#include <sys/bus.h>
#include <sys/signalvar.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/tree.h>
#include <sys/taskqueue.h>
d_open_t drm_open;
d_close_t drm_close;
d_read_t drm_read;
-d_poll_t drm_poll;
d_kqfilter_t drm_kqfilter;
d_mmap_t drm_mmap;
extern drm_local_map_t *drm_getsarea(struct drm_device *dev);
.d_close = drm_close,
.d_read = drm_read,
.d_ioctl = drm_ioctl,
- .d_poll = drm_poll,
.d_kqfilter = drm_kqfilter,
.d_mmap = drm_mmap
};
return 0;
}
-int drm_poll(struct dev_poll_args *ap)
-{
- return 0;
-}
-
static int
drmfilt(struct knote *kn, long hint)
{
#include <sys/kernel.h>
#include <sys/sockio.h>
#include <sys/mbuf.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
static d_close_t cmx_close;
static d_read_t cmx_read;
static d_write_t cmx_write;
-static d_poll_t cmx_poll;
static d_kqfilter_t cmx_kqfilter;
#ifdef CMX_INTR
static void cmx_intr(void *arg);
.d_close = cmx_close,
.d_read = cmx_read,
.d_write = cmx_write,
- .d_poll = cmx_poll,
.d_kqfilter = cmx_kqfilter
};
return 0;
}
-/*
- * Poll handler. Writing is always possible, reading is only possible
- * if BSR_BULK_IN_FULL is set. Will start the cmx_tick callout and
- * set sc->polling.
- */
-static int
-cmx_poll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct cmx_softc *sc;
- int revents = 0;
- uint8_t bsr = 0;
-
- sc = devclass_get_softc(cmx_devclass, minor(dev));
- if (sc == NULL || sc->dying)
- return ENXIO;
-
- bsr = cmx_read_BSR(sc);
- DEBUG_printf(sc->dev, "called (events=%b BSR=%b)\n",
- ap->a_events, POLLBITS, bsr, BSRBITS);
-
- revents = ap->a_events & (POLLOUT | POLLWRNORM);
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (cmx_test(bsr, BSR_BULK_IN_FULL, 1)) {
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- } else {
- selrecord(curthread, &sc->sel);
- CMX_LOCK(sc);
- if (!sc->polling) {
- DEBUG_printf(sc->dev, "enabling polling\n");
- sc->polling = 1;
- callout_reset(&sc->ch, POLL_TICKS,
- cmx_tick, sc);
- } else {
- DEBUG_printf(sc->dev, "already polling\n");
- }
- CMX_UNLOCK(sc);
- }
- }
-
- DEBUG_printf(sc->dev, "success (revents=%b)\n", revents, POLLBITS);
-
- return revents;
-}
-
static struct filterops cmx_read_filterops =
{ 1, NULL, cmx_filter_detach, cmx_filter_read };
static struct filterops cmx_write_filterops =
.d_read = ttyread,
.d_write = ttywrite,
.d_ioctl = dcons_ioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
#include <sys/device.h>
#include <sys/lock.h>
#include <sys/selinfo.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/uio.h>
#include <sys/thread.h>
static d_open_t hotplugopen;
static d_close_t hotplugclose;
static d_read_t hotplugread;
-static d_poll_t hotplugpoll;
static d_kqfilter_t hotplugkqfilter;
static void hotplugfiltdetach(struct knote *);
.d_open = hotplugopen,
.d_close = hotplugclose,
.d_read = hotplugread,
- .d_poll = hotplugpoll,
.d_kqfilter = hotplugkqfilter
};
return 0;
}
-static int
-hotplugpoll(struct dev_poll_args *ap)
-{
- int revents = 0;
-
- lockmgr(&hpsc.lock, LK_EXCLUSIVE);
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (!TAILQ_EMPTY(&hpsc.queue))
- revents = ap->a_events & (POLLIN | POLLRDNORM);
- else
- selrecord(curthread, &hpsc.sel);
- }
- lockmgr(&hpsc.lock, LK_RELEASE);
-
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops hotplugfiltops =
{ 1, NULL, hotplugfiltdetach, hotplugfilt };
#include <sys/conf.h>
#include <sys/proc.h>
#include <sys/tty.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/vnode.h>
#include <sys/uio.h>
static d_read_t genkbdread;
static d_write_t genkbdwrite;
static d_ioctl_t genkbdioctl;
-static d_poll_t genkbdpoll;
static d_kqfilter_t genkbdkqfilter;
static void genkbdfiltdetach(struct knote *);
.d_read = genkbdread,
.d_write = genkbdwrite,
.d_ioctl = genkbdioctl,
- .d_poll = genkbdpoll,
.d_kqfilter = genkbdkqfilter
};
return error;
}
-static int
-genkbdpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- keyboard_t *kbd;
- genkbd_softc_t sc;
- int revents;
-
- revents = 0;
- crit_enter();
- sc = dev->si_drv1;
- kbd = kbd_get_keyboard(KBD_INDEX(dev));
- if ((sc == NULL) || (kbd == NULL) || !KBD_IS_VALID(kbd)) {
- revents = POLLHUP; /* the keyboard has gone */
- } else if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (sc->gkb_q_length > 0)
- revents = ap->a_events & (POLLIN | POLLRDNORM);
- else
- selrecord(curthread, &sc->gkb_rsel);
- }
- crit_exit();
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops genkbdfiltops =
{ 1, NULL, genkbdfiltdetach, genkbdfilter };
#include <sys/device.h>
#include <sys/kernel.h>
#include <sys/bus.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/selinfo.h>
#include <sys/uio.h>
static d_close_t mseclose;
static d_read_t mseread;
static d_ioctl_t mseioctl;
-static d_poll_t msepoll;
static d_kqfilter_t msekqfilter;
static void msefilter_detach(struct knote *);
.d_close = mseclose,
.d_read = mseread,
.d_ioctl = mseioctl,
- .d_poll = msepoll,
.d_kqfilter = msekqfilter
};
return (err);
}
-/*
- * msepoll: check for mouse input to be processed.
- */
-static int
-msepoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- mse_softc_t *sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev));
- int revents = 0;
-
- crit_enter();
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (sc->sc_bytesread != sc->mode.packetsize ||
- sc->sc_deltax != 0 || sc->sc_deltay != 0 ||
- (sc->sc_obuttons ^ sc->sc_buttons) != 0)
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- else {
- /*
- * Since this is an exclusive open device, any previous
- * proc pointer is trash now, so we can just assign it.
- */
- selrecord(curthread, &sc->sc_selp);
- }
- }
- crit_exit();
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops msefiltops =
{ 1, NULL, msefilter_detach, msefilter };
#include <sys/tty.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
-#include <sys/poll.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
#include <sys/signalvar.h>
.d_read = nmdmread,
.d_write = nmdmwrite,
.d_ioctl = nmdmioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/device.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/syslog.h>
#include <sys/malloc.h>
static d_close_t psmclose;
static d_read_t psmread;
static d_ioctl_t psmioctl;
-static d_poll_t psmpoll;
static d_kqfilter_t psmkqfilter;
static int enable_aux_dev (KBDC);
.d_close = psmclose,
.d_read = psmread,
.d_ioctl = psmioctl,
- .d_poll = psmpoll,
.d_kqfilter = psmkqfilter
};
}
}
-static int
-psmpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct psm_softc *sc = PSM_SOFTC(PSM_UNIT(dev));
- int revents = 0;
-
- /* Return true if a mouse event available */
- crit_enter();
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (sc->queue.count > 0)
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- else
- selrecord(curthread, &sc->rsel);
- }
- crit_exit();
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops psmfiltops =
{ 1, NULL, psmfilter_detach, psmfilter };
#include <sys/malloc.h>
#include <sys/tty.h>
#include <sys/conf.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/kernel.h>
#include <sys/queue.h>
static d_read_t snpread;
static d_write_t snpwrite;
static d_ioctl_t snpioctl;
-static d_poll_t snppoll;
static d_kqfilter_t snpkqfilter;
static d_clone_t snpclone;
DEVFS_DECLARE_CLONE_BITMAP(snp);
static void snpfilter_detach(struct knote *);
-static int snpfilter(struct knote *, long);
+static int snpfilter_rd(struct knote *, long);
+static int snpfilter_wr(struct knote *, long);
#if NSNP <= 1
#define SNP_PREALLOCATED_UNITS 4
.d_read = snpread,
.d_write = snpwrite,
.d_ioctl = snpioctl,
- .d_poll = snppoll,
.d_kqfilter = snpkqfilter
};
return (0);
}
-static int
-snppoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct snoop *snp;
- int revents;
-
- snp = dev->si_drv1;
- revents = 0;
- /*
- * If snoop is down, we don't want to poll() forever so we return 1.
- * Caller should see if we down via FIONREAD ioctl(). The last should
- * return -1 to indicate down state.
- */
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (snp->snp_flags & SNOOP_DOWN || snp->snp_len > 0)
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- else
- selrecord(curthread, &snp->snp_sel);
- }
- ap->a_events = revents;
- return (0);
-}
-
-static struct filterops snpfiltops =
- { 1, NULL, snpfilter_detach, snpfilter };
+static struct filterops snpfiltops_rd =
+ { 1, NULL, snpfilter_detach, snpfilter_rd };
+static struct filterops snpfiltops_wr =
+ { 1, NULL, snpfilter_detach, snpfilter_wr };
static int
snpkqfilter(struct dev_kqfilter_args *ap)
switch (kn->kn_filter) {
case EVFILT_READ:
- kn->kn_fop = &snpfiltops;
+ kn->kn_fop = &snpfiltops_rd;
+ kn->kn_hook = (caddr_t)snp;
+ break;
+ case EVFILT_WRITE:
+ kn->kn_fop = &snpfiltops_wr;
kn->kn_hook = (caddr_t)snp;
break;
default:
}
static int
-snpfilter(struct knote *kn, long hint)
+snpfilter_rd(struct knote *kn, long hint)
{
struct snoop *snp = (struct snoop *)kn->kn_hook;
int ready = 0;
return (ready);
}
+static int
+snpfilter_wr(struct knote *kn, long hint)
+{
+ /* Writing is always OK */
+ return (1);
+}
+
static int
snpclone(struct dev_clone_args *ap)
{
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/rman.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/tty.h>
#include <sys/conf.h>
static d_close_t spicclose;
static d_read_t spicread;
static d_ioctl_t spicioctl;
-static d_poll_t spicpoll;
static d_kqfilter_t spickqfilter;
static void spicfilt_detach(struct knote *);
.d_close = spicclose,
.d_read = spicread,
.d_ioctl = spicioctl,
- .d_poll = spicpoll,
.d_kqfilter = spickqfilter
};
return EIO;
}
-static int
-spicpoll(struct dev_poll_args *ap)
-{
- struct spic_softc *sc;
- int revents = 0;
-
- sc = devclass_get_softc(spic_devclass, 0);
- crit_enter();
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (sc->sc_count) {
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- } else {
- selrecord(curthread, &sc->sc_rsel);
- }
- }
- crit_exit();
- ap->a_events = revents;
- return(0);
-}
-
static struct filterops spicfiltops =
{ 1, NULL, spicfilt_detach, spicfilt };
.d_read = scread,
.d_write = ttywrite,
.d_ioctl = scioctl,
- .d_poll = ttypoll,
.d_mmap = scmmap,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
.d_close = smclose,
.d_read = ttyread,
.d_ioctl = smioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
#include <sys/uio.h>
#include <sys/syslog.h>
#include <sys/selinfo.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/thread2.h>
static d_close_t twclose;
static d_read_t twread;
static d_write_t twwrite;
-static d_poll_t twpoll;
static d_kqfilter_t twkqfilter;
static void twfilter_detach(struct knote *);
-static int twfilter(struct knote *, long);
+static int twfilter_read(struct knote *, long);
+static int twfilter_write(struct knote *, long);
#define CDEV_MAJOR 19
static struct dev_ops tw_ops = {
.d_close = twclose,
.d_read = twread,
.d_write = twwrite,
- .d_poll = twpoll,
.d_kqfilter = twkqfilter
};
* Determine if there is data available for reading
*/
-int
-twpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct tw_sc *sc;
- int revents = 0;
-
- sc = &tw_sc[TWUNIT(dev)];
- crit_enter();
- /* XXX is this correct? the original code didn't test select rw mode!! */
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if(sc->sc_nextin != sc->sc_nextout)
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- else
- selrecord(curthread, &sc->sc_selp);
- }
- crit_exit();
- ap->a_events = revents;
- return(0);
-}
-
-static struct filterops twfiltops =
- { 1, NULL, twfilter_detach, twfilter };
+static struct filterops twfiltops_read =
+ { 1, NULL, twfilter_detach, twfilter_read };
+static struct filterops twfiltops_write =
+ { 1, NULL, twfilter_detach, twfilter_write };
static int
twkqfilter(struct dev_kqfilter_args *ap)
switch (kn->kn_filter) {
case EVFILT_READ:
sc = &tw_sc[TWUNIT(dev)];
- kn->kn_fop = &twfiltops;
+ kn->kn_fop = &twfiltops_read;
+ kn->kn_hook = (caddr_t)sc;
+ break;
+ case EVFILT_WRITE:
+ sc = &tw_sc[TWUNIT(dev)];
+ kn->kn_fop = &twfiltops_write;
kn->kn_hook = (caddr_t)sc;
break;
default:
}
static int
-twfilter(struct knote *kn, long hint)
+twfilter_read(struct knote *kn, long hint)
{
struct tw_sc *sc = (struct tw_sc *)kn->kn_hook;
int ready = 0;
return (ready);
}
+static int
+twfilter_write(struct knote *kn, long hint)
+{
+ /* write() is always OK */
+ return (1);
+}
+
/*
* X-10 Protocol
*/
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/sysctl.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/bus.h>
static d_open_t aac_open;
static d_close_t aac_close;
static d_ioctl_t aac_ioctl;
-static d_poll_t aac_poll;
static d_kqfilter_t aac_kqfilter;
static void aac_filter_detach(struct knote *kn);
static int aac_filter(struct knote *kn, long hint);
.d_open = aac_open,
.d_close = aac_close,
.d_ioctl = aac_ioctl,
- .d_poll = aac_poll,
.d_kqfilter = aac_kqfilter
};
return(error);
}
-static int
-aac_poll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct aac_softc *sc;
- int revents;
-
- sc = dev->si_drv1;
- revents = 0;
-
- AAC_LOCK_ACQUIRE(&sc->aac_aifq_lock);
- if ((ap->a_events & (POLLRDNORM | POLLIN)) != 0) {
- if (sc->aac_aifq_tail != sc->aac_aifq_head)
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- }
- AAC_LOCK_RELEASE(&sc->aac_aifq_lock);
-
- if (revents == 0) {
- if (ap->a_events & (POLLIN | POLLRDNORM))
- selrecord(curthread, &sc->rcv_select);
- }
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops aac_filterops =
{ 1, NULL, aac_filter_detach, aac_filter };
#include "vinumhdr.h"
#include <sys/sysproto.h> /* for sync(2) */
#include <sys/devicestat.h>
-#include <sys/poll.h>
+#include <sys/poll.h> /* XXX: poll ops used in kq filters */
#include <sys/event.h>
#ifdef VINUMDEBUG
#include <sys/reboot.h>
.d_read = physread,
.d_write = physwrite,
.d_ioctl = vinumioctl,
- .d_poll = vinumpoll,
.d_kqfilter = vinumkqfilter,
.d_strategy = vinumstrategy,
.d_dump = vinumdump,
return ENXIO;
}
-int
-vinumpoll(struct dev_poll_args *ap)
-{
- ap->a_events = seltrue(ap->a_head.a_dev, ap->a_events);
- return(0);
-}
-
void
vinumfilt_detach(struct knote *kn) {}
int
-vinumfilt(struct knote *kn, long hint)
+vinumfilt_rd(struct knote *kn, long hint)
{
cdev_t dev = (cdev_t)kn->kn_hook;
return (0);
}
-struct filterops vinumfiltops =
- { 1, NULL, vinumfilt_detach, vinumfilt };
+int
+vinumfilt_wr(struct knote *kn, long hint)
+{
+ /* Writing is always OK */
+ return (1);
+}
+
+struct filterops vinumfiltops_rd =
+ { 1, NULL, vinumfilt_detach, vinumfilt_rd };
+struct filterops vinumfiltops_wr =
+ { 1, NULL, vinumfilt_detach, vinumfilt_wr };
int
vinumkqfilter(struct dev_kqfilter_args *ap)
{
if (ap->a_kn->kn_filter == EVFILT_READ) {
- ap->a_kn->kn_fop = &vinumfiltops;
+ ap->a_kn->kn_fop = &vinumfiltops_rd;
ap->a_kn->kn_hook = (caddr_t)ap->a_head.a_dev;
ap->a_result = 0;
+ } else if (ap->a_kn->kn_filter == EVFILT_WRITE) {
+ ap->a_kn->kn_fop = &vinumfiltops_wr;
+ ap->a_result = 0;
} else {
ap->a_result = EOPNOTSUPP;
}
d_ioctl_t vinumioctl;
d_dump_t vinumdump;
d_psize_t vinumsize;
-d_poll_t vinumpoll;
d_kqfilter_t vinumkqfilter;
-int vinumfilt(struct knote *, long);
+int vinumfilt_rd(struct knote *, long);
+int vinumfilt_wr(struct knote *, long);
void vinumfilt_detach(struct knote *);
int vinumstart(cdev_t dev, struct bio *bio, int reviveok);
.d_read = ttyread,
.d_write = siowrite,
.d_ioctl = sioioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
.d_read = ttyread,
.d_write = ttywrite,
.d_ioctl = dgmioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
.d_read = digiread,
.d_write = digiwrite,
.d_ioctl = digiioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
.d_read = ttyread,
.d_write = ttywrite,
.d_ioctl = rcioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
.d_read = ttyread,
.d_write = rpwrite,
.d_ioctl = rpioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
.d_read = ttyread,
.d_write = siwrite,
.d_ioctl = siioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
.d_read = sioread,
.d_write = siowrite,
.d_ioctl = sioioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
.d_read = ttyread,
.d_write = ttywrite,
.d_ioctl = stlioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
.d_read = stliread,
.d_write = stliwrite,
.d_ioctl = stliioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
static d_read_t dsp_read;
static d_write_t dsp_write;
static d_ioctl_t dsp_ioctl;
-static d_poll_t dsp_poll;
static d_kqfilter_t dsp_kqfilter;
static d_mmap_t dsp_mmap;
.d_read = dsp_read,
.d_write = dsp_write,
.d_ioctl = dsp_ioctl,
- .d_poll = dsp_poll,
.d_kqfilter = dsp_kqfilter,
.d_mmap = dsp_mmap,
};
return ret;
}
-static int
-dsp_poll(struct dev_poll_args *ap)
-{
- struct cdev *i_dev = ap->a_head.a_dev;
- int events = ap->a_events;
- struct thread *td = curthread;
- struct pcm_channel *wrch = NULL, *rdch = NULL;
- int ret, e;
-
- ret = 0;
- getchns(i_dev, &rdch, &wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);
-
- if (wrch) {
- e = (events & (POLLOUT | POLLWRNORM));
- if (e)
- ret |= chn_poll(wrch, e, td);
- }
- if (rdch) {
- e = (events & (POLLIN | POLLRDNORM));
- if (e)
- ret |= chn_poll(rdch, e, td);
- }
- relchns(i_dev, rdch, wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);
-
- ap->a_events = ret;
- return (0);
-}
-
static struct filterops dsp_read_filtops =
{ 1, NULL, dsp_filter_detach, dsp_filter_read };
static struct filterops dsp_write_filtops =
#include <sys/select.h>
#include <sys/proc.h>
#include <sys/priv.h>
-#include <sys/poll.h>
#include <sys/sysctl.h>
#include <sys/thread2.h>
.d_read = ucomread,
.d_write = ucomwrite,
.d_ioctl = ucomioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
#include <sys/file.h>
#include <sys/select.h>
#include <sys/vnode.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/sysctl.h>
#include <sys/thread2.h>
d_read_t ugenread;
d_write_t ugenwrite;
d_ioctl_t ugenioctl;
-d_poll_t ugenpoll;
d_kqfilter_t ugenkqfilter;
static void ugen_filt_detach(struct knote *);
.d_read = ugenread,
.d_write = ugenwrite,
.d_ioctl = ugenioctl,
- .d_poll = ugenpoll,
.d_kqfilter = ugenkqfilter
};
return (error);
}
-int
-ugenpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct ugen_softc *sc;
- struct ugen_endpoint *sce_in, *sce_out;
- usb_endpoint_descriptor_t *edesc;
- int revents = 0;
-
- sc = devclass_get_softc(ugen_devclass, UGENUNIT(dev));
-
- if (sc->sc_dying) {
- return ((ap->a_events & (POLLIN | POLLOUT | POLLRDNORM |
- POLLWRNORM)) | POLLHUP);
- }
-
- /* Do not allow to poll a control endpoint */
- if (UGENENDPOINT(dev) == USB_CONTROL_ENDPOINT) {
- return (ap->a_events & (POLLIN | POLLOUT | POLLRDNORM |
- POLLWRNORM));
- }
-
- sce_in = &sc->sc_endpoints[UGENENDPOINT(dev)][IN];
- sce_out = &sc->sc_endpoints[UGENENDPOINT(dev)][OUT];
- edesc = (sce_in->edesc != NULL) ? sce_in->edesc : sce_out->edesc;
- KASSERT(edesc != NULL, ("ugenpoll: NULL edesc"));
-
- if (sce_in->edesc == NULL || sce_in->pipeh == NULL)
- sce_in = NULL;
- if (sce_out->edesc == NULL || sce_out->pipeh == NULL)
- sce_out = NULL;
-
- crit_enter();
- switch (edesc->bmAttributes & UE_XFERTYPE) {
- case UE_INTERRUPT:
- if (sce_in != NULL && (ap->a_events & (POLLIN | POLLRDNORM))) {
- if (sce_in->q.c_cc > 0)
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- else
- selrecord(curthread, &sce_in->rsel);
- }
- if (sce_out != NULL && (ap->a_events & (POLLOUT | POLLWRNORM))) {
- if (sce_out->q.c_cc > 0)
- revents |= ap->a_events & (POLLOUT | POLLWRNORM);
- else
- selrecord(curthread, &sce_out->rsel);
- }
- break;
- case UE_ISOCHRONOUS:
- if (sce_in != NULL && (ap->a_events & (POLLIN | POLLRDNORM))) {
- if (sce_in->cur != sce_in->fill)
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- else
- selrecord(curthread, &sce_in->rsel);
- }
- if (sce_out != NULL && (ap->a_events & (POLLOUT | POLLWRNORM))) {
- if (sce_out->cur != sce_out->fill)
- revents |= ap->a_events & (POLLOUT | POLLWRNORM);
- else
- selrecord(curthread, &sce_out->rsel);
- }
- break;
- case UE_BULK:
- /*
- * We have no easy way of determining if a read will
- * yield any data or a write will happen.
- * Pretend they will.
- */
- revents |= ap->a_events &
- (POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM);
- break;
- default:
- break;
- }
- crit_exit();
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops ugen_filtops_read =
{ 1, NULL, ugen_filt_detach, ugen_filt_read };
static struct filterops ugen_filtops_write =
#include <sys/select.h>
#include <sys/proc.h>
#include <sys/vnode.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/sysctl.h>
#include <sys/thread2.h>
d_read_t uhidread;
d_write_t uhidwrite;
d_ioctl_t uhidioctl;
-d_poll_t uhidpoll;
d_kqfilter_t uhidkqfilter;
static void uhidfilt_detach(struct knote *);
.d_read = uhidread,
.d_write = uhidwrite,
.d_ioctl = uhidioctl,
- .d_poll = uhidpoll,
.d_kqfilter = uhidkqfilter
};
return (error);
}
-int
-uhidpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct uhid_softc *sc;
- int revents = 0;
-
- sc = devclass_get_softc(uhid_devclass, UHIDUNIT(dev));
-
- if (sc->sc_dying)
- return (EIO);
-
- crit_enter();
- if (ap->a_events & (POLLOUT | POLLWRNORM))
- revents |= ap->a_events & (POLLOUT | POLLWRNORM);
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (sc->sc_q.c_cc > 0)
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- else
- selrecord(curthread, &sc->sc_rsel);
- }
- crit_exit();
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops uhidfiltops_read =
{ 1, NULL, uhidfilt_detach, uhidfilt_read };
static struct filterops uhidfiltops_write =
#include <sys/file.h>
#include <sys/select.h>
#include <sys/vnode.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/sysctl.h>
#include <sys/thread2.h>
static d_close_t ums_close;
static d_read_t ums_read;
static d_ioctl_t ums_ioctl;
-static d_poll_t ums_poll;
static d_kqfilter_t ums_kqfilter;
static void ums_filt_detach(struct knote *);
.d_close = ums_close,
.d_read = ums_read,
.d_ioctl = ums_ioctl,
- .d_poll = ums_poll,
.d_kqfilter = ums_kqfilter
};
return 0;
}
-static int
-ums_poll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct ums_softc *sc;
- int revents = 0;
-
- sc = devclass_get_softc(ums_devclass, UMSUNIT(dev));
-
- if (!sc) {
- ap->a_events = 0;
- return 0;
- }
-
- crit_enter();
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (sc->qcount) {
- revents = ap->a_events & (POLLIN | POLLRDNORM);
- } else {
- /* sc->state |= UMS_SELECT; */
- selrecord(curthread, &sc->rsel);
- }
- }
- crit_exit();
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops ums_filtops =
{ 1, NULL, ums_filt_detach, ums_filt };
#include <sys/file.h>
#include <sys/select.h>
#include <sys/proc.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/conf.h>
#include <sys/sysctl.h>
d_close_t uscannerclose;
d_read_t uscannerread;
d_write_t uscannerwrite;
-d_poll_t uscannerpoll;
d_kqfilter_t uscannerkqfilter;
#define USCANNER_CDEV_MAJOR 156
.d_close = uscannerclose,
.d_read = uscannerread,
.d_write = uscannerwrite,
- .d_poll = uscannerpoll,
.d_kqfilter = uscannerkqfilter
};
return (0);
}
-int
-uscannerpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct uscanner_softc *sc;
- int revents = 0;
-
- sc = devclass_get_softc(uscanner_devclass, USCANNERUNIT(dev));
-
- if (sc->sc_dying)
- return (EIO);
-
- /*
- * We have no easy way of determining if a read will
- * yield any data or a write will happen.
- * Pretend they will.
- */
- revents |= ap->a_events &
- (POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM);
-
- ap->a_events = revents;
- return (0);
-}
-
static void
uscannerfilt_detach(struct knote *kn) {}
#include <sys/signalvar.h>
#include <sys/malloc.h>
#include <sys/mman.h>
-#include <sys/poll.h>
#include <sys/select.h>
#include <sys/event.h>
#include <sys/bus.h>
static d_write_t bktr_write;
static d_ioctl_t bktr_ioctl;
static d_mmap_t bktr_mmap;
-static d_poll_t bktr_poll;
static d_kqfilter_t bktr_kqfilter;
static void bktr_filter_detach(struct knote *);
.d_read = bktr_read,
.d_write = bktr_write,
.d_ioctl = bktr_ioctl,
- .d_poll = bktr_poll,
.d_kqfilter = bktr_kqfilter,
.d_mmap = bktr_mmap,
};
return(0);
}
-static int
-bktr_poll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- int unit;
- bktr_ptr_t bktr;
- int revents = 0;
-
- unit = UNIT(minor(dev));
-
- /* Get the device data */
- bktr = (struct bktr_softc*)devclass_get_softc(bktr_devclass, unit);
- if (bktr == NULL) {
- /* the device is no longer valid/functioning */
- return (ENXIO);
- }
-
- LOCK_VBI(bktr);
- crit_enter();
-
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
-
- switch ( FUNCTION( minor(dev) ) ) {
- case VBI_DEV:
- if(bktr->vbisize == 0)
- selrecord(curthread, &bktr->vbi_select);
- else
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- break;
- }
- }
-
- crit_exit();
- UNLOCK_VBI(bktr);
-
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops bktr_filterops =
{ 1, NULL, bktr_filter_detach, bktr_filter };
#include <sys/kernel.h>
#include <sys/mman.h>
#include <sys/module.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
static d_close_t cxm_close;
static d_read_t cxm_read;
static d_ioctl_t cxm_ioctl;
-static d_poll_t cxm_poll;
static d_kqfilter_t cxm_kqfilter;
static void cxm_filter_detach(struct knote *);
.d_close = cxm_close,
.d_read = cxm_read,
.d_ioctl = cxm_ioctl,
- .d_poll = cxm_poll,
.d_kqfilter = cxm_kqfilter
};
return 0;
}
-
-int
-cxm_poll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- int revents;
- int unit;
- struct cxm_softc *sc;
-
- unit = UNIT(minor(dev));
-
- /* Get the device data */
- sc = (struct cxm_softc*)devclass_get_softc(cxm_devclass, unit);
- if (sc == NULL) {
- /* the device is no longer valid/functioning */
- return POLLHUP;
- }
-
- revents = 0;
-
- crit_enter();
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (sc->enc_pool.read == sc->enc_pool.write)
- selrecord(curthread, &sc->enc_sel);
- else
- revents = ap->a_events & (POLLIN | POLLRDNORM);
- }
- crit_exit();
-
- return revents;
-}
-
static struct filterops cxm_filterops =
{ 1, NULL, cxm_filter_detach, cxm_filter };
DEVOP_DESC_INIT(ioctl);
DEVOP_DESC_INIT(dump);
DEVOP_DESC_INIT(psize);
-DEVOP_DESC_INIT(poll);
DEVOP_DESC_INIT(mmap);
DEVOP_DESC_INIT(strategy);
DEVOP_DESC_INIT(kqfilter);
.d_read = noread,
.d_write = nowrite,
.d_ioctl = noioctl,
- .d_poll = nopoll,
.d_mmap = nommap,
.d_strategy = nostrategy,
.d_dump = nodump,
return(dev->si_ops->d_ioctl(&ap));
}
-int
-dev_dpoll(cdev_t dev, int events)
-{
- struct dev_poll_args ap;
- int error;
-
- ap.a_head.a_desc = &dev_poll_desc;
- ap.a_head.a_dev = dev;
- ap.a_events = events;
- error = dev->si_ops->d_poll(&ap);
- if (error == 0)
- return(ap.a_events);
- return (seltrue(dev, events));
-}
-
int
dev_dmmap(cdev_t dev, vm_offset_t offset, int nprot)
{
return (ENODEV);
}
-int
-nopoll(struct dev_poll_args *ap)
-{
- ap->a_events = 0;
- return(0);
-}
-
int
nostrategy(struct dev_strategy_args *ap)
{
static d_write_t mmwrite;
static d_ioctl_t mmioctl;
static d_mmap_t memmmap;
-static d_poll_t mmpoll;
static d_kqfilter_t mmkqfilter;
#define CDEV_MAJOR 2
.d_read = mmread,
.d_write = mmwrite,
.d_ioctl = mmioctl,
- .d_poll = mmpoll,
.d_kqfilter = mmkqfilter,
.d_mmap = memmmap,
};
return (error);
}
-int
-mmpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- int revents;
-
- switch (minor(dev)) {
- case 3: /* /dev/random */
- revents = random_poll(dev, ap->a_events);
- break;
- case 4: /* /dev/urandom */
- default:
- revents = seltrue(dev, ap->a_events);
- break;
- }
- ap->a_events = revents;
- return (0);
-}
-
static int
mm_filter_read(struct knote *kn, long hint)
{
#include <sys/proc.h>
#include <sys/buf.h>
#include <sys/conf.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/ioccom.h>
#include <sys/malloc.h>
static d_open_t udev_dev_open;
static d_close_t udev_dev_close;
static d_read_t udev_dev_read;
-static d_poll_t udev_dev_poll;
static d_kqfilter_t udev_dev_kqfilter;
static d_ioctl_t udev_dev_ioctl;
.d_open = udev_dev_open,
.d_close = udev_dev_close,
.d_read = udev_dev_read,
- .d_poll = udev_dev_poll,
.d_kqfilter = udev_dev_kqfilter,
.d_ioctl = udev_dev_ioctl
};
return 0;
}
-static int
-udev_dev_poll(struct dev_poll_args *ap)
-{
- int revents = 0;
-
- lockmgr(&udevctx.lock, LK_EXCLUSIVE);
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (!TAILQ_EMPTY(&udevctx.ev_queue))
- revents = ap->a_events & (POLLIN | POLLRDNORM);
- else
- selrecord(curthread, &udevctx.sel);
- }
- lockmgr(&udevctx.lock, LK_RELEASE);
-
- ap->a_events = revents;
- return 0;
-}
-
static struct filterops udev_dev_read_filtops =
{ 1, NULL, udev_dev_filter_detach, udev_dev_filter_read };
#include <sys/selinfo.h>
#include <sys/uio.h>
#include <sys/filio.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/signalvar.h>
static d_close_t devclose;
static d_read_t devread;
static d_ioctl_t devioctl;
-static d_poll_t devpoll;
static d_kqfilter_t devkqfilter;
static struct dev_ops devctl_ops = {
.d_close = devclose,
.d_read = devread,
.d_ioctl = devioctl,
- .d_poll = devpoll,
.d_kqfilter = devkqfilter
};
return (ENOTTY);
}
-static int
-devpoll(struct dev_poll_args *ap)
-{
- int revents = 0;
-
- lockmgr(&devsoftc.lock, LK_EXCLUSIVE);
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (!TAILQ_EMPTY(&devsoftc.devq))
- revents = ap->a_events & (POLLIN | POLLRDNORM);
- else
- selrecord(curthread, &devsoftc.sel);
- }
- lockmgr(&devsoftc.lock, LK_RELEASE);
-
- ap->a_events = revents;
- return (0);
-}
-
static void dev_filter_detach(struct knote *);
static int dev_filter_read(struct knote *, long);
#include <sys/msgbuf.h>
#include <sys/signalvar.h>
#include <sys/kernel.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/filedesc.h>
#include <sys/sysctl.h>
static d_close_t logclose;
static d_read_t logread;
static d_ioctl_t logioctl;
-static d_poll_t logpoll;
static d_kqfilter_t logkqfilter;
static void logtimeout(void *arg);
.d_close = logclose,
.d_read = logread,
.d_ioctl = logioctl,
- .d_poll = logpoll,
.d_kqfilter = logkqfilter
};
return (error);
}
-/*ARGSUSED*/
-static int
-logpoll(struct dev_poll_args *ap)
-{
- int revents = 0;
-
- crit_enter();
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (msgbufp->msg_bufr != msgbufp->msg_bufx)
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- else
- selrecord(curthread, &logsoftc.sc_selp);
- }
- crit_exit();
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops logread_filtops =
{ 1, NULL, logfiltdetach, logfiltread };
#include <sys/fcntl.h>
#include <sys/conf.h>
#include <sys/dkstat.h>
-#include <sys/poll.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
#include <sys/signalvar.h>
return (0);
}
-int
-ttypoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- int events = ap->a_events;
- int revents = 0;
- struct tty *tp;
-
- tp = dev->si_tty;
- /* XXX used to return ENXIO, but that means true! */
- if (tp == NULL) {
- ap->a_events = (events & (POLLIN | POLLOUT | POLLRDNORM |
- POLLWRNORM)) | POLLHUP;
- return(0);
- }
-
- crit_enter();
- if (events & (POLLIN | POLLRDNORM)) {
- if (ttnread(tp) > 0 || ISSET(tp->t_state, TS_ZOMBIE))
- revents |= events & (POLLIN | POLLRDNORM);
- else
- selrecord(curthread, &tp->t_rsel);
- }
- if (events & (POLLOUT | POLLWRNORM)) {
- if ((tp->t_outq.c_cc <= tp->t_olowat &&
- ISSET(tp->t_state, TS_CONNECTED))
- || ISSET(tp->t_state, TS_ZOMBIE))
- revents |= events & (POLLOUT | POLLWRNORM);
- else
- selrecord(curthread, &tp->t_wsel);
- }
- crit_exit();
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops ttyread_filtops =
{ 1, NULL, filt_ttyrdetach, filt_ttyread };
static struct filterops ttywrite_filtops =
static d_read_t cnread;
static d_write_t cnwrite;
static d_ioctl_t cnioctl;
-static d_poll_t cnpoll;
static d_kqfilter_t cnkqfilter;
static int cnintercept(struct dev_generic_args *ap);
.d_read = cnread,
.d_write = cnwrite,
.d_ioctl = cnioctl,
- .d_poll = cnpoll,
.d_kqfilter = cnkqfilter,
};
return (dev_doperate(&ap->a_head));
}
-static int
-cnpoll(struct dev_poll_args *ap)
-{
- if ((cn_tab == NULL) || cn_mute || cn_fwd_ops == NULL)
- return (1);
- ap->a_head.a_dev = cn_tab->cn_dev;
- return (dev_doperate(&ap->a_head));
-}
-
static int
cnkqfilter(struct dev_kqfilter_args *ap)
{
#include <sys/tty.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
-#include <sys/poll.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
#include <sys/signalvar.h>
static d_close_t ptcclose;
static d_read_t ptcread;
static d_write_t ptcwrite;
-static d_poll_t ptcpoll;
static d_kqfilter_t ptckqfilter;
#ifdef UNIX98_PTYS
.d_read = ptsread,
.d_write = ptswrite,
.d_ioctl = ptyioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
.d_read = ptcread,
.d_write = ptcwrite,
.d_ioctl = ptyioctl,
- .d_poll = ptcpoll,
.d_kqfilter = ptckqfilter,
.d_revoke = ttyrevoke
};
.d_read = ptsread,
.d_write = ptswrite,
.d_ioctl = ptyioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
.d_revoke = ttyrevoke
};
.d_read = ptcread,
.d_write = ptcwrite,
.d_ioctl = ptyioctl,
- .d_poll = ptcpoll,
.d_kqfilter = ptckqfilter,
.d_revoke = ttyrevoke
};
ptcwakeup(tp, flag);
}
-static int
-ptcpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct tty *tp = dev->si_tty;
- struct pt_ioctl *pti = dev->si_drv1;
- int revents = 0;
-
- if ((tp->t_state & TS_CONNECTED) == 0) {
- ap->a_events = seltrue(dev, ap->a_events) | POLLHUP;
- return(0);
- }
-
- /*
- * Need to block timeouts (ttrstart).
- */
- crit_enter();
-
- if (ap->a_events & (POLLIN | POLLRDNORM))
- if ((tp->t_state & TS_ISOPEN) &&
- ((tp->t_outq.c_cc && (tp->t_state & TS_TTSTOP) == 0) ||
- ((pti->pt_flags & PF_PKT) && pti->pt_send) ||
- ((pti->pt_flags & PF_UCNTL) && pti->pt_ucntl)))
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
-
- if (ap->a_events & (POLLOUT | POLLWRNORM))
- if (tp->t_state & TS_ISOPEN &&
- ((pti->pt_flags & PF_REMOTE) ?
- (tp->t_canq.c_cc == 0) :
- ((tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG - 2) ||
- (tp->t_canq.c_cc == 0 && (tp->t_lflag & ICANON)))))
- revents |= ap->a_events & (POLLOUT | POLLWRNORM);
-
- if (ap->a_events & POLLHUP)
- if ((tp->t_state & TS_CARR_ON) == 0)
- revents |= POLLHUP;
-
- if (revents == 0) {
- if (ap->a_events & (POLLIN | POLLRDNORM))
- selrecord(curthread, &pti->pt_selr);
-
- if (ap->a_events & (POLLOUT | POLLWRNORM))
- selrecord(curthread, &pti->pt_selw);
- }
- crit_exit();
-
- ap->a_events = revents;
- return (0);
-}
-
/*
* kqueue ops for pseudo-terminals.
*/
#include <sys/ttycom.h>
#include <sys/vnode.h>
#include <sys/kernel.h>
+#include <sys/poll.h> /* XXX: poll args used in KQ filters */
#include <sys/event.h>
-#include <sys/poll.h>
static d_open_t cttyopen;
static d_close_t cttyclose;
static d_read_t cttyread;
static d_write_t cttywrite;
static d_ioctl_t cttyioctl;
-static d_poll_t cttypoll;
static d_kqfilter_t cttykqfilter;
static void cttyfilt_detach(struct knote *);
.d_read = cttyread,
.d_write = cttywrite,
.d_ioctl = cttyioctl,
- .d_poll = cttypoll,
.d_kqfilter = cttykqfilter
};
ap->a_cred, ap->a_sysmsg));
}
-/*ARGSUSED*/
-static int
-cttypoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct vnode *ttyvp;
- struct proc *p = curproc;
-
- KKASSERT(p);
- ttyvp = cttyvp(p);
- /*
- * try operation to get EOF/failure
- */
- if (ttyvp == NULL)
- ap->a_events = seltrue(dev, ap->a_events);
- else
- ap->a_events = VOP_POLL(ttyvp, ap->a_events, p->p_ucred);
- return(0);
-}
-
static struct filterops cttyfiltops_read =
{ 1, NULL, cttyfilt_detach, cttyfilt_read };
static struct filterops cttyfiltops_write =
#include <sys/ttycom.h>
#include <sys/filedesc.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/socket.h>
static d_read_t bpfread;
static d_write_t bpfwrite;
static d_ioctl_t bpfioctl;
-static d_poll_t bpfpoll;
static d_kqfilter_t bpfkqfilter;
#define CDEV_MAJOR 23
.d_read = bpfread,
.d_write = bpfwrite,
.d_ioctl = bpfioctl,
- .d_poll = bpfpoll,
.d_kqfilter = bpfkqfilter
};
return(ENXIO);
}
-/*
- * Support for select() and poll() system calls
- *
- * Return true iff the specific operation will not block indefinitely.
- * Otherwise, return false but make a note that a selwakeup() must be done.
- */
-static int
-bpfpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct bpf_d *d;
- int revents;
-
- d = dev->si_drv1;
- if (d->bd_bif == NULL)
- return(ENXIO);
-
- revents = ap->a_events & (POLLOUT | POLLWRNORM);
- crit_enter();
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- /*
- * An imitation of the FIONREAD ioctl code.
- * XXX not quite. An exact imitation:
- * if (d->b_slen != 0 ||
- * (d->bd_hbuf != NULL && d->bd_hlen != 0)
- */
- if (d->bd_hlen != 0 ||
- ((d->bd_immediate || d->bd_state == BPF_TIMED_OUT) &&
- d->bd_slen != 0)) {
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- } else {
- selrecord(curthread, &d->bd_sel);
- /* Start the read timeout if necessary. */
- if (d->bd_rtout > 0 && d->bd_state == BPF_IDLE) {
- callout_reset(&d->bd_callout, d->bd_rtout,
- bpf_timed_out, d);
- d->bd_state = BPF_WAITING;
- }
- }
- }
- crit_exit();
- ap->a_events = revents;
- return(0);
-}
-
static struct filterops bpf_read_filtops =
{ 1, NULL, bpf_filter_detach, bpf_filter_read };
static d_close_t i4bctlclose;
static d_ioctl_t i4bctlioctl;
-static d_poll_t i4bctlpoll;
-#define POLLFIELD i4bctlpoll
-
#define CDEV_MAJOR 55
static struct dev_ops i4bctl_ops = {
.d_open = i4bctlopen,
.d_close = i4bctlclose,
.d_ioctl = i4bctlioctl,
- .d_poll = POLLFIELD,
};
static void i4bctlattach(void *);
#endif /* DO_I4B_DEBUG */
}
-/*---------------------------------------------------------------------------*
- * i4bctlpoll - device driver poll routine
- *---------------------------------------------------------------------------*/
-static int
-i4bctlpoll (struct dev_poll_args *ap)
-{
- return (ENODEV);
-}
-
#endif /* NI4BCTL > 0 */
#include "../include/i4b_l3l4.h"
#include "../layer4/i4b_l4.h"
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/filio.h>
PDEVSTATIC int i4brbchkfilt_read(struct knote *, long);
PDEVSTATIC int i4brbchkfilt_write(struct knote *, long);
-PDEVSTATIC d_poll_t i4brbchpoll;
-#define POLLFIELD i4brbchpoll
-
#define CDEV_MAJOR 57
static struct dev_ops i4brbch_ops = {
.d_read = i4brbchread,
.d_write = i4brbchwrite,
.d_ioctl = i4brbchioctl,
- .d_poll = POLLFIELD,
.d_kqfilter = i4brbchkqfilter
};
/*---------------------------------------------------------------------------*
* device driver poll
*---------------------------------------------------------------------------*/
-PDEVSTATIC int
-i4brbchpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- int revents = 0; /* Events we found */
- int unit = minor(dev);
- struct rbch_softc *sc = &rbch_softc[unit];
-
- /* We can't check for anything but IN or OUT */
- crit_enter();
-
- if(!(sc->sc_devstate & ST_ISOPEN))
- {
- crit_exit();
- return(POLLNVAL);
- }
-
- /*
- * Writes are OK if we are connected and the
- * transmit queue can take them
- */
-
- if((ap->a_events & (POLLOUT|POLLWRNORM)) &&
- (sc->sc_devstate & ST_CONNECTED) &&
- !IF_QFULL(isdn_linktab[unit]->tx_queue))
- {
- revents |= (ap->a_events & (POLLOUT|POLLWRNORM));
- }
-
- /* ... while reads are OK if we have any data */
-
- if((ap->a_events & (POLLIN|POLLRDNORM)) &&
- (sc->sc_devstate & ST_CONNECTED))
- {
- struct ifqueue *iqp;
-
- if(sc->sc_bprot == BPROT_RHDLC)
- iqp = &sc->sc_hdlcq;
- else
- iqp = isdn_linktab[unit]->rx_queue;
-
- if(!IF_QEMPTY(iqp))
- revents |= (ap->a_events & (POLLIN|POLLRDNORM));
- }
-
- if(revents == 0)
- selrecord(curthread, &sc->selp);
-
- crit_exit();
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops i4brbchkfiltops_read =
{ 1, NULL, i4brbchkfilt_detach, i4brbchkfilt_read };
static struct filterops i4brbchkfiltops_write =
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/conf.h>
PDEVSTATIC d_ioctl_t i4btelioctl;
PDEVSTATIC d_kqfilter_t i4btelkqfilter;
-PDEVSTATIC d_poll_t i4btelpoll;
-#define POLLFIELD i4btelpoll
-
PDEVSTATIC void i4btelfilt_detach(struct knote *);
PDEVSTATIC int i4btelfilt_read(struct knote *, long);
PDEVSTATIC int i4btelfilt_write(struct knote *, long);
.d_read = i4btelread,
.d_write = i4btelwrite,
.d_ioctl = i4btelioctl,
- .d_poll = POLLFIELD,
.d_kqfilter = i4btelkqfilter
};
/*---------------------------------------------------------------------------*
* device driver poll
*---------------------------------------------------------------------------*/
-PDEVSTATIC int
-i4btelpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- int revents = 0; /* Events we found */
- int unit = UNIT(dev);
- int func = FUNC(dev);
-
- tel_sc_t *sc = &tel_sc[unit][func];
-
- crit_enter();
-
- if(!(sc->devstate & ST_ISOPEN))
- {
- NDBGL4(L4_TELDBG, "i4btel%d, !ST_ISOPEN", unit);
- crit_exit();
- ap->a_events = 0;
- return(0);
- }
-
- if(func == FUNCTEL)
- {
- /*
- * Writes are OK if we are connected and the
- * transmit queue can take them
- */
-
- if((ap->a_events & (POLLOUT|POLLWRNORM)) &&
- (sc->devstate & ST_CONNECTED) &&
- (sc->isdn_linktab != NULL) &&
- (!IF_QFULL(sc->isdn_linktab->tx_queue)))
- {
- NDBGL4(L4_TELDBG, "i4btel%d, POLLOUT", unit);
- revents |= (ap->a_events & (POLLOUT|POLLWRNORM));
- }
-
- /* ... while reads are OK if we have any data */
-
- if((ap->a_events & (POLLIN|POLLRDNORM)) &&
- (sc->devstate & ST_CONNECTED) &&
- (sc->isdn_linktab != NULL) &&
- (!IF_QEMPTY(sc->isdn_linktab->rx_queue)))
- {
- NDBGL4(L4_TELDBG, "i4btel%d, POLLIN", unit);
- revents |= (ap->a_events & (POLLIN|POLLRDNORM));
- }
-
- if(revents == 0)
- {
- NDBGL4(L4_TELDBG, "i4btel%d, selrecord", unit);
- selrecord(curthread, &sc->selp);
- }
- }
- else if(func == FUNCDIAL)
- {
- if(ap->a_events & (POLLOUT|POLLWRNORM))
- {
- NDBGL4(L4_TELDBG, "i4bteld%d, POLLOUT", unit);
- revents |= (ap->a_events & (POLLOUT|POLLWRNORM));
- }
-
- if(ap->a_events & (POLLIN|POLLRDNORM))
- {
- NDBGL4(L4_TELDBG, "i4bteld%d, POLLIN, result = %d", unit, sc->result);
- if(sc->result != 0)
- revents |= (ap->a_events & (POLLIN|POLLRDNORM));
- }
-
- if(revents == 0)
- {
- NDBGL4(L4_TELDBG, "i4bteld%d, selrecord", unit);
- selrecord(curthread, &sc->selp);
- }
- }
- crit_exit();
- ap->a_events = revents;
- return (0);
-}
-
PDEVSTATIC struct filterops i4btelfiltops_read =
{ 1, NULL, i4btelfilt_detach, i4btelfilt_read };
PDEVSTATIC struct filterops i4btelfiltops_write =
static d_read_t i4btrcread;
static d_ioctl_t i4btrcioctl;
-static d_poll_t i4btrcpoll;
-#define POLLFIELD i4btrcpoll
-
#define CDEV_MAJOR 59
static struct dev_ops i4btrc_ops = {
.d_close = i4btrcclose,
.d_read = i4btrcread,
.d_ioctl = i4btrcioctl,
- .d_poll = POLLFIELD,
};
/*---------------------------------------------------------------------------*
return(error);
}
-/*---------------------------------------------------------------------------*
- * poll device
- *---------------------------------------------------------------------------*/
-PDEVSTATIC int
-i4btrcpoll(struct dev_poll_args *ap)
-{
- return(ENODEV);
-}
-
/*---------------------------------------------------------------------------*
* device driver ioctl routine
*---------------------------------------------------------------------------*/
#include "i4b_l4.h"
-#include <sys/poll.h>
#include <sys/event.h>
struct selinfo select_rd_info;
PDEVSTATIC int i4bkqfilt_read(struct knote *, long);
PDEVSTATIC int i4bkqfilt_write(struct knote *, long);
-PDEVSTATIC d_poll_t i4bpoll;
-#define POLLFIELD i4bpoll
-
#define CDEV_MAJOR 60
static struct dev_ops i4b_ops = {
.d_close = i4bclose,
.d_read = i4bread,
.d_ioctl = i4bioctl,
- .d_poll = POLLFIELD,
.d_kqfilter = i4bkqfilter
};
}
/*---------------------------------------------------------------------------*
- * i4bpoll - device driver poll routine
+ * i4bkqfilter - device driver poll routine
*---------------------------------------------------------------------------*/
-PDEVSTATIC int
-i4bpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- int revents;
-
- if (minor(dev))
- return(ENODEV);
-
- revents = 0;
-
- if (ap->a_events & (POLLIN|POLLRDNORM)) {
- crit_enter();
- if (!IF_QEMPTY(&i4b_rdqueue)) {
- revents |= POLLIN | POLLRDNORM;
- } else {
- selrecord(curthread, &select_rd_info);
- }
- crit_exit();
- return(0);
- }
- if (ap->a_events & (POLLOUT|POLLWRNORM)) {
- revents |= ap->a_events & (POLLOUT | POLLWRNORM);
- }
- ap->a_events = revents;
- return(0);
-}
-
static struct filterops i4bkqfiltops_read =
{ 1, NULL, i4bkqfilt_detach, i4bkqfilt_read };
static struct filterops i4bkqfiltops_write =
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
-#include <sys/poll.h>
#include <sys/proc.h>
#include <sys/priv.h>
#include <sys/signalvar.h>
static d_read_t tapread;
static d_write_t tapwrite;
static d_ioctl_t tapioctl;
-static d_poll_t tappoll;
static d_kqfilter_t tapkqfilter;
static struct dev_ops tap_ops = {
.d_read = tapread,
.d_write = tapwrite,
.d_ioctl = tapioctl,
- .d_poll = tappoll,
.d_kqfilter = tapkqfilter
};
return (0);
}
-/*
- * tappoll
- *
- * The poll interface, this is only useful on reads really. The write
- * detect always returns true, write never blocks anyway, it either
- * accepts the packet or drops it
- *
- * Called from the fileops interface with nothing held.
- *
- * MPSAFE
- */
-static int
-tappoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct tap_softc *tp = dev->si_drv1;
- struct ifnet *ifp = &tp->tap_if;
- int revents = 0;
-
- TAPDEBUG(ifp, "polling, minor = %#x\n", minor(tp->tap_dev));
-
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (!IF_QEMPTY(&tp->tap_devq)) {
- TAPDEBUG(ifp,
- "has data in queue. minor = %#x\n",
- minor(tp->tap_dev));
-
- revents |= (ap->a_events & (POLLIN | POLLRDNORM));
- } else {
- TAPDEBUG(ifp, "waiting for data, minor = %#x\n",
- minor(tp->tap_dev));
-
- get_mplock();
- selrecord(curthread, &tp->tap_rsel);
- rel_mplock();
- }
- }
-
- if (ap->a_events & (POLLOUT | POLLWRNORM))
- revents |= (ap->a_events & (POLLOUT | POLLWRNORM));
- ap->a_events = revents;
- return (0);
-}
-
/*
* tapkqfilter - called from the fileops interface with nothing held
*
#include <sys/sockio.h>
#include <sys/thread2.h>
#include <sys/ttycom.h>
-#include <sys/poll.h>
#include <sys/signalvar.h>
#include <sys/filedesc.h>
#include <sys/kernel.h>
static d_read_t tunread;
static d_write_t tunwrite;
static d_ioctl_t tunioctl;
-static d_poll_t tunpoll;
static d_kqfilter_t tunkqfilter;
static d_clone_t tunclone;
.d_read = tunread,
.d_write = tunwrite,
.d_ioctl = tunioctl,
- .d_poll = tunpoll,
.d_kqfilter = tunkqfilter
};
return (0);
}
-/*
- * tunpoll - the poll interface, this is only useful on reads
- * really. The write detect always returns true, write never blocks
- * anyway, it either accepts the packet or drops it.
- */
-static int
-tunpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- struct tun_softc *tp = dev->si_drv1;
- struct ifnet *ifp = &tp->tun_if;
- int revents = 0;
-
- TUNDEBUG(ifp, "tunpoll\n");
-
- ifnet_serialize_all(ifp);
-
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (!ifq_is_empty(&ifp->if_snd)) {
- TUNDEBUG(ifp, "tunpoll q=%d\n", ifp->if_snd.ifq_len);
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- } else {
- TUNDEBUG(ifp, "tunpoll waiting\n");
- selrecord(curthread, &tp->tun_rsel);
- }
- }
- if (ap->a_events & (POLLOUT | POLLWRNORM))
- revents |= ap->a_events & (POLLOUT | POLLWRNORM);
-
- ifnet_deserialize_all(ifp);
- ap->a_events = revents;
- return(0);
-}
-
static struct filterops tun_read_filtops =
{ 1, NULL, tun_filter_detach, tun_filter_read };
static struct filterops tun_write_filtops =
#include <sys/fcntl.h>
#include <sys/malloc.h>
#include <sys/file.h> /* Must come after sys/malloc.h */
-#include <sys/poll.h>
#include <sys/proc.h>
#include <sys/select.h>
#include <sys/socket.h>
static d_read_t nsmb_dev_read;
static d_write_t nsmb_dev_write;
static d_ioctl_t nsmb_dev_ioctl;
-static d_poll_t nsmb_dev_poll;
static d_clone_t nsmbclone;
DEVFS_DECLARE_CLONE_BITMAP(nsmb);
.d_read = nsmb_dev_read,
.d_write = nsmb_dev_write,
.d_ioctl = nsmb_dev_ioctl,
- .d_poll = nsmb_dev_poll,
};
return EACCES;
}
-static int
-nsmb_dev_poll(struct dev_poll_args *ap)
-{
- return ENODEV;
-}
-
static int
nsmbclone(struct dev_clone_args *ap)
{
static d_close_t apmclose;
static d_write_t apmwrite;
static d_ioctl_t apmioctl;
-static d_poll_t apmpoll;
static d_kqfilter_t apmkqfilter;
#define CDEV_MAJOR 39
.d_close = apmclose,
.d_write = apmwrite,
.d_ioctl = apmioctl,
- .d_poll = apmpoll,
.d_kqfilter = apmkqfilter
};
return (ap->a_uio->uio_resid);
}
-static int
-apmpoll(struct dev_poll_args *ap)
-{
- ap->a_events = 0;
- return (0);
-}
-
static void apmfilter_detach(struct knote *);
static int apmfilter(struct knote *, long);
#include <sys/reboot.h>
#include <sys/bus.h>
#include <sys/selinfo.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/fcntl.h>
#include <sys/uio.h>
static d_close_t apmclose;
static d_write_t apmwrite;
static d_ioctl_t apmioctl;
-static d_poll_t apmpoll;
static d_kqfilter_t apmkqfilter;
static void apmfilter_detach(struct knote *);
-static int apmfilter(struct knote *, long);
+static int apmfilter_read(struct knote *, long);
+static int apmfilter_write(struct knote *, long);
#define CDEV_MAJOR 39
static struct dev_ops apm_ops = {
.d_close = apmclose,
.d_write = apmwrite,
.d_ioctl = apmioctl,
- .d_poll = apmpoll,
.d_kqfilter = apmkqfilter
};
return uio->uio_resid;
}
-static int
-apmpoll(struct dev_poll_args *ap)
-{
- struct apm_softc *sc = &apm_softc;
- int revents = 0;
-
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (sc->event_count) {
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- } else {
- selrecord(curthread, &sc->sc_rsel);
- }
- }
- ap->a_events = revents;
- return (0);
-}
-
-static struct filterops apmfiltops =
- { 1, NULL, apmfilter_detach, apmfilter };
+static struct filterops apmfiltops_read =
+ { 1, NULL, apmfilter_detach, apmfilter_read };
+static struct filterops apmfiltops_write =
+ { 1, NULL, apmfilter_detach, apmfilter_write };
static int
apmkqfilter(struct dev_kqfilter_args *ap)
switch (kn->kn_filter) {
case EVFILT_READ:
- kn->kn_fop = &apmfiltops;
+ kn->kn_fop = &apmfiltops_read;
+ kn->kn_hook = (caddr_t)sc;
+ break;
+ case EVFILT_WRITE:
+ kn->kn_fop = &apmfiltops_write;
kn->kn_hook = (caddr_t)sc;
break;
default:
}
static int
-apmfilter(struct knote *kn, long hint)
+apmfilter_read(struct knote *kn, long hint)
{
struct apm_softc *sc = (struct apm_softc *)kn->kn_hook;
int ready = 0;
return (ready);
}
+static int
+apmfilter_write(struct knote *kn, long hint)
+{
+ /* write()'s are always OK */
+ return (1);
+}
+
/*
* Because apm is a static device that always exists under any attached
* isa device, and not scanned by the isa device, we need an identify
/* read */ ttyread,
/* write */ ttywrite,
/* ioctl */ dgbioctl,
- /* poll */ ttypoll,
/* mmap */ nommap,
/* strategy */ nostrategy,
/* dump */ nodump,
#include <sys/buf.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/selinfo.h>
#include <sys/uio.h>
static d_close_t ascclose;
static d_read_t ascread;
static d_ioctl_t ascioctl;
-static d_poll_t ascpoll;
static d_kqfilter_t asckqfilter;
static void ascfilter_detach(struct knote *kn);
.d_close = ascclose,
.d_read = ascread,
.d_ioctl = ascioctl,
- .d_poll = ascpoll,
.d_kqfilter = asckqfilter
};
return SUCCESS;
}
-STATIC int
-ascpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- int unit = UNIT(minor(dev));
- struct asc_unit *scu = unittab + unit;
- int revents = 0;
-
- crit_enter();
-
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (scu->sbuf.count >0)
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- else {
- if (!(scu->flags & DMA_ACTIVE))
- dma_restart(scu);
-
- selrecord(curthread, &scu->selp);
- }
- }
- crit_exit();
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops ascfiltops =
{ 1, NULL, ascfilter_detach, ascfilter };
static d_close_t apmclose;
static d_write_t apmwrite;
static d_ioctl_t apmioctl;
-static d_poll_t apmpoll;
static d_kqfilter_t apmkqfilter;
#define CDEV_MAJOR 39
.d_close = apmclose,
.d_write = apmwrite,
.d_ioctl = apmioctl,
- .d_poll = apmpoll,
.d_kqfilter = apmkqfilter
};
return (ap->a_uio->uio_resid);
}
-static int
-apmpoll(struct dev_poll_args *ap)
-{
- ap->a_events = 0;
- return (0);
-}
-
static void apmfilter_detach(struct knote *);
static int apmfilter(struct knote *, long);
#include <sys/reboot.h>
#include <sys/bus.h>
#include <sys/selinfo.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/fcntl.h>
#include <sys/uio.h>
static d_close_t apmclose;
static d_write_t apmwrite;
static d_ioctl_t apmioctl;
-static d_poll_t apmpoll;
static d_kqfilter_t apmkqfilter;
static void apmfilter_detach(struct knote *);
-static int apmfilter(struct knote *, long);
+static int apmfilter_read(struct knote *, long);
+static int apmfilter_write(struct knote *, long);
#define CDEV_MAJOR 39
static struct dev_ops apm_ops = {
.d_close = apmclose,
.d_write = apmwrite,
.d_ioctl = apmioctl,
- .d_poll = apmpoll,
.d_kqfilter = apmkqfilter
};
return uio->uio_resid;
}
-static int
-apmpoll(struct dev_poll_args *ap)
-{
- struct apm_softc *sc = &apm_softc;
- int revents = 0;
-
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (sc->event_count) {
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- } else {
- selrecord(curthread, &sc->sc_rsel);
- }
- }
- ap->a_events = revents;
- return (0);
-}
-
-static struct filterops apmfiltops =
- { 1, NULL, apmfilter_detach, apmfilter };
+static struct filterops apmfiltops_read =
+ { 1, NULL, apmfilter_detach, apmfilter_read };
+static struct filterops apmfiltops_write =
+ { 1, NULL, apmfilter_detach, apmfilter_write };
static int
apmkqfilter(struct dev_kqfilter_args *ap)
switch (kn->kn_filter) {
case EVFILT_READ:
- kn->kn_fop = &apmfiltops;
+ kn->kn_fop = &apmfiltops_read;
+ kn->kn_hook = (caddr_t)sc;
+ break;
+ case EVFILT_WRITE:
+ kn->kn_fop = &apmfiltops_write;
kn->kn_hook = (caddr_t)sc;
break;
default:
}
static int
-apmfilter(struct knote *kn, long hint)
+apmfilter_read(struct knote *kn, long hint)
{
struct apm_softc *sc = (struct apm_softc *)kn->kn_hook;
int ready = 0;
return (ready);
}
+static int
+apmfilter_write(struct knote *kn, long hint)
+{
+ /* write()'s are always OK */
+ return (1);
+}
+
/*
* Because apm is a static device that always exists under any attached
* isa device, and not scanned by the isa device, we need an identify
#include <sys/buf.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
-#include <sys/poll.h>
#include <sys/event.h>
#include <sys/selinfo.h>
#include <sys/uio.h>
static d_close_t ascclose;
static d_read_t ascread;
static d_ioctl_t ascioctl;
-static d_poll_t ascpoll;
static d_kqfilter_t asckqfilter;
static void ascfilter_detach(struct knote *kn);
.d_close = ascclose,
.d_read = ascread,
.d_ioctl = ascioctl,
- .d_poll = ascpoll,
.d_kqfilter = asckqfilter
};
return SUCCESS;
}
-STATIC int
-ascpoll(struct dev_poll_args *ap)
-{
- cdev_t dev = ap->a_head.a_dev;
- int unit = UNIT(minor(dev));
- struct asc_unit *scu = unittab + unit;
- int revents = 0;
-
- crit_enter();
-
- if (ap->a_events & (POLLIN | POLLRDNORM)) {
- if (scu->sbuf.count >0)
- revents |= ap->a_events & (POLLIN | POLLRDNORM);
- else {
- if (!(scu->flags & DMA_ACTIVE))
- dma_restart(scu);
-
- selrecord(curthread, &scu->selp);
- }
- }
- crit_exit();
- ap->a_events = revents;
- return (0);
-}
-
static struct filterops ascfiltops =
{ 1, NULL, ascfilter_detach, ascfilter };
.d_read = ttyread,
.d_write = ttywrite,
.d_ioctl = vcons_ioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter,
};
.d_read = ttyread,
.d_write = ttywrite,
.d_ioctl = vcons_ioctl,
- .d_poll = ttypoll,
.d_kqfilter = ttykqfilter
};
struct sysmsg *a_sysmsg;
};
-/*
- * int d_poll(cdev_t dev, int events)
- */
-struct dev_poll_args {
- struct dev_generic_args a_head;
- int a_events;
-};
-
/*
* int d_mmap(cdev_t dev, vm_offset_t offset, int nprot)
*/
typedef int d_read_t (struct dev_read_args *ap);
typedef int d_write_t (struct dev_write_args *ap);
typedef int d_ioctl_t (struct dev_ioctl_args *ap);
-typedef int d_poll_t (struct dev_poll_args *ap);
typedef int d_mmap_t (struct dev_mmap_args *ap);
typedef int d_strategy_t (struct dev_strategy_args *ap);
typedef int d_dump_t (struct dev_dump_args *ap);
d_read_t *d_read;
d_write_t *d_write;
d_ioctl_t *d_ioctl;
- d_poll_t *d_poll;
d_mmap_t *d_mmap;
d_strategy_t *d_strategy;
d_dump_t *d_dump;
struct dev_read_args du_read;
struct dev_write_args du_write;
struct dev_ioctl_args du_ioctl;
- struct dev_poll_args du_poll;
struct dev_mmap_args du_mmap;
struct dev_strategy_args du_strategy;
struct dev_dump_args du_dump;
int64_t dev_dpsize(cdev_t dev);
int dev_dread(cdev_t dev, struct uio *uio, int ioflag);
int dev_dwrite(cdev_t dev, struct uio *uio, int ioflag);
-int dev_dpoll(cdev_t dev, int events);
int dev_dkqfilter(cdev_t dev, struct knote *kn);
int dev_dmmap(cdev_t dev, vm_offset_t offset, int nprot);
int dev_dclone(cdev_t dev);
d_read_t noread;
d_write_t nowrite;
d_ioctl_t noioctl;
-d_poll_t nopoll;
d_mmap_t nommap;
d_strategy_t nostrategy;
d_dump_t nodump;
extern struct syslink_desc dev_ioctl_desc;
extern struct syslink_desc dev_dump_desc;
extern struct syslink_desc dev_psize_desc;
-extern struct syslink_desc dev_poll_desc;
extern struct syslink_desc dev_mmap_desc;
extern struct syslink_desc dev_strategu_desc;
extern struct syslink_desc dev_kqfilter_desc;
struct tty *ttymalloc (struct tty *tp);
int ttymodem (struct tty *tp, int flag);
int ttyopen (cdev_t device, struct tty *tp);
-int ttypoll (struct dev_poll_args *);
int ttykqfilter (struct dev_kqfilter_args *);
int ttyread (struct dev_read_args *);
void ttyregister (struct tty *tp);
static int devfs_spec_read(struct vop_read_args *);
static int devfs_spec_write(struct vop_write_args *);
static int devfs_spec_ioctl(struct vop_ioctl_args *);
-static int devfs_spec_poll(struct vop_poll_args *);
static int devfs_spec_kqfilter(struct vop_kqfilter_args *);
static int devfs_spec_strategy(struct vop_strategy_args *);
static void devfs_spec_strategy_done(struct bio *);
static int devfs_specf_write(struct file *, struct uio *, struct ucred *, int);
static int devfs_specf_stat(struct file *, struct stat *, struct ucred *);
static int devfs_specf_kqfilter(struct file *, struct knote *);
-static int devfs_specf_poll(struct file *, int, struct ucred *);
static int devfs_specf_ioctl(struct file *, u_long, caddr_t,
struct ucred *, struct sysmsg *);
static __inline int sequential_heuristic(struct uio *, struct file *);
.vop_open = devfs_spec_open,
.vop_pathconf = vop_stdpathconf,
.vop_print = devfs_print,
- .vop_poll = devfs_spec_poll,
.vop_kqfilter = devfs_spec_kqfilter,
.vop_read = devfs_spec_read,
.vop_readdir = DEVFS_BADOP,
.fo_read = devfs_specf_read,
.fo_write = devfs_specf_write,
.fo_ioctl = devfs_specf_ioctl,
- .fo_poll = devfs_specf_poll,
.fo_kqfilter = devfs_specf_kqfilter,
.fo_stat = devfs_specf_stat,
.fo_close = devfs_specf_close,
return (error);
}
-
-static int
-devfs_specf_poll(struct file *fp, int events, struct ucred *cred)
-{
- struct devfs_node *node;
- struct vnode *vp;
- int error;
- cdev_t dev;
-
- get_mplock();
-
- vp = (struct vnode *)fp->f_data;
- if (vp == NULL || vp->v_type == VBAD) {
- error = EBADF;
- goto done;
- }
- node = DEVFS_NODE(vp);
-
- if ((dev = vp->v_rdev) == NULL) {
- error = EBADF;
- goto done;
- }
- reference_dev(dev);
- error = dev_dpoll(dev, events);
-
- release_dev(dev);
-
-#if 0
- if (node)
- nanotime(&node->atime);
-#endif
-done:
- rel_mplock();
- return (error);
-}
-
-
/*
* MPALMOSTSAFE - acquires mplock
*/
ap->a_cred, ap->a_sysmsg));
}
-/*
- * spec_poll(struct vnode *a_vp, int a_events, struct ucred *a_cred)
- */
-/* ARGSUSED */
-static int
-devfs_spec_poll(struct vop_poll_args *ap)
-{
- struct vnode *vp = ap->a_vp;
- struct devfs_node *node;
- cdev_t dev;
-
- if ((dev = vp->v_rdev) == NULL)
- return (EBADF); /* device was revoked */
- node = DEVFS_NODE(vp);
-
-#if 0
- if (node)
- nanotime(&node->atime);
-#endif
-
- return (dev_dpoll(dev, ap->a_events));
-}
-
/*
* spec_kqfilter(struct vnode *a_vp, struct knote *a_kn)
*/