Commit b7d06f1b authored by Paolo \'Blaisorblade\' Giarrusso's avatar Paolo \'Blaisorblade\' Giarrusso Committed by Linus Torvalds

[PATCH] uml: Folds hostaudio_user.c into hostaudio_kern.c.

Folds hostaudio_user.c into hostaudio_kern.c.  A lot of code less.  Also note
that I no more update ppos(as I used to do in the 2.4 patch): I checked that
OSS never changes ppos, so hostaudio did the right thing.
Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 85b9aa7d
...@@ -15,7 +15,7 @@ mcast-objs := mcast_kern.o mcast_user.o ...@@ -15,7 +15,7 @@ mcast-objs := mcast_kern.o mcast_user.o
#pcap-objs := pcap_kern.o pcap_user.o $(PCAP) #pcap-objs := pcap_kern.o pcap_user.o $(PCAP)
net-objs := net_kern.o net_user.o net-objs := net_kern.o net_user.o
mconsole-objs := mconsole_kern.o mconsole_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 ubd-objs := ubd_kern.o ubd_user.o
port-objs := port_kern.o port_user.o port-objs := port_kern.o port_user.o
harddog-objs := harddog_kern.o harddog_user.o harddog-objs := harddog_kern.o harddog_user.o
......
...@@ -13,7 +13,18 @@ ...@@ -13,7 +13,18 @@
#include "asm/uaccess.h" #include "asm/uaccess.h"
#include "kern_util.h" #include "kern_util.h"
#include "init.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 */ /* Only changed from linux_main at boot time */
char *dsp = HOSTAUDIO_DEV_DSP; char *dsp = HOSTAUDIO_DEV_DSP;
...@@ -61,7 +72,7 @@ static ssize_t hostaudio_read(struct file *file, char *buffer, size_t count, ...@@ -61,7 +72,7 @@ static ssize_t hostaudio_read(struct file *file, char *buffer, size_t count,
{ {
struct hostaudio_state *state = file->private_data; struct hostaudio_state *state = file->private_data;
void *kbuf; void *kbuf;
int err; int ret;
#ifdef DEBUG #ifdef DEBUG
printk("hostaudio: read called, count = %d\n", count); printk("hostaudio: read called, count = %d\n", count);
...@@ -71,16 +82,16 @@ static ssize_t hostaudio_read(struct file *file, char *buffer, size_t count, ...@@ -71,16 +82,16 @@ static ssize_t hostaudio_read(struct file *file, char *buffer, size_t count,
if(kbuf == NULL) if(kbuf == NULL)
return(-ENOMEM); return(-ENOMEM);
err = hostaudio_read_user(state, kbuf, count, ppos); ret = os_read_file(state->fd, kbuf, count);
if(err < 0) if(ret < 0)
goto out; goto out;
if(copy_to_user(buffer, kbuf, err)) if(copy_to_user(buffer, kbuf, ret))
err = -EFAULT; ret = -EFAULT;
out: out:
kfree(kbuf); kfree(kbuf);
return(err); return(ret);
} }
static ssize_t hostaudio_write(struct file *file, const char *buffer, static ssize_t hostaudio_write(struct file *file, const char *buffer,
...@@ -88,7 +99,7 @@ static ssize_t hostaudio_write(struct file *file, const char *buffer, ...@@ -88,7 +99,7 @@ static ssize_t hostaudio_write(struct file *file, const char *buffer,
{ {
struct hostaudio_state *state = file->private_data; struct hostaudio_state *state = file->private_data;
void *kbuf; void *kbuf;
int err; int ret;
#ifdef DEBUG #ifdef DEBUG
printk("hostaudio: write called, count = %d\n", count); printk("hostaudio: write called, count = %d\n", count);
...@@ -98,17 +109,17 @@ static ssize_t hostaudio_write(struct file *file, const char *buffer, ...@@ -98,17 +109,17 @@ static ssize_t hostaudio_write(struct file *file, const char *buffer,
if(kbuf == NULL) if(kbuf == NULL)
return(-ENOMEM); return(-ENOMEM);
err = -EFAULT; ret = -EFAULT;
if(copy_from_user(kbuf, buffer, count)) if(copy_from_user(kbuf, buffer, count))
goto out; goto out;
err = hostaudio_write_user(state, kbuf, count, ppos); ret = os_write_file(state->fd, kbuf, count);
if(err < 0) if(ret < 0)
goto out; goto out;
out: out:
kfree(kbuf); kfree(kbuf);
return(err); return(ret);
} }
static unsigned int hostaudio_poll(struct file *file, static unsigned int hostaudio_poll(struct file *file,
...@@ -128,7 +139,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file, ...@@ -128,7 +139,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
{ {
struct hostaudio_state *state = file->private_data; struct hostaudio_state *state = file->private_data;
unsigned long data = 0; unsigned long data = 0;
int err; int ret;
#ifdef DEBUG #ifdef DEBUG
printk("hostaudio: ioctl called, cmd = %u\n", cmd); printk("hostaudio: ioctl called, cmd = %u\n", cmd);
...@@ -147,7 +158,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file, ...@@ -147,7 +158,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
break; break;
} }
err = hostaudio_ioctl_user(state, cmd, (unsigned long) &data); ret = os_ioctl_generic(state->fd, cmd, (unsigned long) &data);
switch(cmd){ switch(cmd){
case SNDCTL_DSP_SPEED: case SNDCTL_DSP_SPEED:
...@@ -163,7 +174,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file, ...@@ -163,7 +174,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
break; break;
} }
return(err); return(ret);
} }
static int hostaudio_open(struct inode *inode, struct file *file) static int hostaudio_open(struct inode *inode, struct file *file)
...@@ -182,12 +193,17 @@ static int hostaudio_open(struct inode *inode, struct file *file) ...@@ -182,12 +193,17 @@ static int hostaudio_open(struct inode *inode, struct file *file)
if(file->f_mode & FMODE_READ) r = 1; if(file->f_mode & FMODE_READ) r = 1;
if(file->f_mode & FMODE_WRITE) w = 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){ if(ret < 0){
printk("hostaudio_open failed to open '%s', err = %d\n",
dsp, -ret);
kfree(state); kfree(state);
return(ret); return(ret);
} }
state->fd = ret;
file->private_data = state; file->private_data = state;
return(0); return(0);
} }
...@@ -195,16 +211,19 @@ static int hostaudio_open(struct inode *inode, struct file *file) ...@@ -195,16 +211,19 @@ static int hostaudio_open(struct inode *inode, struct file *file)
static int hostaudio_release(struct inode *inode, struct file *file) static int hostaudio_release(struct inode *inode, struct file *file)
{ {
struct hostaudio_state *state = file->private_data; struct hostaudio_state *state = file->private_data;
int ret;
#ifdef DEBUG #ifdef DEBUG
printk("hostaudio: release called\n"); printk("hostaudio: release called\n");
#endif #endif
ret = hostaudio_release_user(state); if(state->fd >= 0){
os_close_file(state->fd);
state->fd = -1;
}
kfree(state); kfree(state);
return(ret); return(0);
} }
/* /dev/mixer file operations */ /* /dev/mixer file operations */
...@@ -218,7 +237,7 @@ static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file, ...@@ -218,7 +237,7 @@ static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file,
printk("hostmixer: ioctl called\n"); printk("hostmixer: ioctl called\n");
#endif #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) static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
...@@ -237,13 +256,17 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file) ...@@ -237,13 +256,17 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
if(file->f_mode & FMODE_READ) r = 1; if(file->f_mode & FMODE_READ) r = 1;
if(file->f_mode & FMODE_WRITE) w = 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){ if(ret < 0){
printk("hostaudio_open_mixdev failed to open '%s', err = %d\n",
dsp, -ret);
kfree(state); kfree(state);
return(ret); return(ret);
} }
state->fd = ret;
file->private_data = state; file->private_data = state;
return(0); return(0);
} }
...@@ -251,16 +274,18 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file) ...@@ -251,16 +274,18 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
static int hostmixer_release(struct inode *inode, struct file *file) static int hostmixer_release(struct inode *inode, struct file *file)
{ {
struct hostmixer_state *state = file->private_data; struct hostmixer_state *state = file->private_data;
int ret;
#ifdef DEBUG #ifdef DEBUG
printk("hostmixer: release called\n"); printk("hostmixer: release called\n");
#endif #endif
ret = hostmixer_release_mixdev_user(state); if(state->fd >= 0){
os_close_file(state->fd);
state->fd = -1;
}
kfree(state); kfree(state);
return(ret); return(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:
*/
/*
* 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:
*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment