From 88a31edf941b04ca5569cf67fb9b7cad5da0b093 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Tigeot?= Date: Wed, 4 Jul 2012 14:28:29 +0200 Subject: [PATCH] sound: Port to DragonFly - cdevsw to dev_ops semantics --- sys/dev/sound/pci/emu10kx.c | 16 ++++++----- sys/dev/sound/pcm/dsp.c | 53 ++++++++++++++++++++++++------------- sys/dev/sound/pcm/dsp.h | 2 +- sys/dev/sound/pcm/mixer.c | 21 +++++++++------ sys/dev/sound/pcm/sndstat.c | 18 ++++++++----- 5 files changed, 69 insertions(+), 41 deletions(-) diff --git a/sys/dev/sound/pci/emu10kx.c b/sys/dev/sound/pci/emu10kx.c index cb1d43b639..5fe7d0bf14 100644 --- a/sys/dev/sound/pci/emu10kx.c +++ b/sys/dev/sound/pci/emu10kx.c @@ -2187,18 +2187,17 @@ static d_open_t emu10kx_open; static d_close_t emu10kx_close; static d_read_t emu10kx_read; -static struct cdevsw emu10kx_cdevsw = { +static struct dev_ops emu10kx_ops = { .d_open = emu10kx_open, .d_close = emu10kx_close, .d_read = emu10kx_read, - .d_name = "emu10kx", - .d_version = D_VERSION, }; static int -emu10kx_open(struct cdev *i_dev, int flags __unused, int mode __unused, struct thread *td __unused) +emu10kx_open(struct dev_open_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; int error; struct emu_sc_info *sc; @@ -2226,8 +2225,9 @@ out: } static int -emu10kx_close(struct cdev *i_dev, int flags __unused, int mode __unused, struct thread *td __unused) +emu10kx_close(struct dev_close_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; struct emu_sc_info *sc; sc = i_dev->si_drv1; @@ -2245,8 +2245,10 @@ emu10kx_close(struct cdev *i_dev, int flags __unused, int mode __unused, struct } static int -emu10kx_read(struct cdev *i_dev, struct uio *buf, int flag __unused) +emu10kx_read(struct dev_read_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; + struct uio *buf = ap->a_uio; int l, err; struct emu_sc_info *sc; @@ -2332,7 +2334,7 @@ emu10kx_dev_init(struct emu_sc_info *sc) LK_CANRECURSE); unit = device_get_unit(sc->dev); - sc->cdev = make_dev(&emu10kx_cdevsw, PCMMINOR(unit), UID_ROOT, GID_WHEEL, 0640, "emu10kx%d", unit); + sc->cdev = make_dev(&emu10kx_ops, PCMMINOR(unit), UID_ROOT, GID_WHEEL, 0640, "emu10kx%d", unit); if (sc->cdev != NULL) { sc->cdev->si_drv1 = sc; return (0); diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index d084af2f51..f72b173b78 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -73,21 +73,23 @@ 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; static d_mmap_single_t dsp_mmap_single; -struct cdevsw dsp_cdevsw = { - .d_version = D_VERSION, +static void dsp_filter_detach(struct knote *); +static int dsp_filter_read(struct knote *, long); +static int dsp_filter_write(struct knote *, long); + +struct dev_ops dsp_ops = { .d_open = dsp_open, .d_close = dsp_close, .d_read = dsp_read, .d_write = dsp_write, .d_ioctl = dsp_ioctl, - .d_poll = dsp_poll, + .d_kqfilter = dsp_kqfilter, .d_mmap = dsp_mmap, .d_mmap_single = dsp_mmap_single, - .d_name = "dsp", }; static eventhandler_tag dsp_ehtag = NULL; @@ -442,8 +444,10 @@ static const struct { } while (0) static int -dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td) +dsp_open(struct dev_open_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; + int flags = ap->a_oflags; struct pcm_channel *rdch, *wrch; struct snddev_info *d; uint32_t fmt, spd, prio, volctl; @@ -693,8 +697,9 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td) } static int -dsp_close(struct cdev *i_dev, int flags, int mode, struct thread *td) +dsp_close(struct dev_close_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; struct pcm_channel *rdch, *wrch, *volch; struct snddev_info *d; int sg_ids, rdref, wdref; @@ -885,14 +890,20 @@ dsp_io_ops(struct cdev *i_dev, struct uio *buf) } static int -dsp_read(struct cdev *i_dev, struct uio *buf, int flag) +dsp_read(struct dev_read_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; + struct uio *buf = ap->a_uio; + return (dsp_io_ops(i_dev, buf)); } static int -dsp_write(struct cdev *i_dev, struct uio *buf, int flag) +dsp_write(struct dev_write_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; + struct uio *buf = ap->a_uio; + return (dsp_io_ops(i_dev, buf)); } @@ -1060,9 +1071,11 @@ dsp_ioctl_channel(struct cdev *dev, struct pcm_channel *volch, u_long cmd, } static int -dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, - struct thread *td) +dsp_ioctl(struct dev_ioctl_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; + u_long cmd = ap->a_cmd; + caddr_t arg = ap->a_data; struct pcm_channel *chn, *rdch, *wrch; struct snddev_info *d; u_long xcmd; @@ -2195,19 +2208,23 @@ dsp_poll(struct cdev *i_dev, int events, struct thread *td) } static int -dsp_mmap(struct cdev *i_dev, vm_ooffset_t offset, vm_paddr_t *paddr, - int nprot, vm_memattr_t *memattr) +dsp_mmap(struct dev_mmap_args *ap) { + vm_offset_t offset = ap->a_offset; /* XXX memattr is not honored */ - *paddr = vtophys(offset); + ap->a_result = vtophys(offset); return (0); } static int -dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset, - vm_size_t size, struct vm_object **object, int nprot) +dsp_mmap_single(struct dev_mmap_single_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; + vm_ooffset_t *offset = ap->a_offset; + vm_size_t size = ap->a_size; + struct vm_object **object = ap->a_object; + int nprot = ap->a_nprot; struct snddev_info *d; struct pcm_channel *wrch, *rdch, *c; @@ -2447,7 +2464,7 @@ dsp_clone_alloc: snd_clone_setmaxunit(d->clones, tumax); if (ce != NULL) { udcmask |= snd_c2unit(cunit); - *dev = make_dev(&dsp_cdevsw, PCMMINOR(udcmask), + dev = make_only_dev(&dsp_ops, PCMMINOR(udcmask), UID_ROOT, GID_WHEEL, 0666, "%s%d%s%d", devname, unit, devsep, cunit); snd_clone_register(ce, *dev); @@ -2553,7 +2570,7 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *ai) * DSP device. (Users may use this ioctl with /dev/mixer and * /dev/midi.) */ - if (ai->dev == -1 && i_dev->si_devsw != &dsp_cdevsw) + if (ai->dev == -1 && i_dev->si_ops != &dsp_ops) return (EINVAL); ch = NULL; diff --git a/sys/dev/sound/pcm/dsp.h b/sys/dev/sound/pcm/dsp.h index ac7182ce03..81bc2e1955 100644 --- a/sys/dev/sound/pcm/dsp.h +++ b/sys/dev/sound/pcm/dsp.h @@ -31,7 +31,7 @@ #ifndef _PCMDSP_H_ #define _PCMDSP_H_ -extern struct cdevsw dsp_cdevsw; +extern struct dev_ops dsp_ops; struct dsp_cdevinfo; diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index ab1dc66aa3..4937928c86 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -31,6 +31,7 @@ #endif #include +#include #include #include "feeder_if.h" @@ -98,12 +99,11 @@ static d_open_t mixer_open; static d_close_t mixer_close; static d_ioctl_t mixer_ioctl; -static struct cdevsw mixer_cdevsw = { - .d_version = D_VERSION, +static struct dev_ops mixer_cdevsw = { + { "mixer", 0, D_TRACKCLOSE }, .d_open = mixer_open, .d_close = mixer_close, .d_ioctl = mixer_ioctl, - .d_name = "mixer", }; /** @@ -1033,8 +1033,9 @@ mix_get_type(struct snd_mixer *m) /* ----------------------------------------------------------------------- */ static int -mixer_open(struct cdev *i_dev, int flags, int mode, struct thread *td) +mixer_open(struct dev_open_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; struct snddev_info *d; struct snd_mixer *m; @@ -1057,8 +1058,9 @@ mixer_open(struct cdev *i_dev, int flags, int mode, struct thread *td) } static int -mixer_close(struct cdev *i_dev, int flags, int mode, struct thread *td) +mixer_close(struct dev_close_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; struct snddev_info *d; struct snd_mixer *m; int ret; @@ -1190,9 +1192,12 @@ mixer_ioctl_channel_proc: } static int -mixer_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, - struct thread *td) +mixer_ioctl(struct dev_ioctl_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; + u_long cmd = ap->a_cmd; + caddr_t arg = ap->a_data; + int mode = ap->a_fflag; struct snddev_info *d; int ret; @@ -1394,7 +1399,7 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi) * If probing the device handling the ioctl, make sure it's a mixer * device. (This ioctl is valid on audio, mixer, and midi devices.) */ - if (mi->dev == -1 && i_dev->si_devsw != &mixer_cdevsw) + if (mi->dev == -1 && i_dev->si_ops != &mixer_cdevsw) return (EINVAL); d = NULL; diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c index b455e39c01..9ef1857822 100644 --- a/sys/dev/sound/pcm/sndstat.c +++ b/sys/dev/sound/pcm/sndstat.c @@ -47,13 +47,11 @@ static d_open_t sndstat_open; static d_close_t sndstat_close; static d_read_t sndstat_read; -static struct cdevsw sndstat_cdevsw = { - .d_version = D_VERSION, +static struct dev_ops sndstat_cdevsw = { + { "sndstat", 0, 0 }, .d_open = sndstat_open, .d_close = sndstat_close, .d_read = sndstat_read, - .d_name = "sndstat", - .d_flags = D_TRACKCLOSE, }; struct sndstat_entry { @@ -129,8 +127,10 @@ SYSCTL_PROC(_hw_snd, OID_AUTO, verbose, CTLTYPE_INT | CTLFLAG_RW, 0, sizeof(int), sysctl_hw_sndverbose, "I", "verbosity level"); static int -sndstat_open(struct cdev *i_dev, int flags, int mode, struct thread *td) +sndstat_open(struct dev_open_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; + if (sndstat_dev == NULL || i_dev != sndstat_dev) return EBADF; @@ -151,8 +151,10 @@ sndstat_open(struct cdev *i_dev, int flags, int mode, struct thread *td) } static int -sndstat_close(struct cdev *i_dev, int flags, int mode, struct thread *td) +sndstat_close(struct dev_close_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; + if (sndstat_dev == NULL || i_dev != sndstat_dev) return EBADF; @@ -171,8 +173,10 @@ sndstat_close(struct cdev *i_dev, int flags, int mode, struct thread *td) } static int -sndstat_read(struct cdev *i_dev, struct uio *buf, int flag) +sndstat_read(struct dev_read_args *ap) { + struct cdev *i_dev = ap->a_head.a_dev; + struct uio *buf = ap->a_uio; int l, err; if (sndstat_dev == NULL || i_dev != sndstat_dev) -- 2.41.0