This stack check implementation leverages the compiler's profiling (gcc -p)
[linux-2.6.git] / arch / um / drivers / hostaudio_user.c
1 /* 
2  * Copyright (C) 2002 Steve Schmidtke 
3  * Licensed under the GPL
4  */
5
6 #include <sys/types.h>
7 #include <unistd.h>
8 #include <errno.h>
9 #include "hostaudio.h"
10 #include "user_util.h"
11 #include "kern_util.h"
12 #include "user.h"
13 #include "os.h"
14
15 /* /dev/dsp file operations */
16
17 ssize_t hostaudio_read_user(struct hostaudio_state *state, char *buffer, 
18                             size_t count, loff_t *ppos)
19 {
20 #ifdef DEBUG
21         printk("hostaudio: read_user called, count = %d\n", count);
22 #endif
23
24         return(os_read_file(state->fd, buffer, count));
25 }
26
27 ssize_t hostaudio_write_user(struct hostaudio_state *state, const char *buffer,
28                              size_t count, loff_t *ppos)
29 {
30 #ifdef DEBUG
31         printk("hostaudio: write_user called, count = %d\n", count);
32 #endif
33
34         return(os_write_file(state->fd, buffer, count));
35 }
36
37 int hostaudio_ioctl_user(struct hostaudio_state *state, unsigned int cmd, 
38                          unsigned long arg)
39 {
40 #ifdef DEBUG
41         printk("hostaudio: ioctl_user called, cmd = %u\n", cmd);
42 #endif
43
44         return(os_ioctl_generic(state->fd, cmd, arg));
45 }
46
47 int hostaudio_open_user(struct hostaudio_state *state, int r, int w, char *dsp)
48 {
49 #ifdef DEBUG
50         printk("hostaudio: open_user called\n");
51 #endif
52
53         state->fd = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
54
55         if(state->fd < 0) {
56                 printk("hostaudio_open_user failed to open '%s', err = %d\n",
57                        dsp, -state->fd);
58                 return(state->fd); 
59         }
60         
61         return(0);
62 }
63
64 int hostaudio_release_user(struct hostaudio_state *state)
65 {
66 #ifdef DEBUG
67         printk("hostaudio: release called\n");
68 #endif
69         if(state->fd >= 0){
70                 os_close_file(state->fd);
71                 state->fd = -1;
72         }
73
74         return(0);
75 }
76
77 /* /dev/mixer file operations */
78
79 int hostmixer_ioctl_mixdev_user(struct hostmixer_state *state, 
80                                 unsigned int cmd, unsigned long arg)
81 {
82 #ifdef DEBUG
83         printk("hostmixer: ioctl_user called cmd = %u\n",cmd);
84 #endif
85
86         return(os_ioctl_generic(state->fd, cmd, arg));
87 }
88
89 int hostmixer_open_mixdev_user(struct hostmixer_state *state, int r, int w,
90                                char *mixer)
91 {
92 #ifdef DEBUG
93         printk("hostmixer: open_user called\n");
94 #endif
95
96         state->fd = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
97
98         if(state->fd < 0) {
99                 printk("hostaudio_open_mixdev_user failed to open '%s', "
100                        "err = %d\n", mixer, state->fd);
101                 return(state->fd); 
102         }
103         
104         return(0);
105 }
106
107 int hostmixer_release_mixdev_user(struct hostmixer_state *state)
108 {
109 #ifdef DEBUG
110         printk("hostmixer: release_user called\n");
111 #endif
112
113         if(state->fd >= 0){
114                 os_close_file(state->fd);
115                 state->fd = -1;
116         }
117
118         return 0;
119 }
120
121 /*
122  * Overrides for Emacs so that we follow Linus's tabbing style.
123  * Emacs will notice this stuff at the end of the file and automatically
124  * adjust the settings for this buffer only.  This must remain at the end
125  * of the file.
126  * ---------------------------------------------------------------------------
127  * Local variables:
128  * c-file-style: "linux"
129  * End:
130  */