summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdike <jdike>2004-02-16 00:09:15 +0000
committerjdike <jdike>2004-02-16 00:09:15 +0000
commit9e81c34c7f79a831eeb1a6d036f5c98c7e041aff (patch)
treebff44a4edaec817dcfe39938c33c92a3d35c19d9
parent4577f0cfd6f2a056e1e260f05aa925f026bcc23b (diff)
downloaduml-history-9e81c34c7f79a831eeb1a6d036f5c98c7e041aff.tar.gz
Got rid of the userspace part of this driver in favor of calling straight into
the os layer.
-rw-r--r--arch/um/drivers/Makefile2
-rw-r--r--arch/um/drivers/hostaudio_kern.c42
-rw-r--r--arch/um/drivers/hostaudio_user.c130
-rw-r--r--arch/um/include/hostaudio.h48
4 files changed, 29 insertions, 193 deletions
diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile
index d07f6fa..c861de5 100644
--- a/arch/um/drivers/Makefile
+++ b/arch/um/drivers/Makefile
@@ -18,7 +18,7 @@ pcap-objs := pcap_kern.o pcap_user.o
pcap-libs := -lpcap -L/usr/lib
net-objs := net_kern.o net_user.o
mconsole-objs := mconsole_kern.o mconsole_user.o
-hostaudio-objs := hostaudio_kern.o hostaudio_user.o
+hostaudio-objs := hostaudio_kern.o
ubd-objs := ubd_kern.o ubd_user.o
port-objs := port_kern.o port_user.o
harddog-objs := harddog_kern.o harddog_user.o
diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c
index 9f9ae27..ebc29f2 100644
--- a/arch/um/drivers/hostaudio_kern.c
+++ b/arch/um/drivers/hostaudio_kern.c
@@ -13,7 +13,18 @@
#include "asm/uaccess.h"
#include "kern_util.h"
#include "init.h"
-#include "hostaudio.h"
+#include "os.h"
+
+struct hostaudio_state {
+ int fd;
+};
+
+struct hostmixer_state {
+ int fd;
+};
+
+#define HOSTAUDIO_DEV_DSP "/dev/sound/dsp"
+#define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer"
/* Only changed from linux_main at boot time */
char *dsp = HOSTAUDIO_DEV_DSP;
@@ -71,7 +82,7 @@ static ssize_t hostaudio_read(struct file *file, char *buffer, size_t count,
if(kbuf == NULL)
return(-ENOMEM);
- err = hostaudio_read_user(state, kbuf, count, ppos);
+ err = os_read_file(state->fd, kbuf, count);
if(err < 0)
goto out;
@@ -102,9 +113,10 @@ static ssize_t hostaudio_write(struct file *file, const char *buffer,
if(copy_from_user(kbuf, buffer, count))
goto out;
- err = hostaudio_write_user(state, kbuf, count, ppos);
+ err = os_write_file(state->fd, kbuf, count);
if(err < 0)
goto out;
+ *ppos += err;
out:
kfree(kbuf);
@@ -147,7 +159,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
break;
}
- err = hostaudio_ioctl_user(state, cmd, (unsigned long) &data);
+ err = os_ioctl_generic(state->fd, cmd, (unsigned long) &data);
switch(cmd){
case SNDCTL_DSP_SPEED:
@@ -177,17 +189,19 @@ static int hostaudio_open(struct inode *inode, struct file *file)
#endif
state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL);
- if(state == NULL) return(-ENOMEM);
+ if(state == NULL)
+ return(-ENOMEM);
if(file->f_mode & FMODE_READ) r = 1;
if(file->f_mode & FMODE_WRITE) w = 1;
- ret = hostaudio_open_user(state, r, w, dsp);
+ ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
if(ret < 0){
kfree(state);
return(ret);
}
+ state->fd = ret;
file->private_data = state;
return(0);
}
@@ -195,16 +209,15 @@ static int hostaudio_open(struct inode *inode, struct file *file)
static int hostaudio_release(struct inode *inode, struct file *file)
{
struct hostaudio_state *state = file->private_data;
- int ret;
#ifdef DEBUG
printk("hostaudio: release called\n");
#endif
- ret = hostaudio_release_user(state);
+ os_close_file(state->fd);
kfree(state);
- return(ret);
+ return(0);
}
/* /dev/mixer file operations */
@@ -218,7 +231,7 @@ static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file,
printk("hostmixer: ioctl called\n");
#endif
- return(hostmixer_ioctl_mixdev_user(state, cmd, arg));
+ return(os_ioctl_generic(state->fd, cmd, arg));
}
static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
@@ -237,9 +250,11 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
if(file->f_mode & FMODE_READ) r = 1;
if(file->f_mode & FMODE_WRITE) w = 1;
- ret = hostmixer_open_mixdev_user(state, r, w, mixer);
+ ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
if(ret < 0){
+ printk("hostaudio_open_mixdev failed to open '%s', err = %d\n",
+ dsp, -ret);
kfree(state);
return(ret);
}
@@ -251,16 +266,15 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
static int hostmixer_release(struct inode *inode, struct file *file)
{
struct hostmixer_state *state = file->private_data;
- int ret;
#ifdef DEBUG
printk("hostmixer: release called\n");
#endif
- ret = hostmixer_release_mixdev_user(state);
+ os_close_file(state->fd);
kfree(state);
- return(ret);
+ return(0);
}
diff --git a/arch/um/drivers/hostaudio_user.c b/arch/um/drivers/hostaudio_user.c
deleted file mode 100644
index 4cf1f15..0000000
--- a/arch/um/drivers/hostaudio_user.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2002 Steve Schmidtke
- * Licensed under the GPL
- */
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <errno.h>
-#include "hostaudio.h"
-#include "user_util.h"
-#include "kern_util.h"
-#include "user.h"
-#include "os.h"
-
-/* /dev/dsp file operations */
-
-ssize_t hostaudio_read_user(struct hostaudio_state *state, char *buffer,
- size_t count, loff_t *ppos)
-{
-#ifdef DEBUG
- printk("hostaudio: read_user called, count = %d\n", count);
-#endif
-
- return(os_read_file(state->fd, buffer, count));
-}
-
-ssize_t hostaudio_write_user(struct hostaudio_state *state, const char *buffer,
- size_t count, loff_t *ppos)
-{
-#ifdef DEBUG
- printk("hostaudio: write_user called, count = %d\n", count);
-#endif
-
- return(os_write_file(state->fd, buffer, count));
-}
-
-int hostaudio_ioctl_user(struct hostaudio_state *state, unsigned int cmd,
- unsigned long arg)
-{
-#ifdef DEBUG
- printk("hostaudio: ioctl_user called, cmd = %u\n", cmd);
-#endif
-
- return(os_ioctl_generic(state->fd, cmd, arg));
-}
-
-int hostaudio_open_user(struct hostaudio_state *state, int r, int w, char *dsp)
-{
-#ifdef DEBUG
- printk("hostaudio: open_user called\n");
-#endif
-
- state->fd = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
-
- if(state->fd < 0) {
- printk("hostaudio_open_user failed to open '%s', err = %d\n",
- dsp, -state->fd);
- return(state->fd);
- }
-
- return(0);
-}
-
-int hostaudio_release_user(struct hostaudio_state *state)
-{
-#ifdef DEBUG
- printk("hostaudio: release called\n");
-#endif
- if(state->fd >= 0){
- os_close_file(state->fd);
- state->fd = -1;
- }
-
- return(0);
-}
-
-/* /dev/mixer file operations */
-
-int hostmixer_ioctl_mixdev_user(struct hostmixer_state *state,
- unsigned int cmd, unsigned long arg)
-{
-#ifdef DEBUG
- printk("hostmixer: ioctl_user called cmd = %u\n",cmd);
-#endif
-
- return(os_ioctl_generic(state->fd, cmd, arg));
-}
-
-int hostmixer_open_mixdev_user(struct hostmixer_state *state, int r, int w,
- char *mixer)
-{
-#ifdef DEBUG
- printk("hostmixer: open_user called\n");
-#endif
-
- state->fd = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
-
- if(state->fd < 0) {
- printk("hostaudio_open_mixdev_user failed to open '%s', "
- "err = %d\n", mixer, state->fd);
- return(state->fd);
- }
-
- return(0);
-}
-
-int hostmixer_release_mixdev_user(struct hostmixer_state *state)
-{
-#ifdef DEBUG
- printk("hostmixer: release_user called\n");
-#endif
-
- if(state->fd >= 0){
- os_close_file(state->fd);
- state->fd = -1;
- }
-
- return 0;
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/include/hostaudio.h b/arch/um/include/hostaudio.h
deleted file mode 100644
index 797b3f2..0000000
--- a/arch/um/include/hostaudio.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2002 Steve Schmidtke
- * Licensed under the GPL
- */
-
-#ifndef HOSTAUDIO_H
-#define HOSTAUDIO_H
-
-#define HOSTAUDIO_DEV_DSP "/dev/sound/dsp"
-#define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer"
-
-struct hostaudio_state {
- int fd;
-};
-
-struct hostmixer_state {
- int fd;
-};
-
-/* UML user-side protoypes */
-extern ssize_t hostaudio_read_user(struct hostaudio_state *state, char *buffer,
- size_t count, loff_t *ppos);
-extern ssize_t hostaudio_write_user(struct hostaudio_state *state,
- const char *buffer, size_t count,
- loff_t *ppos);
-extern int hostaudio_ioctl_user(struct hostaudio_state *state,
- unsigned int cmd, unsigned long arg);
-extern int hostaudio_open_user(struct hostaudio_state *state, int r, int w,
- char *dsp);
-extern int hostaudio_release_user(struct hostaudio_state *state);
-extern int hostmixer_ioctl_mixdev_user(struct hostmixer_state *state,
- unsigned int cmd, unsigned long arg);
-extern int hostmixer_open_mixdev_user(struct hostmixer_state *state, int r,
- int w, char *mixer);
-extern int hostmixer_release_mixdev_user(struct hostmixer_state *state);
-
-#endif /* HOSTAUDIO_H */
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */