Page MenuHomeFreeBSD

D59071.id.diff
No OneTemporary

D59071.id.diff

diff --git a/sys/dev/sound/pci/es137x.c b/sys/dev/sound/pci/es137x.c
--- a/sys/dev/sound/pci/es137x.c
+++ b/sys/dev/sound/pci/es137x.c
@@ -1516,7 +1516,7 @@
dev = oidp->oid_arg1;
d = device_get_softc(dev);
- if (!PCM_REGISTERED(d) || d->mixer_dev == NULL || d->mixer == NULL)
+ if (!PCM_REGISTERED(d) || !MIXER_REGISTERED(d->mixer))
return (EINVAL);
es = d->devinfo;
if (es == NULL)
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -725,9 +725,9 @@
return (ret);
}
- if (d->mixer_dev != NULL) {
+ if (MIXER_REGISTERED(d->mixer)) {
PCM_ACQUIRE_QUICK(d);
- ret = mixer_ioctl_cmd(d->mixer_dev, cmd, arg, -1, td);
+ ret = mixer_ioctl_cmd(d->mixer->cdev, cmd, arg, -1, td);
PCM_RELEASE_QUICK(d);
} else
ret = EBADF;
@@ -1510,9 +1510,9 @@
return (ret);
}
- if (d->mixer_dev != NULL) {
+ if (MIXER_REGISTERED(d->mixer)) {
PCM_ACQUIRE_QUICK(d);
- ret = mixer_ioctl_cmd(d->mixer_dev, xcmd, arg, -1, td);
+ ret = mixer_ioctl_cmd(d->mixer->cdev, xcmd, arg, -1, td);
PCM_RELEASE_QUICK(d);
} else
ret = ENOTSUP;
@@ -1522,9 +1522,9 @@
case SNDCTL_DSP_GET_RECSRC_NAMES:
case SNDCTL_DSP_GET_RECSRC:
case SNDCTL_DSP_SET_RECSRC:
- if (d->mixer_dev != NULL) {
+ if (MIXER_REGISTERED(d->mixer)) {
PCM_ACQUIRE_QUICK(d);
- ret = mixer_ioctl_cmd(d->mixer_dev, cmd, arg, -1, td);
+ ret = mixer_ioctl_cmd(d->mixer->cdev, cmd, arg, -1, td);
PCM_RELEASE_QUICK(d);
} else
ret = ENOTSUP;
@@ -2195,7 +2195,7 @@
strlcpy(ai->cmd, CHN_COMM_UNKNOWN, sizeof(ai->cmd));
ai->card_number = unit;
ai->port_number = unit;
- ai->mixer_dev = (d->mixer_dev != NULL) ? unit : -1;
+ ai->mixer_dev = MIXER_REGISTERED(d->mixer) ? unit : -1;
ai->legacy_device = unit;
snprintf(ai->devnode, sizeof(ai->devnode), "/dev/dsp%d", unit);
ai->enabled = device_is_attached(d->dev) ? 1 : 0;
@@ -2441,7 +2441,7 @@
* @todo @c port_number - routing information?
*/
ai->port_number = unit;
- ai->mixer_dev = (d->mixer_dev != NULL) ? unit : -1;
+ ai->mixer_dev = MIXER_REGISTERED(d->mixer) ? unit : -1;
/**
* @note
* @c legacy_device - OSSv4 docs: "Obsolete."
diff --git a/sys/dev/sound/pcm/mixer.h b/sys/dev/sound/pcm/mixer.h
--- a/sys/dev/sound/pcm/mixer.h
+++ b/sys/dev/sound/pcm/mixer.h
@@ -34,6 +34,8 @@
#ifndef _PCM_MIXER_H_
#define _PCM_MIXER_H_
+#define MIXER_REGISTERED(x) ((x) != NULL && (x)->cdev != NULL)
+
#define MIXER_NAMELEN 16
struct snd_mixer {
KOBJ_FIELDS;
@@ -54,6 +56,7 @@
char name[MIXER_NAMELEN];
struct mtx lock;
int modify_counter;
+ struct cdev *cdev;
};
struct snd_mixer *mixer_create(device_t dev, kobj_class_t cls, void *devinfo,
diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c
--- a/sys/dev/sound/pcm/mixer.c
+++ b/sys/dev/sound/pcm/mixer.c
@@ -679,13 +679,9 @@
mixer_uninit(device_t dev)
{
int i;
- struct snddev_info *d;
struct snd_mixer *m;
- d = device_get_softc(dev);
- if (d == NULL)
- return EBADF;
- m = d->mixer;
+ m = mixer_get_devt(dev);
KASSERT(m != NULL, ("NULL snd_mixer"));
KASSERT(m->type == MIXER_TYPE_PRIMARY,
@@ -695,9 +691,9 @@
* snd_uaudio(4) in particular can call mixer_uninit() directly if
* attach failed prior to pcm_register(), in which case the cdev will
* not have been created. Do not call destroy_dev() unconditionally.
- */
- if (d->mixer_dev != NULL)
- destroy_dev(d->mixer_dev);
+ */
+ if (MIXER_REGISTERED(m))
+ destroy_dev(m->cdev);
mtx_lock(&m->lock);
@@ -715,9 +711,6 @@
mtx_destroy(&m->lock);
kobj_delete((kobj_t)m, M_DEVBUF);
- d->mixer_dev = NULL;
- d->mixer = NULL;
-
return 0;
}
@@ -765,7 +758,7 @@
devargs.mda_gid = GID_AUDIO;
devargs.mda_mode = 0660;
devargs.mda_si_drv1 = sc->mixer;
- err = make_dev_s(&devargs, &sc->mixer_dev, "mixer%d", unit);
+ err = make_dev_s(&devargs, &sc->mixer->cdev, "mixer%d", unit);
if (err != 0) {
device_printf(dev, "failed to create mixer%d: error %d\n",
unit, err);
@@ -1148,8 +1141,8 @@
bus_topo_lock();
d = devclass_get_softc(pcm_devclass, snd_unit);
/* See related comment in dsp_clone(). */
- if (PCM_REGISTERED(d) && d->mixer_dev != NULL) {
- *dev = d->mixer_dev;
+ if (PCM_REGISTERED(d) && MIXER_REGISTERED(d->mixer)) {
+ *dev = d->mixer->cdev;
dev_ref(*dev);
}
bus_topo_unlock();
@@ -1246,17 +1239,21 @@
PCM_UNLOCKASSERT(d);
PCM_LOCK(d);
- if (!((d->mixer_dev == i_dev && mi->dev == -1) ||
- mi->dev == i)) {
+ if (!MIXER_REGISTERED(d->mixer)) {
+ if (mi->dev == i) {
+ mixer_oss_mixerinfo_unavail(mi, i);
+ PCM_UNLOCK(d);
+ bus_topo_unlock();
+ return (0);
+ }
PCM_UNLOCK(d);
continue;
}
- if (d->mixer == NULL) {
- mixer_oss_mixerinfo_unavail(mi, i);
+ if (!((d->mixer->cdev == i_dev && mi->dev == -1) ||
+ mi->dev == i)) {
PCM_UNLOCK(d);
- bus_topo_unlock();
- return (0);
+ continue;
}
m = d->mixer;
diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h
--- a/sys/dev/sound/pcm/sound.h
+++ b/sys/dev/sound/pcm/sound.h
@@ -189,7 +189,6 @@
device_t dev;
char status[SND_STATUSLEN];
struct mtx lock;
- struct cdev *mixer_dev;
struct cdev *dsp_dev;
struct snd_mixer *mixer;
uint32_t pvchanrate, pvchanformat, pvchanmode;

File Metadata

Mime Type
text/plain
Expires
Sun, Aug 23, 2:37 AM (9 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37085830
Default Alt Text
D59071.id.diff (5 KB)

Event Timeline