From 163625b9bf04f32ec3cbbaef7e6b242aeb8a152c Mon Sep 17 00:00:00 2001 From: "Samuel J. Greear" Date: Sun, 11 Jul 2010 16:23:55 +0000 Subject: [PATCH] kernel - Tear out device polling * Remove existing (now legacy) code that implements device polling, kq filters are now the "One True (and only) Way" * Add dummy write filters (always true) for devices: targ, vinum, snp, tw and apm --- sys/bus/cam/scsi/scsi_target.c | 64 ++++++++--------- sys/bus/firewire/fwdev.c | 34 --------- sys/bus/firewire/fwmem.c | 6 +- sys/bus/firewire/fwmem.h | 1 - sys/bus/usb/usb.c | 28 -------- sys/dev/drm/drmP.h | 2 - sys/dev/drm/drm_drv.c | 1 - sys/dev/drm/drm_fops.c | 5 -- sys/dev/misc/cmx/cmx.c | 48 ------------- sys/dev/misc/dcons/dcons_os.c | 1 - sys/dev/misc/hotplug/hotplug.c | 21 ------ sys/dev/misc/kbd/kbd.c | 28 -------- sys/dev/misc/mse/mse.c | 32 --------- sys/dev/misc/nmdm/nmdm.c | 2 - sys/dev/misc/psm/psm.c | 23 ------- sys/dev/misc/snp/snp.c | 51 +++++--------- sys/dev/misc/spic/spic.c | 23 ------- sys/dev/misc/syscons/syscons.c | 1 - sys/dev/misc/syscons/sysmouse.c | 1 - sys/dev/misc/tw/tw.c | 49 ++++++------- sys/dev/raid/aac/aac.c | 28 -------- sys/dev/raid/vinum/vinum.c | 30 ++++---- sys/dev/raid/vinum/vinumext.h | 4 +- sys/dev/serial/cy/cy.c | 1 - sys/dev/serial/dgb/dgm.c | 1 - sys/dev/serial/digi/digi.c | 1 - sys/dev/serial/rc/rc.c | 1 - sys/dev/serial/rp/rp.c | 1 - sys/dev/serial/si/si.c | 1 - sys/dev/serial/sio/sio.c | 1 - sys/dev/serial/stl/stallion.c | 1 - sys/dev/serial/stli/istallion.c | 1 - sys/dev/sound/pcm/dsp.c | 30 -------- sys/dev/usbmisc/ucom/ucom.c | 2 - sys/dev/usbmisc/ugen/ugen.c | 82 ---------------------- sys/dev/usbmisc/uhid/uhid.c | 29 -------- sys/dev/usbmisc/ums/ums.c | 31 --------- sys/dev/usbmisc/uscanner/uscanner.c | 27 -------- sys/dev/video/bktr/bktr_os.c | 42 ------------ sys/dev/video/cxm/cxm.c | 35 ---------- sys/kern/kern_device.c | 24 ------- sys/kern/kern_memio.c | 21 ------ sys/kern/kern_udev.c | 21 ------ sys/kern/subr_bus.c | 21 ------ sys/kern/subr_log.c | 21 ------ sys/kern/tty.c | 37 ---------- sys/kern/tty_cons.c | 11 --- sys/kern/tty_pty.c | 56 --------------- sys/kern/tty_tty.c | 24 +------ sys/net/bpf.c | 48 ------------- sys/net/i4b/driver/i4b_ctl.c | 13 ---- sys/net/i4b/driver/i4b_rbch.c | 58 ---------------- sys/net/i4b/driver/i4b_tel.c | 84 ----------------------- sys/net/i4b/driver/i4b_trace.c | 13 ---- sys/net/i4b/layer4/i4b_i4bdrv.c | 35 +--------- sys/net/tap/if_tap.c | 47 ------------- sys/net/tun/if_tun.c | 37 ---------- sys/netproto/smb/smb_dev.c | 9 --- sys/platform/pc32/acpica5/acpi_machdep.c | 9 --- sys/platform/pc32/apm/apm.c | 44 +++++------- sys/platform/pc32/gnu/isa/dgb.c | 1 - sys/platform/pc32/isa/asc.c | 28 -------- sys/platform/pc64/acpica5/acpi_machdep.c | 9 --- sys/platform/pc64/apm/apm.c | 44 +++++------- sys/platform/pc64/isa/asc.c | 28 -------- sys/platform/vkernel/platform/console.c | 1 - sys/platform/vkernel64/platform/console.c | 1 - sys/sys/device.h | 14 ---- sys/sys/tty.h | 1 - sys/vfs/devfs/devfs_vnops.c | 64 ----------------- 70 files changed, 128 insertions(+), 1466 deletions(-) diff --git a/sys/bus/cam/scsi/scsi_target.c b/sys/bus/cam/scsi/scsi_target.c index afdc59667e..e3e2379402 100644 --- a/sys/bus/cam/scsi/scsi_target.c +++ b/sys/bus/cam/scsi/scsi_target.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -98,15 +97,17 @@ static d_close_t targclose; 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 = { @@ -116,7 +117,6 @@ static struct dev_ops targ_ops = { .d_read = targread, .d_write = targwrite, .d_ioctl = targioctl, - .d_poll = targpoll, .d_kqfilter = targkqfilter }; @@ -321,33 +321,6 @@ targioctl(struct dev_ioctl_args *ap) 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) { @@ -355,8 +328,22 @@ 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(); @@ -364,7 +351,7 @@ targkqfilter(struct dev_kqfilter_args *ap) } static void -targreadfiltdetach(struct knote *kn) +targfiltdetach(struct knote *kn) { struct targ_softc *softc; @@ -389,6 +376,13 @@ targreadfilt(struct knote *kn, long hint) 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) diff --git a/sys/bus/firewire/fwdev.c b/sys/bus/firewire/fwdev.c index 17ed38e09f..206f7c7b0e 100644 --- a/sys/bus/firewire/fwdev.c +++ b/sys/bus/firewire/fwdev.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include @@ -77,7 +76,6 @@ 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; @@ -96,7 +94,6 @@ struct dev_ops firewire_ops = .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, @@ -715,37 +712,6 @@ out: } 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 }; diff --git a/sys/bus/firewire/fwmem.c b/sys/bus/firewire/fwmem.c index ec6ece6140..e945a4234f 100644 --- a/sys/bus/firewire/fwmem.c +++ b/sys/bus/firewire/fwmem.c @@ -427,11 +427,7 @@ fwmem_ioctl(struct dev_ioctl_args *ap) } return(err); } -int -fwmem_poll(struct dev_poll_args *ap) -{ - return EINVAL; -} + int fwmem_mmap(struct dev_mmap_args *ap) { diff --git a/sys/bus/firewire/fwmem.h b/sys/bus/firewire/fwmem.h index b7945da1ba..d836fb6f27 100644 --- a/sys/bus/firewire/fwmem.h +++ b/sys/bus/firewire/fwmem.h @@ -53,6 +53,5 @@ d_close_t fwmem_close; 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; diff --git a/sys/bus/usb/usb.c b/sys/bus/usb/usb.c index ac6418d596..35f3b74eb7 100644 --- a/sys/bus/usb/usb.c +++ b/sys/bus/usb/usb.c @@ -69,7 +69,6 @@ #include #include #include -#include #include #include #include @@ -148,7 +147,6 @@ d_open_t usbopen; 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 *); @@ -160,7 +158,6 @@ struct dev_ops usb_ops = { .d_close = usbclose, .d_read = usbread, .d_ioctl = usbioctl, - .d_poll = usbpoll, .d_kqfilter = usbkqfilter }; @@ -699,31 +696,6 @@ usbioctl(struct dev_ioctl_args *ap) 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 }; diff --git a/sys/dev/drm/drmP.h b/sys/dev/drm/drmP.h index 2ead7788b8..59d1c457a6 100644 --- a/sys/dev/drm/drmP.h +++ b/sys/dev/drm/drmP.h @@ -56,7 +56,6 @@ struct drm_file; #include #include #include -#include #include #include #include @@ -731,7 +730,6 @@ d_ioctl_t drm_ioctl; 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); diff --git a/sys/dev/drm/drm_drv.c b/sys/dev/drm/drm_drv.c index 12f79ab9bd..b05f1ce74f 100644 --- a/sys/dev/drm/drm_drv.c +++ b/sys/dev/drm/drm_drv.c @@ -124,7 +124,6 @@ static struct dev_ops drm_cdevsw = { .d_close = drm_close, .d_read = drm_read, .d_ioctl = drm_ioctl, - .d_poll = drm_poll, .d_kqfilter = drm_kqfilter, .d_mmap = drm_mmap }; diff --git a/sys/dev/drm/drm_fops.c b/sys/dev/drm/drm_fops.c index e8141923b3..af87270f11 100644 --- a/sys/dev/drm/drm_fops.c +++ b/sys/dev/drm/drm_fops.c @@ -109,11 +109,6 @@ int drm_read(struct dev_read_args *ap) return 0; } -int drm_poll(struct dev_poll_args *ap) -{ - return 0; -} - static int drmfilt(struct knote *kn, long hint) { diff --git a/sys/dev/misc/cmx/cmx.c b/sys/dev/misc/cmx/cmx.c index 706f589688..16e138a9e2 100644 --- a/sys/dev/misc/cmx/cmx.c +++ b/sys/dev/misc/cmx/cmx.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -131,7 +130,6 @@ static d_open_t cmx_open; 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); @@ -148,7 +146,6 @@ static struct dev_ops cmx_ops = { .d_close = cmx_close, .d_read = cmx_read, .d_write = cmx_write, - .d_poll = cmx_poll, .d_kqfilter = cmx_kqfilter }; @@ -649,51 +646,6 @@ cmx_write(struct dev_write_args *ap) 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 = diff --git a/sys/dev/misc/dcons/dcons_os.c b/sys/dev/misc/dcons/dcons_os.c index 25e24e5957..194902fa9c 100644 --- a/sys/dev/misc/dcons/dcons_os.c +++ b/sys/dev/misc/dcons/dcons_os.c @@ -100,7 +100,6 @@ static struct dev_ops dcons_ops = { .d_read = ttyread, .d_write = ttywrite, .d_ioctl = dcons_ioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/misc/hotplug/hotplug.c b/sys/dev/misc/hotplug/hotplug.c index a824dedf50..043e92fea2 100644 --- a/sys/dev/misc/hotplug/hotplug.c +++ b/sys/dev/misc/hotplug/hotplug.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -42,7 +41,6 @@ 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 *); @@ -53,7 +51,6 @@ static struct dev_ops hotplug_ops = { .d_open = hotplugopen, .d_close = hotplugclose, .d_read = hotplugread, - .d_poll = hotplugpoll, .d_kqfilter = hotplugkqfilter }; @@ -107,24 +104,6 @@ hotplugclose(struct dev_close_args *ap) 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 }; diff --git a/sys/dev/misc/kbd/kbd.c b/sys/dev/misc/kbd/kbd.c index 6e188489a1..1d86f1fe10 100644 --- a/sys/dev/misc/kbd/kbd.c +++ b/sys/dev/misc/kbd/kbd.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -495,7 +494,6 @@ static d_close_t genkbdclose; 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 *); @@ -510,7 +508,6 @@ static struct dev_ops kbd_ops = { .d_read = genkbdread, .d_write = genkbdwrite, .d_ioctl = genkbdioctl, - .d_poll = genkbdpoll, .d_kqfilter = genkbdkqfilter }; @@ -748,31 +745,6 @@ genkbdioctl(struct dev_ioctl_args *ap) 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 }; diff --git a/sys/dev/misc/mse/mse.c b/sys/dev/misc/mse/mse.c index 27ee0230c9..3d660dd92f 100644 --- a/sys/dev/misc/mse/mse.c +++ b/sys/dev/misc/mse/mse.c @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -135,7 +134,6 @@ static d_open_t mseopen; 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 *); @@ -148,7 +146,6 @@ static struct dev_ops mse_ops = { .d_close = mseclose, .d_read = mseread, .d_ioctl = mseioctl, - .d_poll = msepoll, .d_kqfilter = msekqfilter }; @@ -611,35 +608,6 @@ mseioctl(struct dev_ioctl_args *ap) 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 }; diff --git a/sys/dev/misc/nmdm/nmdm.c b/sys/dev/misc/nmdm/nmdm.c index bd40c45625..7bd4375b3f 100644 --- a/sys/dev/misc/nmdm/nmdm.c +++ b/sys/dev/misc/nmdm/nmdm.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -76,7 +75,6 @@ static struct dev_ops nmdm_ops = { .d_read = nmdmread, .d_write = nmdmwrite, .d_ioctl = nmdmioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/misc/psm/psm.c b/sys/dev/misc/psm/psm.c index 8a7b3350f0..3e69ec680c 100644 --- a/sys/dev/misc/psm/psm.c +++ b/sys/dev/misc/psm/psm.c @@ -71,7 +71,6 @@ #include #include #include -#include #include #include #include @@ -242,7 +241,6 @@ static d_open_t psmopen; 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); @@ -351,7 +349,6 @@ static struct dev_ops psm_ops = { .d_close = psmclose, .d_read = psmread, .d_ioctl = psmioctl, - .d_poll = psmpoll, .d_kqfilter = psmkqfilter }; @@ -2384,26 +2381,6 @@ psmintr(void *arg) } } -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 }; diff --git a/sys/dev/misc/snp/snp.c b/sys/dev/misc/snp/snp.c index 1086c0dfc2..de5487a9e0 100644 --- a/sys/dev/misc/snp/snp.c +++ b/sys/dev/misc/snp/snp.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -40,13 +39,13 @@ static d_close_t snpclose; 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 @@ -62,7 +61,6 @@ static struct dev_ops snp_ops = { .d_read = snpread, .d_write = snpwrite, .d_ioctl = snpioctl, - .d_poll = snppoll, .d_kqfilter = snpkqfilter }; @@ -564,32 +562,10 @@ snpioctl(struct dev_ioctl_args *ap) 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) @@ -603,7 +579,11 @@ 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: @@ -632,7 +612,7 @@ snpfilter_detach(struct knote *kn) } 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; @@ -648,6 +628,13 @@ snpfilter(struct knote *kn, long hint) 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) { diff --git a/sys/dev/misc/spic/spic.c b/sys/dev/misc/spic/spic.c index dcef981c12..40d5516156 100644 --- a/sys/dev/misc/spic/spic.c +++ b/sys/dev/misc/spic/spic.c @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include @@ -86,7 +85,6 @@ static d_open_t spicopen; 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 *); @@ -98,7 +96,6 @@ static struct dev_ops spic_ops = { .d_close = spicclose, .d_read = spicread, .d_ioctl = spicioctl, - .d_poll = spicpoll, .d_kqfilter = spickqfilter }; @@ -524,26 +521,6 @@ spicioctl(struct dev_ioctl_args *ap) 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 }; diff --git a/sys/dev/misc/syscons/syscons.c b/sys/dev/misc/syscons/syscons.c index 43cbb5df84..3f2b330c47 100644 --- a/sys/dev/misc/syscons/syscons.c +++ b/sys/dev/misc/syscons/syscons.c @@ -240,7 +240,6 @@ static struct dev_ops sc_ops = { .d_read = scread, .d_write = ttywrite, .d_ioctl = scioctl, - .d_poll = ttypoll, .d_mmap = scmmap, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke diff --git a/sys/dev/misc/syscons/sysmouse.c b/sys/dev/misc/syscons/sysmouse.c index e0fb1932ac..954f7f11b5 100644 --- a/sys/dev/misc/syscons/sysmouse.c +++ b/sys/dev/misc/syscons/sysmouse.c @@ -58,7 +58,6 @@ static struct dev_ops sm_ops = { .d_close = smclose, .d_read = ttyread, .d_ioctl = smioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/misc/tw/tw.c b/sys/dev/misc/tw/tw.c index 0f622fd504..12a1915daf 100644 --- a/sys/dev/misc/tw/tw.c +++ b/sys/dev/misc/tw/tw.c @@ -149,7 +149,6 @@ #include #include #include -#include #include #include @@ -215,11 +214,11 @@ static d_open_t twopen; 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 = { @@ -228,7 +227,6 @@ static struct dev_ops tw_ops = { .d_close = twclose, .d_read = twread, .d_write = twwrite, - .d_poll = twpoll, .d_kqfilter = twkqfilter }; @@ -527,29 +525,10 @@ twwrite(struct dev_write_args *ap) * 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) @@ -564,7 +543,12 @@ 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: @@ -593,7 +577,7 @@ twfilter_detach(struct knote *kn) } 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; @@ -606,6 +590,13 @@ twfilter(struct knote *kn, long hint) return (ready); } +static int +twfilter_write(struct knote *kn, long hint) +{ + /* write() is always OK */ + return (1); +} + /* * X-10 Protocol */ diff --git a/sys/dev/raid/aac/aac.c b/sys/dev/raid/aac/aac.c index aca4e6b502..bc4bd1bf88 100644 --- a/sys/dev/raid/aac/aac.c +++ b/sys/dev/raid/aac/aac.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include @@ -213,7 +212,6 @@ static char *aac_describe_code(struct aac_code_lookup *table, 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); @@ -235,7 +233,6 @@ static struct dev_ops aac_ops = { .d_open = aac_open, .d_close = aac_close, .d_ioctl = aac_ioctl, - .d_poll = aac_poll, .d_kqfilter = aac_kqfilter }; @@ -3064,31 +3061,6 @@ aac_ioctl(struct dev_ioctl_args *ap) 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 }; diff --git a/sys/dev/raid/vinum/vinum.c b/sys/dev/raid/vinum/vinum.c index 7ea66e2b3e..b4f5b2768e 100644 --- a/sys/dev/raid/vinum/vinum.c +++ b/sys/dev/raid/vinum/vinum.c @@ -45,7 +45,7 @@ #include "vinumhdr.h" #include /* for sync(2) */ #include -#include +#include /* XXX: poll ops used in kq filters */ #include #ifdef VINUMDEBUG #include @@ -64,7 +64,6 @@ struct dev_ops vinum_ops = .d_read = physread, .d_write = physwrite, .d_ioctl = vinumioctl, - .d_poll = vinumpoll, .d_kqfilter = vinumkqfilter, .d_strategy = vinumstrategy, .d_dump = vinumdump, @@ -575,18 +574,11 @@ vinumdump(struct dev_dump_args *ap) 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; @@ -596,16 +588,28 @@ vinumfilt(struct knote *kn, long hint) 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; } diff --git a/sys/dev/raid/vinum/vinumext.h b/sys/dev/raid/vinum/vinumext.h index 687f7fc227..ec8a5c58ef 100644 --- a/sys/dev/raid/vinum/vinumext.h +++ b/sys/dev/raid/vinum/vinumext.h @@ -138,10 +138,10 @@ d_strategy_t vinumstrategy; 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); diff --git a/sys/dev/serial/cy/cy.c b/sys/dev/serial/cy/cy.c index 66a8774610..218ee5f0ea 100644 --- a/sys/dev/serial/cy/cy.c +++ b/sys/dev/serial/cy/cy.c @@ -390,7 +390,6 @@ static struct dev_ops sio_ops = { .d_read = ttyread, .d_write = siowrite, .d_ioctl = sioioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/serial/dgb/dgm.c b/sys/dev/serial/dgb/dgm.c index 97854d67c4..02b07e440c 100644 --- a/sys/dev/serial/dgb/dgm.c +++ b/sys/dev/serial/dgb/dgm.c @@ -248,7 +248,6 @@ static struct dev_ops dgm_ops = { .d_read = ttyread, .d_write = ttywrite, .d_ioctl = dgmioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/serial/digi/digi.c b/sys/dev/serial/digi/digi.c index 998ac566c4..3dddc47acd 100644 --- a/sys/dev/serial/digi/digi.c +++ b/sys/dev/serial/digi/digi.c @@ -153,7 +153,6 @@ static struct dev_ops digi_ops = { .d_read = digiread, .d_write = digiwrite, .d_ioctl = digiioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/serial/rc/rc.c b/sys/dev/serial/rc/rc.c index bcc2bddbde..58e452fb23 100644 --- a/sys/dev/serial/rc/rc.c +++ b/sys/dev/serial/rc/rc.c @@ -98,7 +98,6 @@ static struct dev_ops rc_ops = { .d_read = ttyread, .d_write = ttywrite, .d_ioctl = rcioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/serial/rp/rp.c b/sys/dev/serial/rp/rp.c index 4cee213590..f095f9ef54 100644 --- a/sys/dev/serial/rp/rp.c +++ b/sys/dev/serial/rp/rp.c @@ -578,7 +578,6 @@ struct dev_ops rp_ops = { .d_read = ttyread, .d_write = rpwrite, .d_ioctl = rpioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/serial/si/si.c b/sys/dev/serial/si/si.c index dfc8e5e73c..c9c7317a5e 100644 --- a/sys/dev/serial/si/si.c +++ b/sys/dev/serial/si/si.c @@ -126,7 +126,6 @@ static struct dev_ops si_ops = { .d_read = ttyread, .d_write = siwrite, .d_ioctl = siioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/serial/sio/sio.c b/sys/dev/serial/sio/sio.c index a40c01efbd..4865894b14 100644 --- a/sys/dev/serial/sio/sio.c +++ b/sys/dev/serial/sio/sio.c @@ -257,7 +257,6 @@ static struct dev_ops sio_ops = { .d_read = sioread, .d_write = siowrite, .d_ioctl = sioioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/serial/stl/stallion.c b/sys/dev/serial/stl/stallion.c index 3c194041c8..4fa3d6d054 100644 --- a/sys/dev/serial/stl/stallion.c +++ b/sys/dev/serial/stl/stallion.c @@ -756,7 +756,6 @@ static struct dev_ops stl_ops = { .d_read = ttyread, .d_write = ttywrite, .d_ioctl = stlioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/serial/stli/istallion.c b/sys/dev/serial/stli/istallion.c index 8553f3e229..ddde4099bf 100644 --- a/sys/dev/serial/stli/istallion.c +++ b/sys/dev/serial/stli/istallion.c @@ -639,7 +639,6 @@ static struct dev_ops stli_ops = { .d_read = stliread, .d_write = stliwrite, .d_ioctl = stliioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index 4eacd29147..60da277a10 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -43,7 +43,6 @@ static d_close_t dsp_close; 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; @@ -59,7 +58,6 @@ struct dev_ops dsp_cdevsw = { .d_read = dsp_read, .d_write = dsp_write, .d_ioctl = dsp_ioctl, - .d_poll = dsp_poll, .d_kqfilter = dsp_kqfilter, .d_mmap = dsp_mmap, }; @@ -1088,34 +1086,6 @@ dsp_ioctl(struct dev_ioctl_args *ap) 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 = diff --git a/sys/dev/usbmisc/ucom/ucom.c b/sys/dev/usbmisc/ucom/ucom.c index 3960296eb0..3500f83156 100644 --- a/sys/dev/usbmisc/ucom/ucom.c +++ b/sys/dev/usbmisc/ucom/ucom.c @@ -80,7 +80,6 @@ #include #include #include -#include #include #include @@ -127,7 +126,6 @@ static struct dev_ops ucom_ops = { .d_read = ucomread, .d_write = ucomwrite, .d_ioctl = ucomioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; diff --git a/sys/dev/usbmisc/ugen/ugen.c b/sys/dev/usbmisc/ugen/ugen.c index 83f33cbed8..58f2d0ec03 100644 --- a/sys/dev/usbmisc/ugen/ugen.c +++ b/sys/dev/usbmisc/ugen/ugen.c @@ -63,7 +63,6 @@ #include #include #include -#include #include #include #include @@ -140,7 +139,6 @@ d_close_t ugenclose; 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 *); @@ -156,7 +154,6 @@ static struct dev_ops ugen_ops = { .d_read = ugenread, .d_write = ugenwrite, .d_ioctl = ugenioctl, - .d_poll = ugenpoll, .d_kqfilter = ugenkqfilter }; @@ -1429,85 +1426,6 @@ ugenioctl(struct dev_ioctl_args *ap) 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 = diff --git a/sys/dev/usbmisc/uhid/uhid.c b/sys/dev/usbmisc/uhid/uhid.c index 367c792c93..16243e8504 100644 --- a/sys/dev/usbmisc/uhid/uhid.c +++ b/sys/dev/usbmisc/uhid/uhid.c @@ -63,7 +63,6 @@ #include #include #include -#include #include #include #include @@ -132,7 +131,6 @@ d_close_t uhidclose; 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 *); @@ -148,7 +146,6 @@ static struct dev_ops uhid_ops = { .d_read = uhidread, .d_write = uhidwrite, .d_ioctl = uhidioctl, - .d_poll = uhidpoll, .d_kqfilter = uhidkqfilter }; @@ -672,32 +669,6 @@ uhidioctl(struct dev_ioctl_args *ap) 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 = diff --git a/sys/dev/usbmisc/ums/ums.c b/sys/dev/usbmisc/ums/ums.c index 92fdc7eced..193041b378 100644 --- a/sys/dev/usbmisc/ums/ums.c +++ b/sys/dev/usbmisc/ums/ums.c @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -140,7 +139,6 @@ static d_open_t ums_open; 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 *); @@ -154,7 +152,6 @@ static struct dev_ops ums_ops = { .d_close = ums_close, .d_read = ums_read, .d_ioctl = ums_ioctl, - .d_poll = ums_poll, .d_kqfilter = ums_kqfilter }; @@ -671,34 +668,6 @@ ums_read(struct dev_read_args *ap) 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 }; diff --git a/sys/dev/usbmisc/uscanner/uscanner.c b/sys/dev/usbmisc/uscanner/uscanner.c index f5179baca4..0901ae6c08 100644 --- a/sys/dev/usbmisc/uscanner/uscanner.c +++ b/sys/dev/usbmisc/uscanner/uscanner.c @@ -60,7 +60,6 @@ #include #include #include -#include #include #include #include @@ -255,7 +254,6 @@ d_open_t uscanneropen; 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 @@ -266,7 +264,6 @@ static struct dev_ops uscanner_ops = { .d_close = uscannerclose, .d_read = uscannerread, .d_write = uscannerwrite, - .d_poll = uscannerpoll, .d_kqfilter = uscannerkqfilter }; @@ -648,30 +645,6 @@ uscanner_detach(device_t self) 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) {} diff --git a/sys/dev/video/bktr/bktr_os.c b/sys/dev/video/bktr/bktr_os.c index fe0ce82f59..9b7b290efd 100644 --- a/sys/dev/video/bktr/bktr_os.c +++ b/sys/dev/video/bktr/bktr_os.c @@ -60,7 +60,6 @@ #include #include #include -#include #include #include #include @@ -164,7 +163,6 @@ static d_read_t bktr_read; 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 *); @@ -178,7 +176,6 @@ static struct dev_ops bktr_ops = { .d_read = bktr_read, .d_write = bktr_write, .d_ioctl = bktr_ioctl, - .d_poll = bktr_poll, .d_kqfilter = bktr_kqfilter, .d_mmap = bktr_mmap, }; @@ -724,45 +721,6 @@ bktr_mmap(struct dev_mmap_args *ap) 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 }; diff --git a/sys/dev/video/cxm/cxm.c b/sys/dev/video/cxm/cxm.c index ec3b8d39dd..cac3903d47 100644 --- a/sys/dev/video/cxm/cxm.c +++ b/sys/dev/video/cxm/cxm.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -122,7 +121,6 @@ static d_open_t cxm_open; 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 *); @@ -136,7 +134,6 @@ static struct dev_ops cxm_ops = { .d_close = cxm_close, .d_read = cxm_read, .d_ioctl = cxm_ioctl, - .d_poll = cxm_poll, .d_kqfilter = cxm_kqfilter }; @@ -2910,38 +2907,6 @@ cxm_ioctl(struct dev_ioctl_args *ap) 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 }; diff --git a/sys/kern/kern_device.c b/sys/kern/kern_device.c index 197622fb75..84105abba3 100644 --- a/sys/kern/kern_device.c +++ b/sys/kern/kern_device.c @@ -69,7 +69,6 @@ DEVOP_DESC_INIT(write); 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); @@ -89,7 +88,6 @@ struct dev_ops default_dev_ops = { .d_read = noread, .d_write = nowrite, .d_ioctl = noioctl, - .d_poll = nopoll, .d_mmap = nommap, .d_strategy = nostrategy, .d_dump = nodump, @@ -175,21 +173,6 @@ dev_dioctl(cdev_t dev, u_long cmd, caddr_t data, int fflag, struct ucred *cred, 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) { @@ -553,13 +536,6 @@ nommap(struct dev_mmap_args *ap) return (ENODEV); } -int -nopoll(struct dev_poll_args *ap) -{ - ap->a_events = 0; - return(0); -} - int nostrategy(struct dev_strategy_args *ap) { diff --git a/sys/kern/kern_memio.c b/sys/kern/kern_memio.c index 8aa07c2448..9c76b8ac8c 100644 --- a/sys/kern/kern_memio.c +++ b/sys/kern/kern_memio.c @@ -74,7 +74,6 @@ static d_read_t mmread; 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 @@ -85,7 +84,6 @@ static struct dev_ops mem_ops = { .d_read = mmread, .d_write = mmwrite, .d_ioctl = mmioctl, - .d_poll = mmpoll, .d_kqfilter = mmkqfilter, .d_mmap = memmmap, }; @@ -529,25 +527,6 @@ random_ioctl(cdev_t dev, u_long cmd, caddr_t data, int flags, struct ucred *cred 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) { diff --git a/sys/kern/kern_udev.c b/sys/kern/kern_udev.c index 3741f034a8..796ca26bd3 100644 --- a/sys/kern/kern_udev.c +++ b/sys/kern/kern_udev.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -57,7 +56,6 @@ static cdev_t udev_dev; 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; @@ -108,7 +106,6 @@ static struct dev_ops udev_dev_ops = { .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 }; @@ -539,24 +536,6 @@ udev_dev_close(struct dev_close_args *ap) 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 }; diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 3453b71f9d..534b7aa5c2 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include @@ -143,7 +142,6 @@ static d_open_t devopen; 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 = { @@ -152,7 +150,6 @@ static struct dev_ops devctl_ops = { .d_close = devclose, .d_read = devread, .d_ioctl = devioctl, - .d_poll = devpoll, .d_kqfilter = devkqfilter }; @@ -277,24 +274,6 @@ devioctl(struct dev_ioctl_args *ap) 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); diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 740e663c76..46ac56e3f3 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -63,7 +62,6 @@ static d_open_t logopen; 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); @@ -77,7 +75,6 @@ static struct dev_ops log_ops = { .d_close = logclose, .d_read = logread, .d_ioctl = logioctl, - .d_poll = logpoll, .d_kqfilter = logkqfilter }; @@ -165,24 +162,6 @@ logread(struct dev_read_args *ap) 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 }; diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 43e55253bc..0c8efa39b8 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -86,7 +86,6 @@ #include #include #include -#include #include #include #include @@ -1157,42 +1156,6 @@ ttioctl(struct tty *tp, u_long cmd, void *data, int flag) 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 = diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c index f38fc9ae78..3c6c4dd5eb 100644 --- a/sys/kern/tty_cons.c +++ b/sys/kern/tty_cons.c @@ -66,7 +66,6 @@ static d_close_t cnclose; 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); @@ -79,7 +78,6 @@ static struct dev_ops cn_ops = { .d_read = cnread, .d_write = cnwrite, .d_ioctl = cnioctl, - .d_poll = cnpoll, .d_kqfilter = cnkqfilter, }; @@ -449,15 +447,6 @@ cnioctl(struct dev_ioctl_args *ap) 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) { diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 1661659374..788f38a7ce 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -85,7 +84,6 @@ static d_open_t ptcopen; 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 @@ -102,7 +100,6 @@ static struct dev_ops pts98_ops = { .d_read = ptsread, .d_write = ptswrite, .d_ioctl = ptyioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; @@ -114,7 +111,6 @@ static struct dev_ops ptc98_ops = { .d_read = ptcread, .d_write = ptcwrite, .d_ioctl = ptyioctl, - .d_poll = ptcpoll, .d_kqfilter = ptckqfilter, .d_revoke = ttyrevoke }; @@ -128,7 +124,6 @@ static struct dev_ops pts_ops = { .d_read = ptsread, .d_write = ptswrite, .d_ioctl = ptyioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, .d_revoke = ttyrevoke }; @@ -141,7 +136,6 @@ static struct dev_ops ptc_ops = { .d_read = ptcread, .d_write = ptcwrite, .d_ioctl = ptyioctl, - .d_poll = ptcpoll, .d_kqfilter = ptckqfilter, .d_revoke = ttyrevoke }; @@ -655,56 +649,6 @@ ptsstop(struct tty *tp, int flush) 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. */ diff --git a/sys/kern/tty_tty.c b/sys/kern/tty_tty.c index d3fe69e64c..ed28148751 100644 --- a/sys/kern/tty_tty.c +++ b/sys/kern/tty_tty.c @@ -49,15 +49,14 @@ #include #include #include +#include /* XXX: poll args used in KQ filters */ #include -#include 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 *); @@ -73,7 +72,6 @@ struct dev_ops ctty_ops = { .d_read = cttyread, .d_write = cttywrite, .d_ioctl = cttyioctl, - .d_poll = cttypoll, .d_kqfilter = cttykqfilter }; @@ -242,26 +240,6 @@ cttyioctl(struct dev_ioctl_args *ap) 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 = diff --git a/sys/net/bpf.c b/sys/net/bpf.c index d057e397a1..456ca3bf17 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -57,7 +57,6 @@ #include #include -#include #include #include @@ -138,7 +137,6 @@ static d_close_t bpfclose; 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 @@ -149,7 +147,6 @@ static struct dev_ops bpf_ops = { .d_read = bpfread, .d_write = bpfwrite, .d_ioctl = bpfioctl, - .d_poll = bpfpoll, .d_kqfilter = bpfkqfilter }; @@ -1071,51 +1068,6 @@ bpf_setif(struct bpf_d *d, struct ifreq *ifr) 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 }; diff --git a/sys/net/i4b/driver/i4b_ctl.c b/sys/net/i4b/driver/i4b_ctl.c index 6a0a8356c4..5dff7ccf63 100644 --- a/sys/net/i4b/driver/i4b_ctl.c +++ b/sys/net/i4b/driver/i4b_ctl.c @@ -66,9 +66,6 @@ static d_open_t i4bctlopen; 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 = { @@ -76,7 +73,6 @@ static struct dev_ops i4bctl_ops = { .d_open = i4bctlopen, .d_close = i4bctlclose, .d_ioctl = i4bctlioctl, - .d_poll = POLLFIELD, }; static void i4bctlattach(void *); @@ -216,13 +212,4 @@ i4bctlioctl(struct dev_ioctl_args *ap) #endif /* DO_I4B_DEBUG */ } -/*---------------------------------------------------------------------------* - * i4bctlpoll - device driver poll routine - *---------------------------------------------------------------------------*/ -static int -i4bctlpoll (struct dev_poll_args *ap) -{ - return (ENODEV); -} - #endif /* NI4BCTL > 0 */ diff --git a/sys/net/i4b/driver/i4b_rbch.c b/sys/net/i4b/driver/i4b_rbch.c index 651eb5b2b9..bb6db28004 100644 --- a/sys/net/i4b/driver/i4b_rbch.c +++ b/sys/net/i4b/driver/i4b_rbch.c @@ -60,7 +60,6 @@ #include "../include/i4b_l3l4.h" #include "../layer4/i4b_l4.h" -#include #include #include @@ -125,9 +124,6 @@ PDEVSTATIC void i4brbchkfilt_detach(struct knote *); 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 = { @@ -137,7 +133,6 @@ static struct dev_ops i4brbch_ops = { .d_read = i4brbchread, .d_write = i4brbchwrite, .d_ioctl = i4brbchioctl, - .d_poll = POLLFIELD, .d_kqfilter = i4brbchkqfilter }; @@ -536,59 +531,6 @@ i4brbchioctl(struct dev_ioctl_args *ap) /*---------------------------------------------------------------------------* * 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 = diff --git a/sys/net/i4b/driver/i4b_tel.c b/sys/net/i4b/driver/i4b_tel.c index 7d75f3020b..b9b5a6783d 100644 --- a/sys/net/i4b/driver/i4b_tel.c +++ b/sys/net/i4b/driver/i4b_tel.c @@ -43,7 +43,6 @@ #include #include -#include #include #include @@ -144,9 +143,6 @@ PDEVSTATIC d_write_t i4btelwrite; 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); @@ -160,7 +156,6 @@ static struct dev_ops i4btel_ops = { .d_read = i4btelread, .d_write = i4btelwrite, .d_ioctl = i4btelioctl, - .d_poll = POLLFIELD, .d_kqfilter = i4btelkqfilter }; @@ -690,85 +685,6 @@ tel_tone(tel_sc_t *sc) /*---------------------------------------------------------------------------* * 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 = diff --git a/sys/net/i4b/driver/i4b_trace.c b/sys/net/i4b/driver/i4b_trace.c index d200aac358..dd14c2f668 100644 --- a/sys/net/i4b/driver/i4b_trace.c +++ b/sys/net/i4b/driver/i4b_trace.c @@ -73,9 +73,6 @@ static d_close_t i4btrcclose; 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 = { @@ -84,7 +81,6 @@ static struct dev_ops i4btrc_ops = { .d_close = i4btrcclose, .d_read = i4btrcread, .d_ioctl = i4btrcioctl, - .d_poll = POLLFIELD, }; /*---------------------------------------------------------------------------* @@ -337,15 +333,6 @@ i4btrcread(struct dev_read_args *ap) return(error); } -/*---------------------------------------------------------------------------* - * poll device - *---------------------------------------------------------------------------*/ -PDEVSTATIC int -i4btrcpoll(struct dev_poll_args *ap) -{ - return(ENODEV); -} - /*---------------------------------------------------------------------------* * device driver ioctl routine *---------------------------------------------------------------------------*/ diff --git a/sys/net/i4b/layer4/i4b_i4bdrv.c b/sys/net/i4b/layer4/i4b_i4bdrv.c index 9a28f2b526..2577f44070 100644 --- a/sys/net/i4b/layer4/i4b_i4bdrv.c +++ b/sys/net/i4b/layer4/i4b_i4bdrv.c @@ -72,7 +72,6 @@ #include "i4b_l4.h" -#include #include struct selinfo select_rd_info; @@ -93,9 +92,6 @@ PDEVSTATIC void i4bkqfilt_detach(struct knote *); 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 = { @@ -104,7 +100,6 @@ static struct dev_ops i4b_ops = { .d_close = i4bclose, .d_read = i4bread, .d_ioctl = i4bioctl, - .d_poll = POLLFIELD, .d_kqfilter = i4bkqfilter }; @@ -733,36 +728,8 @@ diag_done: } /*---------------------------------------------------------------------------* - * 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 = diff --git a/sys/net/tap/if_tap.c b/sys/net/tap/if_tap.c index 9b74641212..d22362516b 100644 --- a/sys/net/tap/if_tap.c +++ b/sys/net/tap/if_tap.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -117,7 +116,6 @@ static d_close_t tapclose; 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 = { @@ -127,7 +125,6 @@ static struct dev_ops tap_ops = { .d_read = tapread, .d_write = tapwrite, .d_ioctl = tapioctl, - .d_poll = tappoll, .d_kqfilter = tapkqfilter }; @@ -941,50 +938,6 @@ tapwrite(struct dev_write_args *ap) 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 * diff --git a/sys/net/tun/if_tun.c b/sys/net/tun/if_tun.c index 9d45ab0731..8f6ab099a4 100644 --- a/sys/net/tun/if_tun.c +++ b/sys/net/tun/if_tun.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -87,7 +86,6 @@ static d_close_t tunclose; 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; @@ -107,7 +105,6 @@ static struct dev_ops tun_ops = { .d_read = tunread, .d_write = tunwrite, .d_ioctl = tunioctl, - .d_poll = tunpoll, .d_kqfilter = tunkqfilter }; @@ -702,40 +699,6 @@ tunwrite(struct dev_write_args *ap) 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 = diff --git a/sys/netproto/smb/smb_dev.c b/sys/netproto/smb/smb_dev.c index 9bb7d4fe8d..1f317f0ead 100644 --- a/sys/netproto/smb/smb_dev.c +++ b/sys/netproto/smb/smb_dev.c @@ -40,7 +40,6 @@ #include #include #include /* Must come after sys/malloc.h */ -#include #include #include #include @@ -68,7 +67,6 @@ static d_close_t nsmb_dev_close; 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); @@ -96,7 +94,6 @@ static struct dev_ops nsmb_ops = { .d_read = nsmb_dev_read, .d_write = nsmb_dev_write, .d_ioctl = nsmb_dev_ioctl, - .d_poll = nsmb_dev_poll, }; @@ -330,12 +327,6 @@ nsmb_dev_write(struct dev_write_args *ap) return EACCES; } -static int -nsmb_dev_poll(struct dev_poll_args *ap) -{ - return ENODEV; -} - static int nsmbclone(struct dev_clone_args *ap) { diff --git a/sys/platform/pc32/acpica5/acpi_machdep.c b/sys/platform/pc32/acpica5/acpi_machdep.c index 4387bb6b8b..89d69fc5ae 100644 --- a/sys/platform/pc32/acpica5/acpi_machdep.c +++ b/sys/platform/pc32/acpica5/acpi_machdep.c @@ -67,7 +67,6 @@ static d_open_t apmopen; 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 @@ -77,7 +76,6 @@ static struct dev_ops apm_ops = { .d_close = apmclose, .d_write = apmwrite, .d_ioctl = apmioctl, - .d_poll = apmpoll, .d_kqfilter = apmkqfilter }; @@ -297,13 +295,6 @@ apmwrite(struct dev_write_args *ap) 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); diff --git a/sys/platform/pc32/apm/apm.c b/sys/platform/pc32/apm/apm.c index 0b30682117..e4c0980b07 100644 --- a/sys/platform/pc32/apm/apm.c +++ b/sys/platform/pc32/apm/apm.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -83,11 +82,11 @@ static d_open_t apmopen; 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 = { @@ -96,7 +95,6 @@ static struct dev_ops apm_ops = { .d_close = apmclose, .d_write = apmwrite, .d_ioctl = apmioctl, - .d_poll = apmpoll, .d_kqfilter = apmkqfilter }; @@ -1342,25 +1340,10 @@ apmwrite(struct dev_write_args *ap) 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) @@ -1373,7 +1356,11 @@ 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: @@ -1402,7 +1389,7 @@ apmfilter_detach(struct knote *kn) } 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; @@ -1413,6 +1400,13 @@ apmfilter(struct knote *kn, long hint) 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 diff --git a/sys/platform/pc32/gnu/isa/dgb.c b/sys/platform/pc32/gnu/isa/dgb.c index 9ad482a240..9c329d25ef 100644 --- a/sys/platform/pc32/gnu/isa/dgb.c +++ b/sys/platform/pc32/gnu/isa/dgb.c @@ -227,7 +227,6 @@ static struct cdevsw dgb_cdevsw = { /* read */ ttyread, /* write */ ttywrite, /* ioctl */ dgbioctl, - /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* dump */ nodump, diff --git a/sys/platform/pc32/isa/asc.c b/sys/platform/pc32/isa/asc.c index e2ce868eb8..47421a77f7 100644 --- a/sys/platform/pc32/isa/asc.c +++ b/sys/platform/pc32/isa/asc.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -186,7 +185,6 @@ static d_open_t ascopen; 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); @@ -200,7 +198,6 @@ static struct dev_ops asc_ops = { .d_close = ascclose, .d_read = ascread, .d_ioctl = ascioctl, - .d_poll = ascpoll, .d_kqfilter = asckqfilter }; @@ -852,31 +849,6 @@ ascioctl(struct dev_ioctl_args *ap) 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 }; diff --git a/sys/platform/pc64/acpica5/acpi_machdep.c b/sys/platform/pc64/acpica5/acpi_machdep.c index da44709d5f..63d500c1d0 100644 --- a/sys/platform/pc64/acpica5/acpi_machdep.c +++ b/sys/platform/pc64/acpica5/acpi_machdep.c @@ -63,7 +63,6 @@ static d_open_t apmopen; 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 @@ -73,7 +72,6 @@ static struct dev_ops apm_ops = { .d_close = apmclose, .d_write = apmwrite, .d_ioctl = apmioctl, - .d_poll = apmpoll, .d_kqfilter = apmkqfilter }; @@ -293,13 +291,6 @@ apmwrite(struct dev_write_args *ap) 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); diff --git a/sys/platform/pc64/apm/apm.c b/sys/platform/pc64/apm/apm.c index 902f355c8e..a77e830ee0 100644 --- a/sys/platform/pc64/apm/apm.c +++ b/sys/platform/pc64/apm/apm.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -83,11 +82,11 @@ static d_open_t apmopen; 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 = { @@ -96,7 +95,6 @@ static struct dev_ops apm_ops = { .d_close = apmclose, .d_write = apmwrite, .d_ioctl = apmioctl, - .d_poll = apmpoll, .d_kqfilter = apmkqfilter }; @@ -1342,25 +1340,10 @@ apmwrite(struct dev_write_args *ap) 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) @@ -1373,7 +1356,11 @@ 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: @@ -1402,7 +1389,7 @@ apmfilter_detach(struct knote *kn) } 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; @@ -1413,6 +1400,13 @@ apmfilter(struct knote *kn, long hint) 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 diff --git a/sys/platform/pc64/isa/asc.c b/sys/platform/pc64/isa/asc.c index 2c49ec2260..cd2789f574 100644 --- a/sys/platform/pc64/isa/asc.c +++ b/sys/platform/pc64/isa/asc.c @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -185,7 +184,6 @@ static d_open_t ascopen; 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); @@ -199,7 +197,6 @@ static struct dev_ops asc_ops = { .d_close = ascclose, .d_read = ascread, .d_ioctl = ascioctl, - .d_poll = ascpoll, .d_kqfilter = asckqfilter }; @@ -851,31 +848,6 @@ ascioctl(struct dev_ioctl_args *ap) 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 }; diff --git a/sys/platform/vkernel/platform/console.c b/sys/platform/vkernel/platform/console.c index c942d0c354..54de5a96b4 100644 --- a/sys/platform/vkernel/platform/console.c +++ b/sys/platform/vkernel/platform/console.c @@ -88,7 +88,6 @@ static struct dev_ops vcons_ops = { .d_read = ttyread, .d_write = ttywrite, .d_ioctl = vcons_ioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter, }; diff --git a/sys/platform/vkernel64/platform/console.c b/sys/platform/vkernel64/platform/console.c index f07834a58a..353bd51188 100644 --- a/sys/platform/vkernel64/platform/console.c +++ b/sys/platform/vkernel64/platform/console.c @@ -88,7 +88,6 @@ static struct dev_ops vcons_ops = { .d_read = ttyread, .d_write = ttywrite, .d_ioctl = vcons_ioctl, - .d_poll = ttypoll, .d_kqfilter = ttykqfilter }; diff --git a/sys/sys/device.h b/sys/sys/device.h index 485d527563..52d2d10e1a 100644 --- a/sys/sys/device.h +++ b/sys/sys/device.h @@ -111,14 +111,6 @@ struct dev_ioctl_args { 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) */ @@ -198,7 +190,6 @@ typedef int d_close_t (struct dev_close_args *ap); 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); @@ -229,7 +220,6 @@ struct dev_ops { 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; @@ -274,7 +264,6 @@ union dev_args_union { 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; @@ -320,7 +309,6 @@ int dev_ddump(cdev_t dev, void *virtual, vm_offset_t physical, off_t offset, 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); @@ -339,7 +327,6 @@ d_close_t noclose; 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; @@ -359,7 +346,6 @@ extern struct syslink_desc dev_write_desc; 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; diff --git a/sys/sys/tty.h b/sys/sys/tty.h index 52ef3b098d..99c5dfc9b3 100644 --- a/sys/sys/tty.h +++ b/sys/sys/tty.h @@ -281,7 +281,6 @@ int ttylclose (struct tty *tp, int flag); 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); diff --git a/sys/vfs/devfs/devfs_vnops.c b/sys/vfs/devfs/devfs_vnops.c index 44db5412a0..9d6272e1f3 100644 --- a/sys/vfs/devfs/devfs_vnops.c +++ b/sys/vfs/devfs/devfs_vnops.c @@ -96,7 +96,6 @@ static int devfs_spec_fsync(struct vop_fsync_args *); 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 *); @@ -112,7 +111,6 @@ static int devfs_specf_read(struct file *, struct uio *, struct ucred *, int); 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 *); @@ -171,7 +169,6 @@ struct vop_ops devfs_vnode_dev_vops = { .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, @@ -189,7 +186,6 @@ struct fileops devfs_dev_fileops = { .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, @@ -1394,43 +1390,6 @@ done: 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 */ @@ -1651,29 +1610,6 @@ devfs_spec_ioctl(struct vop_ioctl_args *ap) 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) */ -- 2.41.0