* [uml-devel] First shrinkage of *_user.c files
@ 2004-01-20 19:26 BlaisorBlade
2004-01-20 20:34 ` [uml-devel] " Jeff Dike
2004-01-21 19:19 ` [uml-devel] " BlaisorBlade
0 siblings, 2 replies; 5+ messages in thread
From: BlaisorBlade @ 2004-01-20 19:26 UTC (permalink / raw)
To: user-mode-linux-devel; +Cc: Jeff Dike
[-- Attachment #1: Type: text/plain, Size: 478 bytes --]
I've started removing some functions from the user_objs, and here there are
the two first patches. Any comment on the style of these changes is highly
appreciated. The next thing I'm going to do is to remove entirely
hostaudio_user.c (I've already started this, but I've not got a successful
test yet, since I also did a little fix in this).
Bye
--
cat <<EOSIGN
Paolo Giarrusso, aka Blaisorblade
Linux Kernel 2.4.23/2.6.0 on an i686; Linux registered user n. 292729
EOSIGN
[-- Attachment #2: Os_expand_1.diff --]
[-- Type: text/x-diff, Size: 2182 bytes --]
--- ./arch/um/include/os.h.fix 2004-01-17 18:41:12.000000000 +0100
+++ ./arch/um/include/os.h 2004-01-19 20:54:48.000000000 +0100
@@ -130,6 +130,7 @@
extern int os_set_slip(int fd);
extern int os_set_owner(int fd, int pid);
extern int os_sigio_async(int master, int slave);
+extern int os_make_pty_raw(int master);
extern int os_mode_fd(int fd, int mode);
extern int os_seek_file(int fd, __u64 offset);
--- ./arch/um/kernel/sigio_user.c.fix 2004-01-17 18:41:14.000000000 +0100
+++ ./arch/um/kernel/sigio_user.c 2004-01-19 21:00:50.000000000 +0100
@@ -50,7 +50,6 @@
void __init check_one_sigio(void (*proc)(int, int))
{
struct sigaction old, new;
- struct termios tt;
struct openpty_arg pty = { .master = -1, .slave = -1 };
int master, slave, err;
@@ -68,12 +67,9 @@
return;
}
- /* XXX These can fail with EINTR */
- if(tcgetattr(master, &tt) < 0)
- panic("check_sigio : tcgetattr failed, errno = %d\n", errno);
- cfmakeraw(&tt);
- if(tcsetattr(master, TCSADRAIN, &tt) < 0)
- panic("check_sigio : tcsetattr failed, errno = %d\n", errno);
+ err = os_make_pty_raw(master);
+ if (err < 0)
+ panic("check_sigio : os_make_pty_raw failed, errno = %d\n", -err);
err = os_sigio_async(master, slave);
if(err < 0)
--- ./arch/um/os-Linux/file.c.fix 2004-01-17 18:41:19.000000000 +0100
+++ ./arch/um/os-Linux/file.c 2004-01-19 21:24:27.000000000 +0100
@@ -8,6 +8,7 @@
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
+#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
@@ -132,6 +133,32 @@
return(0);
}
+int os_make_pty_raw(int master)
+{
+ struct termios tt;
+ int err;
+
+ while (((err = tcgetattr(master, &tt)) < 0) && errno == EINTR)
+ ;
+ if(err < 0) {
+ printk("os_make_pty_raw : tcgetattr failed, errno = %d\n", errno);
+ goto fail;
+ }
+
+ cfmakeraw(&tt);
+
+ while (((err = tcsetattr(master, TCSADRAIN, &tt)) < 0) && errno == EINTR)
+ ;
+ if(err < 0) {
+ printk("os_make_pty_raw : tcsetattr failed, errno = %d\n", errno);
+ goto fail;
+ }
+
+ return 0;
+fail:
+ return -errno;
+}
+
/* FIXME: ensure namebuf in os_get_if_name is big enough */
int os_get_ifname(int fd, char* namebuf)
{
[-- Attachment #3: Os_expand_2.diff --]
[-- Type: text/x-diff, Size: 2439 bytes --]
--- ./arch/um/drivers/chan_kern.c.fix 2004-01-17 18:41:10.000000000 +0100
+++ ./arch/um/drivers/chan_kern.c 2004-01-19 21:34:30.000000000 +0100
@@ -17,6 +17,7 @@
#include "irq_user.h"
#include "sigio.h"
#include "line.h"
+#include "os.h"
static void *not_configged_init(char *str, int device, struct chan_opts *opts)
{
@@ -87,6 +88,52 @@
.winch = 0,
};
+void generic_close(int fd, void *unused)
+{
+ os_close_file(fd);
+}
+
+int generic_read(int fd, char *c_out, void *unused)
+{
+ int n;
+
+ n = os_read_file(fd, c_out, sizeof(*c_out));
+
+ if(n == -EAGAIN)
+ return(0);
+ else if(n == 0)
+ return(-EIO);
+ return(n);
+}
+
+int generic_write(int fd, const char *buf, int n, void *unused)
+{
+ return(os_write_file(fd, buf, n));
+}
+
+int generic_window_size(int fd, void *unused, unsigned short *rows_out,
+ unsigned short *cols_out)
+{
+ int rows, cols;
+ int ret;
+
+ ret = os_window_size(fd, &rows, &cols);
+ if(ret < 0)
+ return(ret);
+
+ ret = ((*rows_out != rows) || (*cols_out != cols));
+
+ *rows_out = rows;
+ *cols_out = cols;
+
+ return(ret);
+}
+
+void generic_free(void *data)
+{
+ kfree(data);
+}
+
static void tty_receive_char(struct tty_struct *tty, char ch)
{
if(tty == NULL) return;
--- ./arch/um/drivers/chan_user.c.fix 2004-01-17 18:41:10.000000000 +0100
+++ ./arch/um/drivers/chan_user.c 2004-01-19 21:32:03.000000000 +0100
@@ -21,31 +21,6 @@
#include "choose-mode.h"
#include "mode.h"
-void generic_close(int fd, void *unused)
-{
- os_close_file(fd);
-}
-
-int generic_read(int fd, char *c_out, void *unused)
-{
- int n;
-
- n = os_read_file(fd, c_out, sizeof(*c_out));
-
- if(n == -EAGAIN)
- return(0);
- else if(n == 0)
- return(-EIO);
- return(n);
-}
-
-/* XXX Trivial wrapper around os_write_file */
-
-int generic_write(int fd, const char *buf, int n, void *unused)
-{
- return(os_write_file(fd, buf, n));
-}
-
int generic_console_write(int fd, const char *buf, int n, void *unused)
{
struct termios save, new;
@@ -62,29 +37,6 @@
return(err);
}
-int generic_window_size(int fd, void *unused, unsigned short *rows_out,
- unsigned short *cols_out)
-{
- int rows, cols;
- int ret;
-
- ret = os_window_size(fd, &rows, &cols);
- if(ret < 0)
- return(ret);
-
- ret = ((*rows_out != rows) || (*cols_out != cols));
-
- *rows_out = rows;
- *cols_out = cols;
-
- return(ret);
-}
-
-void generic_free(void *data)
-{
- kfree(data);
-}
-
static void winch_handler(int sig)
{
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [uml-devel] Re: First shrinkage of *_user.c files
2004-01-20 19:26 [uml-devel] First shrinkage of *_user.c files BlaisorBlade
@ 2004-01-20 20:34 ` Jeff Dike
2004-01-21 19:29 ` BlaisorBlade
2004-01-21 19:19 ` [uml-devel] " BlaisorBlade
1 sibling, 1 reply; 5+ messages in thread
From: Jeff Dike @ 2004-01-20 20:34 UTC (permalink / raw)
To: BlaisorBlade; +Cc: user-mode-linux-devel
blaisorblade_spam@yahoo.it said:
> I've started removing some functions from the user_objs, and here
> there are the two first patches. Any comment on the style of these
> changes is highly appreciated. The next thing I'm going to do is to
> remove entirely hostaudio_user.c (I've already started this, but I've
> not got a successful test yet, since I also did a little fix in
> this).
Yeah, that's the style I'm looking for. The goal should be to eliminate
anything outside of arch/um/os needing any libc headers.
Try to extract the essence of the libc dependency into arch/um/os rather
than just moving large chunks of code there, which looks like what you're
doing.
Jeff
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [uml-devel] First shrinkage of *_user.c files
2004-01-20 19:26 [uml-devel] First shrinkage of *_user.c files BlaisorBlade
2004-01-20 20:34 ` [uml-devel] " Jeff Dike
@ 2004-01-21 19:19 ` BlaisorBlade
2004-02-13 23:55 ` Jeff Dike
1 sibling, 1 reply; 5+ messages in thread
From: BlaisorBlade @ 2004-01-21 19:19 UTC (permalink / raw)
To: user-mode-linux-devel; +Cc: Jeff Dike
[-- Attachment #1: Type: text/plain, Size: 849 bytes --]
Alle 20:26, martedì 20 gennaio 2004, BlaisorBlade ha scritto:
> The next thing I'm going to do is to remove entirely
> hostaudio_user.c (I've already started this, but I've not got a successful
> test yet, since I also did a little fix in this).
Now I've got a successful test (the host /dev/dsp was locked by KDE's Arts).
However, when testing it with /dev/dsp locked, UML freezes completely (I
think this happens anyway, since the open() is called without O_NONBLOCK and
so it seems obvious why it locks). The export_ioctl adds a missing
EXPORT_SYMBOL, while Os_expand_3 is a less intrusive version of
Hostaudio_clean_and_fix, that doesn't fold the _user calls inside the other
ones.
Bye
--
cat <<EOSIGN
Paolo Giarrusso, aka Blaisorblade
Linux Kernel 2.4.23/2.6.0 on an i686; Linux registered user n. 292729
EOSIGN
[-- Attachment #2: Export_ioctl.diff --]
[-- Type: text/x-diff, Size: 362 bytes --]
--- ./arch/um/kernel/ksyms.c.fix 2004-01-17 18:41:14.000000000 +0100
+++ ./arch/um/kernel/ksyms.c 2004-01-20 17:47:26.000000000 +0100
@@ -69,6 +69,7 @@
EXPORT_SYMBOL(os_write_file);
EXPORT_SYMBOL(os_seek_file);
EXPORT_SYMBOL(os_lock_file);
+EXPORT_SYMBOL(os_ioctl_generic);
EXPORT_SYMBOL(os_pipe);
EXPORT_SYMBOL(os_file_type);
EXPORT_SYMBOL(os_file_mode);
[-- Attachment #3: Os_expand_3.diff --]
[-- Type: text/x-diff, Size: 8829 bytes --]
--- ./arch/um/drivers/hostaudio_kern.c.fix 2004-01-17 18:41:10.000000000 +0100
+++ ./arch/um/drivers/hostaudio_kern.c 2004-01-20 16:28:31.000000000 +0100
@@ -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;
@@ -56,6 +67,66 @@
/* /dev/dsp file operations */
+static inline 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));
+}
+
+static inline 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));
+}
+
+static inline 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));
+}
+
+static inline 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);
+}
+
+static inline 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);
+}
+
static ssize_t hostaudio_read(struct file *file, char *buffer, size_t count,
loff_t *ppos)
{
@@ -209,6 +280,48 @@
/* /dev/mixer file operations */
+static inline 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));
+}
+
+static inline 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);
+}
+
+static inline 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;
+}
+
static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
--- ./arch/um/drivers/hostaudio_user.c.fix 2004-01-17 18:41:10.000000000 +0100
+++ ./arch/um/drivers/hostaudio_user.c 1970-01-01 01:00:00.000000000 +0100
@@ -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:
- */
--- ./arch/um/drivers/Makefile.fix 2004-01-18 10:07:33.000000000 +0100
+++ ./arch/um/drivers/Makefile 2004-01-20 16:25:14.000000000 +0100
@@ -15,7 +15,7 @@
#pcap-objs := pcap_kern.o pcap_user.o $(PCAP)
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
--- ./arch/um/include/hostaudio.h.fix 2003-12-20 16:58:43.000000000 +0100
+++ ./arch/um/include/hostaudio.h 1970-01-01 01:00:00.000000000 +0100
@@ -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:
- */
[-- Attachment #4: Hostaudio_clean_and_fix.diff --]
[-- Type: text/x-diff, Size: 10010 bytes --]
--- ./arch/um/drivers/hostaudio_kern.c.fix 2004-01-20 17:42:12.000000000 +0100
+++ ./arch/um/drivers/hostaudio_kern.c 2004-01-21 20:13:17.000000000 +0100
@@ -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;
@@ -61,7 +72,7 @@
{
struct hostaudio_state *state = file->private_data;
void *kbuf;
- int err;
+ int ret;
#ifdef DEBUG
printk("hostaudio: read called, count = %d\n", count);
@@ -71,16 +82,18 @@
if(kbuf == NULL)
return(-ENOMEM);
- err = hostaudio_read_user(state, kbuf, count, ppos);
- if(err < 0)
+ ret = os_read_file(state->fd, kbuf, count);
+ if(ret < 0)
goto out;
- if(copy_to_user(buffer, kbuf, err))
- err = -EFAULT;
+ if(copy_to_user(buffer, kbuf, ret))
+ ret = -EFAULT;
+ else
+ *ppos += ret;
out:
kfree(kbuf);
- return(err);
+ return(ret);
}
static ssize_t hostaudio_write(struct file *file, const char *buffer,
@@ -88,7 +101,7 @@
{
struct hostaudio_state *state = file->private_data;
void *kbuf;
- int err;
+ int ret;
#ifdef DEBUG
printk("hostaudio: write called, count = %d\n", count);
@@ -98,17 +111,18 @@
if(kbuf == NULL)
return(-ENOMEM);
- err = -EFAULT;
+ ret = -EFAULT;
if(copy_from_user(kbuf, buffer, count))
goto out;
- err = hostaudio_write_user(state, kbuf, count, ppos);
- if(err < 0)
+ ret = os_write_file(state->fd, kbuf, count);
+ if(ret < 0)
goto out;
+ *ppos += ret;
out:
kfree(kbuf);
- return(err);
+ return(ret);
}
static unsigned int hostaudio_poll(struct file *file,
@@ -128,7 +142,7 @@
{
struct hostaudio_state *state = file->private_data;
unsigned long data = 0;
- int err;
+ int ret;
#ifdef DEBUG
printk("hostaudio: ioctl called, cmd = %u\n", cmd);
@@ -147,7 +161,7 @@
break;
}
- err = hostaudio_ioctl_user(state, cmd, (unsigned long) &data);
+ ret = os_ioctl_generic(state->fd, cmd, (unsigned long) &data);
switch(cmd){
case SNDCTL_DSP_SPEED:
@@ -163,7 +177,7 @@
break;
}
- return(err);
+ return(ret);
}
static int hostaudio_open(struct inode *inode, struct file *file)
@@ -182,12 +196,17 @@
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){
+ printk("hostaudio_open failed to open '%s', err = %d\n",
+ dsp, -ret);
kfree(state);
return(ret);
}
+ state->fd = ret;
+
file->private_data = state;
return(0);
}
@@ -195,16 +214,19 @@
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);
+ if(state->fd >= 0){
+ os_close_file(state->fd);
+ state->fd = -1;
+ }
+
kfree(state);
- return(ret);
+ return(0);
}
/* /dev/mixer file operations */
@@ -218,7 +240,7 @@
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,13 +259,17 @@
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);
}
+ state->fd = ret;
+
file->private_data = state;
return(0);
}
@@ -251,16 +277,18 @@
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);
+ if(state->fd >= 0){
+ os_close_file(state->fd);
+ state->fd = -1;
+ }
kfree(state);
- return(ret);
+ return(0);
}
--- ./arch/um/drivers/hostaudio_user.c.fix 2004-01-17 18:41:10.000000000 +0100
+++ ./arch/um/drivers/hostaudio_user.c 1970-01-01 01:00:00.000000000 +0100
@@ -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:
- */
--- ./arch/um/drivers/Makefile.fix 2004-01-18 10:07:33.000000000 +0100
+++ ./arch/um/drivers/Makefile 2004-01-20 17:48:05.000000000 +0100
@@ -15,7 +15,7 @@
#pcap-objs := pcap_kern.o pcap_user.o $(PCAP)
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
--- ./arch/um/include/hostaudio.h.fix 2003-12-20 16:58:43.000000000 +0100
+++ ./arch/um/include/hostaudio.h 1970-01-01 01:00:00.000000000 +0100
@@ -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:
- */
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [uml-devel] Re: First shrinkage of *_user.c files
2004-01-20 20:34 ` [uml-devel] " Jeff Dike
@ 2004-01-21 19:29 ` BlaisorBlade
0 siblings, 0 replies; 5+ messages in thread
From: BlaisorBlade @ 2004-01-21 19:29 UTC (permalink / raw)
To: Jeff Dike; +Cc: user-mode-linux-devel
Alle 21:34, martedì 20 gennaio 2004, Jeff Dike ha scritto:
> blaisorblade_spam@yahoo.it said:
> > I've started removing some functions from the user_objs, and here
> > there are the two first patches. Any comment on the style of these
> > changes is highly appreciated. The next thing I'm going to do is to
> > remove entirely hostaudio_user.c (I've already started this, but I've
> > not got a successful test yet, since I also did a little fix in
> > this).
>
> Yeah, that's the style I'm looking for. The goal should be to eliminate
> anything outside of arch/um/os needing any libc headers.
>
> Try to extract the essence of the libc dependency into arch/um/os rather
> than just moving large chunks of code there, which looks like what you're
> doing.
I added a function to os- and moved some other ones away from _user files.
The first is not too tiny because some other system could not have the
termios.h abstraction, so it must be more abstract (for Windows it will
probably be a no-op, since there is no support in the OS IMHO).
The moved functions didn't depend on userspace so I just moved them (they are
tiny wrappers but are needed for some structures).
However, see the next patches I posted for more changes.
Bye
--
cat <<EOSIGN
Paolo Giarrusso, aka Blaisorblade
Linux Kernel 2.4.23/2.6.0 on an i686; Linux registered user n. 292729
EOSIGN
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [uml-devel] First shrinkage of *_user.c files
2004-01-21 19:19 ` [uml-devel] " BlaisorBlade
@ 2004-02-13 23:55 ` Jeff Dike
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Dike @ 2004-02-13 23:55 UTC (permalink / raw)
To: BlaisorBlade; +Cc: user-mode-linux-devel
blaisorblade_spam@yahoo.it said:
> The next thing I'm going to do is to remove entirely
> hostaudio_user.c (I've already started this, but I've not got a
> successful test yet, since I also did a little fix in this).
I finally merged this. Now we are one file closer to being able to get
rid of the USER_OBJS crap :-)
Jeff
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-02-13 23:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-20 19:26 [uml-devel] First shrinkage of *_user.c files BlaisorBlade
2004-01-20 20:34 ` [uml-devel] " Jeff Dike
2004-01-21 19:29 ` BlaisorBlade
2004-01-21 19:19 ` [uml-devel] " BlaisorBlade
2004-02-13 23:55 ` Jeff Dike
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox