summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2016-01-29 15:14:24 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2016-01-29 15:14:24 +0000
commit0fd8fa093401f537db96978768045221df65b527 (patch)
treee3a96a00314a900da7c149874035b679ce7fc760 /sys
parent9457b1cd4b9f5b6127237b8828a587ce19716929 (diff)
Move the AUDIO_GETDEV ioctl in its own routine.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/audio.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c
index cc6e8ccd29f..1271bc77517 100644
--- a/sys/dev/audio.c
+++ b/sys/dev/audio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: audio.c,v 1.143 2016/01/20 19:01:39 ratchov Exp $ */
+/* $OpenBSD: audio.c,v 1.144 2016/01/29 15:14:23 ratchov Exp $ */
/*
* Copyright (c) 2015 Alexandre Ratchov <alex@caoua.org>
*
@@ -1532,6 +1532,16 @@ audio_write(struct audio_softc *sc, struct uio *uio, int ioflag)
}
int
+audio_getdev(struct audio_softc *sc, struct audio_device *adev)
+{
+ memset(adev, 0, sizeof(struct audio_device));
+ if (sc->dev.dv_parent == NULL)
+ return EIO;
+ strlcpy(adev->name, sc->dev.dv_parent->dv_xname, MAX_AUDIO_DEV_LEN);
+ return 0;
+}
+
+int
audio_ioctl(struct audio_softc *sc, unsigned long cmd, void *addr)
{
struct audio_offset *ao;
@@ -1584,11 +1594,7 @@ audio_ioctl(struct audio_softc *sc, unsigned long cmd, void *addr)
error = audio_getinfo(sc, (struct audio_info *)addr);
break;
case AUDIO_GETDEV:
- memset(addr, 0, sizeof(struct audio_device));
- if (sc->dev.dv_parent)
- strlcpy(((struct audio_device *)addr)->name,
- sc->dev.dv_parent->dv_xname,
- MAX_AUDIO_DEV_LEN);
+ error = audio_getdev(sc, (struct audio_device *)addr);
break;
case AUDIO_GETENC:
error = sc->ops->query_encoding(sc->arg,