aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/hostaudio_kern.c
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-10-16 04:27:34 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:09 -0400
commitcb8fa61c2b8b29d422d7310f064d60022f18f89b (patch)
treef5c8ac78b109e6c76e05250d19fd75e28c47dc74 /arch/um/drivers/hostaudio_kern.c
parent54ae36f24b103e521dd683f66fe72b0584ccb7e2 (diff)
uml: arch/um/drivers formatting
Style fixes for the rest of the drivers. arch/um/drivers should be pretty CodingStyle-compliant now. Except for the ubd driver, which will have to be treated separately. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/drivers/hostaudio_kern.c')
-rw-r--r--arch/um/drivers/hostaudio_kern.c118
1 files changed, 61 insertions, 57 deletions
diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c
index 10e08a8c17c3..ff1b22b69e9c 100644
--- a/arch/um/drivers/hostaudio_kern.c
+++ b/arch/um/drivers/hostaudio_kern.c
@@ -1,16 +1,14 @@
1/* 1/*
2 * Copyright (C) 2002 Steve Schmidtke 2 * Copyright (C) 2002 Steve Schmidtke
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include "linux/fs.h"
6#include "linux/module.h" 7#include "linux/module.h"
7#include "linux/init.h"
8#include "linux/slab.h" 8#include "linux/slab.h"
9#include "linux/fs.h"
10#include "linux/sound.h" 9#include "linux/sound.h"
11#include "linux/soundcard.h" 10#include "linux/soundcard.h"
12#include "asm/uaccess.h" 11#include "asm/uaccess.h"
13#include "kern_util.h"
14#include "init.h" 12#include "init.h"
15#include "os.h" 13#include "os.h"
16 14
@@ -25,7 +23,8 @@ struct hostmixer_state {
25#define HOSTAUDIO_DEV_DSP "/dev/sound/dsp" 23#define HOSTAUDIO_DEV_DSP "/dev/sound/dsp"
26#define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer" 24#define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer"
27 25
28/* Changed either at boot time or module load time. At boot, this is 26/*
27 * Changed either at boot time or module load time. At boot, this is
29 * single-threaded; at module load, multiple modules would each have 28 * single-threaded; at module load, multiple modules would each have
30 * their own copy of these variables. 29 * their own copy of these variables.
31 */ 30 */
@@ -44,7 +43,7 @@ static char *mixer = HOSTAUDIO_DEV_MIXER;
44static int set_dsp(char *name, int *add) 43static int set_dsp(char *name, int *add)
45{ 44{
46 dsp = name; 45 dsp = name;
47 return(0); 46 return 0;
48} 47}
49 48
50__uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP); 49__uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP);
@@ -52,7 +51,7 @@ __uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP);
52static int set_mixer(char *name, int *add) 51static int set_mixer(char *name, int *add)
53{ 52{
54 mixer = name; 53 mixer = name;
55 return(0); 54 return 0;
56} 55}
57 56
58__uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP); 57__uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP);
@@ -77,23 +76,23 @@ static ssize_t hostaudio_read(struct file *file, char __user *buffer,
77 int err; 76 int err;
78 77
79#ifdef DEBUG 78#ifdef DEBUG
80 printk("hostaudio: read called, count = %d\n", count); 79 printk(KERN_DEBUG "hostaudio: read called, count = %d\n", count);
81#endif 80#endif
82 81
83 kbuf = kmalloc(count, GFP_KERNEL); 82 kbuf = kmalloc(count, GFP_KERNEL);
84 if(kbuf == NULL) 83 if (kbuf == NULL)
85 return(-ENOMEM); 84 return -ENOMEM;
86 85
87 err = os_read_file(state->fd, kbuf, count); 86 err = os_read_file(state->fd, kbuf, count);
88 if(err < 0) 87 if (err < 0)
89 goto out; 88 goto out;
90 89
91 if(copy_to_user(buffer, kbuf, err)) 90 if (copy_to_user(buffer, kbuf, err))
92 err = -EFAULT; 91 err = -EFAULT;
93 92
94out: 93out:
95 kfree(kbuf); 94 kfree(kbuf);
96 return(err); 95 return err;
97} 96}
98 97
99static ssize_t hostaudio_write(struct file *file, const char __user *buffer, 98static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
@@ -104,40 +103,40 @@ static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
104 int err; 103 int err;
105 104
106#ifdef DEBUG 105#ifdef DEBUG
107 printk("hostaudio: write called, count = %d\n", count); 106 printk(KERN_DEBUG "hostaudio: write called, count = %d\n", count);
108#endif 107#endif
109 108
110 kbuf = kmalloc(count, GFP_KERNEL); 109 kbuf = kmalloc(count, GFP_KERNEL);
111 if(kbuf == NULL) 110 if (kbuf == NULL)
112 return(-ENOMEM); 111 return -ENOMEM;
113 112
114 err = -EFAULT; 113 err = -EFAULT;
115 if(copy_from_user(kbuf, buffer, count)) 114 if (copy_from_user(kbuf, buffer, count))
116 goto out; 115 goto out;
117 116
118 err = os_write_file(state->fd, kbuf, count); 117 err = os_write_file(state->fd, kbuf, count);
119 if(err < 0) 118 if (err < 0)
120 goto out; 119 goto out;
121 *ppos += err; 120 *ppos += err;
122 121
123 out: 122 out:
124 kfree(kbuf); 123 kfree(kbuf);
125 return(err); 124 return err;
126} 125}
127 126
128static unsigned int hostaudio_poll(struct file *file, 127static unsigned int hostaudio_poll(struct file *file,
129 struct poll_table_struct *wait) 128 struct poll_table_struct *wait)
130{ 129{
131 unsigned int mask = 0; 130 unsigned int mask = 0;
132 131
133#ifdef DEBUG 132#ifdef DEBUG
134 printk("hostaudio: poll called (unimplemented)\n"); 133 printk(KERN_DEBUG "hostaudio: poll called (unimplemented)\n");
135#endif 134#endif
136 135
137 return(mask); 136 return mask;
138} 137}
139 138
140static int hostaudio_ioctl(struct inode *inode, struct file *file, 139static int hostaudio_ioctl(struct inode *inode, struct file *file,
141 unsigned int cmd, unsigned long arg) 140 unsigned int cmd, unsigned long arg)
142{ 141{
143 struct hostaudio_state *state = file->private_data; 142 struct hostaudio_state *state = file->private_data;
@@ -145,7 +144,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
145 int err; 144 int err;
146 145
147#ifdef DEBUG 146#ifdef DEBUG
148 printk("hostaudio: ioctl called, cmd = %u\n", cmd); 147 printk(KERN_DEBUG "hostaudio: ioctl called, cmd = %u\n", cmd);
149#endif 148#endif
150 switch(cmd){ 149 switch(cmd){
151 case SNDCTL_DSP_SPEED: 150 case SNDCTL_DSP_SPEED:
@@ -154,8 +153,8 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
154 case SNDCTL_DSP_CHANNELS: 153 case SNDCTL_DSP_CHANNELS:
155 case SNDCTL_DSP_SUBDIVIDE: 154 case SNDCTL_DSP_SUBDIVIDE:
156 case SNDCTL_DSP_SETFRAGMENT: 155 case SNDCTL_DSP_SETFRAGMENT:
157 if(get_user(data, (int __user *) arg)) 156 if (get_user(data, (int __user *) arg))
158 return(-EFAULT); 157 return EFAULT;
159 break; 158 break;
160 default: 159 default:
161 break; 160 break;
@@ -170,14 +169,14 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
170 case SNDCTL_DSP_CHANNELS: 169 case SNDCTL_DSP_CHANNELS:
171 case SNDCTL_DSP_SUBDIVIDE: 170 case SNDCTL_DSP_SUBDIVIDE:
172 case SNDCTL_DSP_SETFRAGMENT: 171 case SNDCTL_DSP_SETFRAGMENT:
173 if(put_user(data, (int __user *) arg)) 172 if (put_user(data, (int __user *) arg))
174 return(-EFAULT); 173 return -EFAULT;
175 break; 174 break;
176 default: 175 default:
177 break; 176 break;
178 } 177 }
179 178
180 return(err); 179 return err;
181} 180}
182 181
183static int hostaudio_open(struct inode *inode, struct file *file) 182static int hostaudio_open(struct inode *inode, struct file *file)
@@ -187,24 +186,26 @@ static int hostaudio_open(struct inode *inode, struct file *file)
187 int ret; 186 int ret;
188 187
189#ifdef DEBUG 188#ifdef DEBUG
190 printk("hostaudio: open called (host: %s)\n", dsp); 189 printk(KERN_DEBUG "hostaudio: open called (host: %s)\n", dsp);
191#endif 190#endif
192 191
193 state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL); 192 state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL);
194 if(state == NULL) 193 if (state == NULL)
195 return(-ENOMEM); 194 return -ENOMEM;
196 195
197 if(file->f_mode & FMODE_READ) r = 1; 196 if (file->f_mode & FMODE_READ)
198 if(file->f_mode & FMODE_WRITE) w = 1; 197 r = 1;
198 if (file->f_mode & FMODE_WRITE)
199 w = 1;
199 200
200 ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0); 201 ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
201 if(ret < 0){ 202 if (ret < 0) {
202 kfree(state); 203 kfree(state);
203 return(ret); 204 return ret;
204 } 205 }
205 state->fd = ret; 206 state->fd = ret;
206 file->private_data = state; 207 file->private_data = state;
207 return(0); 208 return 0;
208} 209}
209 210
210static int hostaudio_release(struct inode *inode, struct file *file) 211static int hostaudio_release(struct inode *inode, struct file *file)
@@ -212,26 +213,26 @@ static int hostaudio_release(struct inode *inode, struct file *file)
212 struct hostaudio_state *state = file->private_data; 213 struct hostaudio_state *state = file->private_data;
213 214
214#ifdef DEBUG 215#ifdef DEBUG
215 printk("hostaudio: release called\n"); 216 printk(KERN_DEBUG "hostaudio: release called\n");
216#endif 217#endif
217 os_close_file(state->fd); 218 os_close_file(state->fd);
218 kfree(state); 219 kfree(state);
219 220
220 return(0); 221 return 0;
221} 222}
222 223
223/* /dev/mixer file operations */ 224/* /dev/mixer file operations */
224 225
225static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file, 226static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file,
226 unsigned int cmd, unsigned long arg) 227 unsigned int cmd, unsigned long arg)
227{ 228{
228 struct hostmixer_state *state = file->private_data; 229 struct hostmixer_state *state = file->private_data;
229 230
230#ifdef DEBUG 231#ifdef DEBUG
231 printk("hostmixer: ioctl called\n"); 232 printk(KERN_DEBUG "hostmixer: ioctl called\n");
232#endif 233#endif
233 234
234 return(os_ioctl_generic(state->fd, cmd, arg)); 235 return os_ioctl_generic(state->fd, cmd, arg);
235} 236}
236 237
237static int hostmixer_open_mixdev(struct inode *inode, struct file *file) 238static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
@@ -241,26 +242,29 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
241 int ret; 242 int ret;
242 243
243#ifdef DEBUG 244#ifdef DEBUG
244 printk("hostmixer: open called (host: %s)\n", mixer); 245 printk(KERN_DEBUG "hostmixer: open called (host: %s)\n", mixer);
245#endif 246#endif
246 247
247 state = kmalloc(sizeof(struct hostmixer_state), GFP_KERNEL); 248 state = kmalloc(sizeof(struct hostmixer_state), GFP_KERNEL);
248 if(state == NULL) return(-ENOMEM); 249 if (state == NULL)
250 return -ENOMEM;
249 251
250 if(file->f_mode & FMODE_READ) r = 1; 252 if (file->f_mode & FMODE_READ)
251 if(file->f_mode & FMODE_WRITE) w = 1; 253 r = 1;
254 if (file->f_mode & FMODE_WRITE)
255 w = 1;
252 256
253 ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0); 257 ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
254 258
255 if(ret < 0){ 259 if (ret < 0) {
256 printk("hostaudio_open_mixdev failed to open '%s', err = %d\n", 260 printk(KERN_ERR "hostaudio_open_mixdev failed to open '%s', "
257 dsp, -ret); 261 "err = %d\n", dsp, -ret);
258 kfree(state); 262 kfree(state);
259 return(ret); 263 return ret;
260 } 264 }
261 265
262 file->private_data = state; 266 file->private_data = state;
263 return(0); 267 return 0;
264} 268}
265 269
266static int hostmixer_release(struct inode *inode, struct file *file) 270static int hostmixer_release(struct inode *inode, struct file *file)
@@ -268,13 +272,13 @@ static int hostmixer_release(struct inode *inode, struct file *file)
268 struct hostmixer_state *state = file->private_data; 272 struct hostmixer_state *state = file->private_data;
269 273
270#ifdef DEBUG 274#ifdef DEBUG
271 printk("hostmixer: release called\n"); 275 printk(KERN_DEBUG "hostmixer: release called\n");
272#endif 276#endif
273 277
274 os_close_file(state->fd); 278 os_close_file(state->fd);
275 kfree(state); 279 kfree(state);
276 280
277 return(0); 281 return 0;
278} 282}
279 283
280/* kernel module operations */ 284/* kernel module operations */
@@ -314,13 +318,13 @@ static int __init hostaudio_init_module(void)
314 dsp, mixer); 318 dsp, mixer);
315 319
316 module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1); 320 module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1);
317 if(module_data.dev_audio < 0){ 321 if (module_data.dev_audio < 0) {
318 printk(KERN_ERR "hostaudio: couldn't register DSP device!\n"); 322 printk(KERN_ERR "hostaudio: couldn't register DSP device!\n");
319 return -ENODEV; 323 return -ENODEV;
320 } 324 }
321 325
322 module_data.dev_mixer = register_sound_mixer(&hostmixer_fops, -1); 326 module_data.dev_mixer = register_sound_mixer(&hostmixer_fops, -1);
323 if(module_data.dev_mixer < 0){ 327 if (module_data.dev_mixer < 0) {
324 printk(KERN_ERR "hostmixer: couldn't register mixer " 328 printk(KERN_ERR "hostmixer: couldn't register mixer "
325 "device!\n"); 329 "device!\n");
326 unregister_sound_dsp(module_data.dev_audio); 330 unregister_sound_dsp(module_data.dev_audio);