diff options
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/control.c | 5 | ||||
-rw-r--r-- | sound/core/control_compat.c | 1 | ||||
-rw-r--r-- | sound/core/hrtimer.c | 1 | ||||
-rw-r--r-- | sound/core/info.c | 75 | ||||
-rw-r--r-- | sound/core/jack.c | 1 | ||||
-rw-r--r-- | sound/core/misc.c | 1 | ||||
-rw-r--r-- | sound/core/oss/mixer_oss.c | 5 | ||||
-rw-r--r-- | sound/core/oss/pcm_oss.c | 5 | ||||
-rw-r--r-- | sound/core/oss/route.c | 1 | ||||
-rw-r--r-- | sound/core/pcm.c | 3 | ||||
-rw-r--r-- | sound/core/pcm_compat.c | 1 | ||||
-rw-r--r-- | sound/core/pcm_lib.c | 19 | ||||
-rw-r--r-- | sound/core/pcm_memory.c | 1 | ||||
-rw-r--r-- | sound/core/pcm_native.c | 109 | ||||
-rw-r--r-- | sound/core/rawmidi.c | 5 | ||||
-rw-r--r-- | sound/core/seq/oss/seq_oss_init.c | 1 | ||||
-rw-r--r-- | sound/core/seq/oss/seq_oss_midi.c | 1 | ||||
-rw-r--r-- | sound/core/seq/oss/seq_oss_readq.c | 1 | ||||
-rw-r--r-- | sound/core/seq/oss/seq_oss_synth.c | 1 | ||||
-rw-r--r-- | sound/core/seq/oss/seq_oss_timer.c | 1 | ||||
-rw-r--r-- | sound/core/seq/oss/seq_oss_writeq.c | 1 | ||||
-rw-r--r-- | sound/core/seq/seq_clientmgr.c | 6 | ||||
-rw-r--r-- | sound/core/seq/seq_compat.c | 1 | ||||
-rw-r--r-- | sound/core/seq/seq_system.c | 1 | ||||
-rw-r--r-- | sound/core/sound.c | 73 | ||||
-rw-r--r-- | sound/core/timer.c | 11 |
26 files changed, 195 insertions, 136 deletions
diff --git a/sound/core/control.c b/sound/core/control.c index 439ce64f9d82..070aab490191 100644 --- a/sound/core/control.c +++ b/sound/core/control.c | |||
@@ -50,6 +50,10 @@ static int snd_ctl_open(struct inode *inode, struct file *file) | |||
50 | struct snd_ctl_file *ctl; | 50 | struct snd_ctl_file *ctl; |
51 | int err; | 51 | int err; |
52 | 52 | ||
53 | err = nonseekable_open(inode, file); | ||
54 | if (err < 0) | ||
55 | return err; | ||
56 | |||
53 | card = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_CONTROL); | 57 | card = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_CONTROL); |
54 | if (!card) { | 58 | if (!card) { |
55 | err = -ENODEV; | 59 | err = -ENODEV; |
@@ -1388,6 +1392,7 @@ static const struct file_operations snd_ctl_f_ops = | |||
1388 | .read = snd_ctl_read, | 1392 | .read = snd_ctl_read, |
1389 | .open = snd_ctl_open, | 1393 | .open = snd_ctl_open, |
1390 | .release = snd_ctl_release, | 1394 | .release = snd_ctl_release, |
1395 | .llseek = no_llseek, | ||
1391 | .poll = snd_ctl_poll, | 1396 | .poll = snd_ctl_poll, |
1392 | .unlocked_ioctl = snd_ctl_ioctl, | 1397 | .unlocked_ioctl = snd_ctl_ioctl, |
1393 | .compat_ioctl = snd_ctl_ioctl_compat, | 1398 | .compat_ioctl = snd_ctl_ioctl_compat, |
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c index 368dc9c4aef8..426874429a5e 100644 --- a/sound/core/control_compat.c +++ b/sound/core/control_compat.c | |||
@@ -21,6 +21,7 @@ | |||
21 | /* this file included from control.c */ | 21 | /* this file included from control.c */ |
22 | 22 | ||
23 | #include <linux/compat.h> | 23 | #include <linux/compat.h> |
24 | #include <linux/slab.h> | ||
24 | 25 | ||
25 | struct snd_ctl_elem_list32 { | 26 | struct snd_ctl_elem_list32 { |
26 | u32 offset; | 27 | u32 offset; |
diff --git a/sound/core/hrtimer.c b/sound/core/hrtimer.c index 7f4d744ae40a..7730575bfadd 100644 --- a/sound/core/hrtimer.c +++ b/sound/core/hrtimer.c | |||
@@ -19,6 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/slab.h> | ||
22 | #include <linux/module.h> | 23 | #include <linux/module.h> |
23 | #include <linux/moduleparam.h> | 24 | #include <linux/moduleparam.h> |
24 | #include <linux/hrtimer.h> | 25 | #include <linux/hrtimer.h> |
diff --git a/sound/core/info.c b/sound/core/info.c index d749a0d394a7..b70564ed8b37 100644 --- a/sound/core/info.c +++ b/sound/core/info.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/time.h> | 23 | #include <linux/time.h> |
24 | #include <linux/mm.h> | 24 | #include <linux/mm.h> |
25 | #include <linux/slab.h> | ||
25 | #include <linux/smp_lock.h> | 26 | #include <linux/smp_lock.h> |
26 | #include <linux/string.h> | 27 | #include <linux/string.h> |
27 | #include <sound/core.h> | 28 | #include <sound/core.h> |
@@ -163,40 +164,44 @@ static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig) | |||
163 | { | 164 | { |
164 | struct snd_info_private_data *data; | 165 | struct snd_info_private_data *data; |
165 | struct snd_info_entry *entry; | 166 | struct snd_info_entry *entry; |
166 | loff_t ret; | 167 | loff_t ret = -EINVAL, size; |
167 | 168 | ||
168 | data = file->private_data; | 169 | data = file->private_data; |
169 | entry = data->entry; | 170 | entry = data->entry; |
170 | lock_kernel(); | 171 | mutex_lock(&entry->access); |
171 | switch (entry->content) { | 172 | if (entry->content == SNDRV_INFO_CONTENT_DATA && |
172 | case SNDRV_INFO_CONTENT_TEXT: | 173 | entry->c.ops->llseek) { |
173 | switch (orig) { | 174 | offset = entry->c.ops->llseek(entry, |
174 | case SEEK_SET: | 175 | data->file_private_data, |
175 | file->f_pos = offset; | 176 | file, offset, orig); |
176 | ret = file->f_pos; | 177 | goto out; |
177 | goto out; | 178 | } |
178 | case SEEK_CUR: | 179 | if (entry->content == SNDRV_INFO_CONTENT_DATA) |
179 | file->f_pos += offset; | 180 | size = entry->size; |
180 | ret = file->f_pos; | 181 | else |
181 | goto out; | 182 | size = 0; |
182 | case SEEK_END: | 183 | switch (orig) { |
183 | default: | 184 | case SEEK_SET: |
184 | ret = -EINVAL; | ||
185 | goto out; | ||
186 | } | ||
187 | break; | 185 | break; |
188 | case SNDRV_INFO_CONTENT_DATA: | 186 | case SEEK_CUR: |
189 | if (entry->c.ops->llseek) { | 187 | offset += file->f_pos; |
190 | ret = entry->c.ops->llseek(entry, | 188 | break; |
191 | data->file_private_data, | 189 | case SEEK_END: |
192 | file, offset, orig); | 190 | if (!size) |
193 | goto out; | 191 | goto out; |
194 | } | 192 | offset += size; |
195 | break; | 193 | break; |
196 | } | 194 | default: |
197 | ret = -ENXIO; | 195 | goto out; |
198 | out: | 196 | } |
199 | unlock_kernel(); | 197 | if (offset < 0) |
198 | goto out; | ||
199 | if (size && offset > size) | ||
200 | offset = size; | ||
201 | file->f_pos = offset; | ||
202 | ret = offset; | ||
203 | out: | ||
204 | mutex_unlock(&entry->access); | ||
200 | return ret; | 205 | return ret; |
201 | } | 206 | } |
202 | 207 | ||
@@ -231,10 +236,15 @@ static ssize_t snd_info_entry_read(struct file *file, char __user *buffer, | |||
231 | return -EFAULT; | 236 | return -EFAULT; |
232 | break; | 237 | break; |
233 | case SNDRV_INFO_CONTENT_DATA: | 238 | case SNDRV_INFO_CONTENT_DATA: |
234 | if (entry->c.ops->read) | 239 | if (pos >= entry->size) |
240 | return 0; | ||
241 | if (entry->c.ops->read) { | ||
242 | size = entry->size - pos; | ||
243 | size = min(count, size); | ||
235 | size = entry->c.ops->read(entry, | 244 | size = entry->c.ops->read(entry, |
236 | data->file_private_data, | 245 | data->file_private_data, |
237 | file, buffer, count, pos); | 246 | file, buffer, size, pos); |
247 | } | ||
238 | break; | 248 | break; |
239 | } | 249 | } |
240 | if ((ssize_t) size > 0) | 250 | if ((ssize_t) size > 0) |
@@ -281,10 +291,13 @@ static ssize_t snd_info_entry_write(struct file *file, const char __user *buffer | |||
281 | size = count; | 291 | size = count; |
282 | break; | 292 | break; |
283 | case SNDRV_INFO_CONTENT_DATA: | 293 | case SNDRV_INFO_CONTENT_DATA: |
284 | if (entry->c.ops->write) | 294 | if (entry->c.ops->write && count > 0) { |
295 | size_t maxsize = entry->size - pos; | ||
296 | count = min(count, maxsize); | ||
285 | size = entry->c.ops->write(entry, | 297 | size = entry->c.ops->write(entry, |
286 | data->file_private_data, | 298 | data->file_private_data, |
287 | file, buffer, count, pos); | 299 | file, buffer, count, pos); |
300 | } | ||
288 | break; | 301 | break; |
289 | } | 302 | } |
290 | if ((ssize_t) size > 0) | 303 | if ((ssize_t) size > 0) |
diff --git a/sound/core/jack.c b/sound/core/jack.c index 3813e7b04d05..4902ae568730 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c | |||
@@ -20,6 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/input.h> | 22 | #include <linux/input.h> |
23 | #include <linux/slab.h> | ||
23 | #include <sound/jack.h> | 24 | #include <sound/jack.h> |
24 | #include <sound/core.h> | 25 | #include <sound/core.h> |
25 | 26 | ||
diff --git a/sound/core/misc.c b/sound/core/misc.c index 3da4f92427d8..2c41825c836e 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/time.h> | 23 | #include <linux/time.h> |
24 | #include <linux/slab.h> | ||
24 | #include <linux/ioport.h> | 25 | #include <linux/ioport.h> |
25 | #include <sound/core.h> | 26 | #include <sound/core.h> |
26 | 27 | ||
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 54e2eb56e4c2..f50ebf20df96 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c | |||
@@ -43,6 +43,10 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file) | |||
43 | struct snd_mixer_oss_file *fmixer; | 43 | struct snd_mixer_oss_file *fmixer; |
44 | int err; | 44 | int err; |
45 | 45 | ||
46 | err = nonseekable_open(inode, file); | ||
47 | if (err < 0) | ||
48 | return err; | ||
49 | |||
46 | card = snd_lookup_oss_minor_data(iminor(inode), | 50 | card = snd_lookup_oss_minor_data(iminor(inode), |
47 | SNDRV_OSS_DEVICE_TYPE_MIXER); | 51 | SNDRV_OSS_DEVICE_TYPE_MIXER); |
48 | if (card == NULL) | 52 | if (card == NULL) |
@@ -397,6 +401,7 @@ static const struct file_operations snd_mixer_oss_f_ops = | |||
397 | .owner = THIS_MODULE, | 401 | .owner = THIS_MODULE, |
398 | .open = snd_mixer_oss_open, | 402 | .open = snd_mixer_oss_open, |
399 | .release = snd_mixer_oss_release, | 403 | .release = snd_mixer_oss_release, |
404 | .llseek = no_llseek, | ||
400 | .unlocked_ioctl = snd_mixer_oss_ioctl, | 405 | .unlocked_ioctl = snd_mixer_oss_ioctl, |
401 | .compat_ioctl = snd_mixer_oss_ioctl_compat, | 406 | .compat_ioctl = snd_mixer_oss_ioctl_compat, |
402 | }; | 407 | }; |
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 82d4e3329b3d..5c8c7dff8ede 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c | |||
@@ -2379,6 +2379,10 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) | |||
2379 | int nonblock; | 2379 | int nonblock; |
2380 | wait_queue_t wait; | 2380 | wait_queue_t wait; |
2381 | 2381 | ||
2382 | err = nonseekable_open(inode, file); | ||
2383 | if (err < 0) | ||
2384 | return err; | ||
2385 | |||
2382 | pcm = snd_lookup_oss_minor_data(iminor(inode), | 2386 | pcm = snd_lookup_oss_minor_data(iminor(inode), |
2383 | SNDRV_OSS_DEVICE_TYPE_PCM); | 2387 | SNDRV_OSS_DEVICE_TYPE_PCM); |
2384 | if (pcm == NULL) { | 2388 | if (pcm == NULL) { |
@@ -2977,6 +2981,7 @@ static const struct file_operations snd_pcm_oss_f_reg = | |||
2977 | .write = snd_pcm_oss_write, | 2981 | .write = snd_pcm_oss_write, |
2978 | .open = snd_pcm_oss_open, | 2982 | .open = snd_pcm_oss_open, |
2979 | .release = snd_pcm_oss_release, | 2983 | .release = snd_pcm_oss_release, |
2984 | .llseek = no_llseek, | ||
2980 | .poll = snd_pcm_oss_poll, | 2985 | .poll = snd_pcm_oss_poll, |
2981 | .unlocked_ioctl = snd_pcm_oss_ioctl, | 2986 | .unlocked_ioctl = snd_pcm_oss_ioctl, |
2982 | .compat_ioctl = snd_pcm_oss_ioctl_compat, | 2987 | .compat_ioctl = snd_pcm_oss_ioctl_compat, |
diff --git a/sound/core/oss/route.c b/sound/core/oss/route.c index 0dcc2870d537..bbe25d8c450a 100644 --- a/sound/core/oss/route.c +++ b/sound/core/oss/route.c | |||
@@ -19,7 +19,6 @@ | |||
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/time.h> | 22 | #include <linux/time.h> |
24 | #include <sound/core.h> | 23 | #include <sound/core.h> |
25 | #include <sound/pcm.h> | 24 | #include <sound/pcm.h> |
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 0d428d0896db..cbe815dfbdc8 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c | |||
@@ -648,9 +648,6 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) | |||
648 | substream->number = idx; | 648 | substream->number = idx; |
649 | substream->stream = stream; | 649 | substream->stream = stream; |
650 | sprintf(substream->name, "subdevice #%i", idx); | 650 | sprintf(substream->name, "subdevice #%i", idx); |
651 | snprintf(substream->latency_id, sizeof(substream->latency_id), | ||
652 | "ALSA-PCM%d-%d%c%d", pcm->card->number, pcm->device, | ||
653 | (stream ? 'c' : 'p'), idx); | ||
654 | substream->buffer_bytes_max = UINT_MAX; | 651 | substream->buffer_bytes_max = UINT_MAX; |
655 | if (prev == NULL) | 652 | if (prev == NULL) |
656 | pstr->substream = substream; | 653 | pstr->substream = substream; |
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index 08bfed594a83..5fb2e28e796f 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c | |||
@@ -21,6 +21,7 @@ | |||
21 | /* This file included from pcm_native.c */ | 21 | /* This file included from pcm_native.c */ |
22 | 22 | ||
23 | #include <linux/compat.h> | 23 | #include <linux/compat.h> |
24 | #include <linux/slab.h> | ||
24 | 25 | ||
25 | static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream, | 26 | static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream, |
26 | s32 __user *src) | 27 | s32 __user *src) |
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index b546ac2660f9..e9d98be190c5 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -148,6 +148,9 @@ static void pcm_debug_name(struct snd_pcm_substream *substream, | |||
148 | 148 | ||
149 | #define xrun_debug(substream, mask) \ | 149 | #define xrun_debug(substream, mask) \ |
150 | ((substream)->pstr->xrun_debug & (mask)) | 150 | ((substream)->pstr->xrun_debug & (mask)) |
151 | #else | ||
152 | #define xrun_debug(substream, mask) 0 | ||
153 | #endif | ||
151 | 154 | ||
152 | #define dump_stack_on_xrun(substream) do { \ | 155 | #define dump_stack_on_xrun(substream) do { \ |
153 | if (xrun_debug(substream, XRUN_DEBUG_STACK)) \ | 156 | if (xrun_debug(substream, XRUN_DEBUG_STACK)) \ |
@@ -169,6 +172,7 @@ static void xrun(struct snd_pcm_substream *substream) | |||
169 | } | 172 | } |
170 | } | 173 | } |
171 | 174 | ||
175 | #ifdef CONFIG_SND_PCM_XRUN_DEBUG | ||
172 | #define hw_ptr_error(substream, fmt, args...) \ | 176 | #define hw_ptr_error(substream, fmt, args...) \ |
173 | do { \ | 177 | do { \ |
174 | if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { \ | 178 | if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { \ |
@@ -255,8 +259,6 @@ static void xrun_log_show(struct snd_pcm_substream *substream) | |||
255 | 259 | ||
256 | #else /* ! CONFIG_SND_PCM_XRUN_DEBUG */ | 260 | #else /* ! CONFIG_SND_PCM_XRUN_DEBUG */ |
257 | 261 | ||
258 | #define xrun_debug(substream, mask) 0 | ||
259 | #define xrun(substream) do { } while (0) | ||
260 | #define hw_ptr_error(substream, fmt, args...) do { } while (0) | 262 | #define hw_ptr_error(substream, fmt, args...) do { } while (0) |
261 | #define xrun_log(substream, pos) do { } while (0) | 263 | #define xrun_log(substream, pos) do { } while (0) |
262 | #define xrun_log_show(substream) do { } while (0) | 264 | #define xrun_log_show(substream) do { } while (0) |
@@ -343,7 +345,9 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, | |||
343 | new_hw_ptr = hw_base + pos; | 345 | new_hw_ptr = hw_base + pos; |
344 | } | 346 | } |
345 | __delta: | 347 | __delta: |
346 | delta = (new_hw_ptr - old_hw_ptr) % runtime->boundary; | 348 | delta = new_hw_ptr - old_hw_ptr; |
349 | if (delta < 0) | ||
350 | delta += runtime->boundary; | ||
347 | if (xrun_debug(substream, in_interrupt ? | 351 | if (xrun_debug(substream, in_interrupt ? |
348 | XRUN_DEBUG_PERIODUPDATE : XRUN_DEBUG_HWPTRUPDATE)) { | 352 | XRUN_DEBUG_PERIODUPDATE : XRUN_DEBUG_HWPTRUPDATE)) { |
349 | char name[16]; | 353 | char name[16]; |
@@ -437,8 +441,13 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, | |||
437 | snd_pcm_playback_silence(substream, new_hw_ptr); | 441 | snd_pcm_playback_silence(substream, new_hw_ptr); |
438 | 442 | ||
439 | if (in_interrupt) { | 443 | if (in_interrupt) { |
440 | runtime->hw_ptr_interrupt = new_hw_ptr - | 444 | delta = new_hw_ptr - runtime->hw_ptr_interrupt; |
441 | (new_hw_ptr % runtime->period_size); | 445 | if (delta < 0) |
446 | delta += runtime->boundary; | ||
447 | delta -= (snd_pcm_uframes_t)delta % runtime->period_size; | ||
448 | runtime->hw_ptr_interrupt += delta; | ||
449 | if (runtime->hw_ptr_interrupt >= runtime->boundary) | ||
450 | runtime->hw_ptr_interrupt -= runtime->boundary; | ||
442 | } | 451 | } |
443 | runtime->hw_ptr_base = hw_base; | 452 | runtime->hw_ptr_base = hw_base; |
444 | runtime->status->hw_ptr = new_hw_ptr; | 453 | runtime->status->hw_ptr = new_hw_ptr; |
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index d6d49d6651f9..917e4055ee30 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <asm/io.h> | 22 | #include <asm/io.h> |
23 | #include <linux/time.h> | 23 | #include <linux/time.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/slab.h> | ||
25 | #include <linux/moduleparam.h> | 26 | #include <linux/moduleparam.h> |
26 | #include <linux/vmalloc.h> | 27 | #include <linux/vmalloc.h> |
27 | #include <sound/core.h> | 28 | #include <sound/core.h> |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 872887624030..303ac04ff6e4 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/pm_qos_params.h> | 27 | #include <linux/pm_qos_params.h> |
28 | #include <linux/uio.h> | 28 | #include <linux/uio.h> |
29 | #include <linux/dma-mapping.h> | 29 | #include <linux/dma-mapping.h> |
30 | #include <linux/math64.h> | ||
31 | #include <sound/core.h> | 30 | #include <sound/core.h> |
32 | #include <sound/control.h> | 31 | #include <sound/control.h> |
33 | #include <sound/info.h> | 32 | #include <sound/info.h> |
@@ -36,6 +35,9 @@ | |||
36 | #include <sound/timer.h> | 35 | #include <sound/timer.h> |
37 | #include <sound/minors.h> | 36 | #include <sound/minors.h> |
38 | #include <asm/io.h> | 37 | #include <asm/io.h> |
38 | #if defined(CONFIG_MIPS) && defined(CONFIG_DMA_NONCOHERENT) | ||
39 | #include <dma-coherence.h> | ||
40 | #endif | ||
39 | 41 | ||
40 | /* | 42 | /* |
41 | * Compatibility | 43 | * Compatibility |
@@ -367,38 +369,6 @@ static int period_to_usecs(struct snd_pcm_runtime *runtime) | |||
367 | return usecs; | 369 | return usecs; |
368 | } | 370 | } |
369 | 371 | ||
370 | static int calc_boundary(struct snd_pcm_runtime *runtime) | ||
371 | { | ||
372 | u_int64_t boundary; | ||
373 | |||
374 | boundary = (u_int64_t)runtime->buffer_size * | ||
375 | (u_int64_t)runtime->period_size; | ||
376 | #if BITS_PER_LONG < 64 | ||
377 | /* try to find lowest common multiple for buffer and period */ | ||
378 | if (boundary > LONG_MAX - runtime->buffer_size) { | ||
379 | u_int32_t remainder = -1; | ||
380 | u_int32_t divident = runtime->buffer_size; | ||
381 | u_int32_t divisor = runtime->period_size; | ||
382 | while (remainder) { | ||
383 | remainder = divident % divisor; | ||
384 | if (remainder) { | ||
385 | divident = divisor; | ||
386 | divisor = remainder; | ||
387 | } | ||
388 | } | ||
389 | boundary = div_u64(boundary, divisor); | ||
390 | if (boundary > LONG_MAX - runtime->buffer_size) | ||
391 | return -ERANGE; | ||
392 | } | ||
393 | #endif | ||
394 | if (boundary == 0) | ||
395 | return -ERANGE; | ||
396 | runtime->boundary = boundary; | ||
397 | while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) | ||
398 | runtime->boundary *= 2; | ||
399 | return 0; | ||
400 | } | ||
401 | |||
402 | static int snd_pcm_hw_params(struct snd_pcm_substream *substream, | 372 | static int snd_pcm_hw_params(struct snd_pcm_substream *substream, |
403 | struct snd_pcm_hw_params *params) | 373 | struct snd_pcm_hw_params *params) |
404 | { | 374 | { |
@@ -474,18 +444,20 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream, | |||
474 | runtime->stop_threshold = runtime->buffer_size; | 444 | runtime->stop_threshold = runtime->buffer_size; |
475 | runtime->silence_threshold = 0; | 445 | runtime->silence_threshold = 0; |
476 | runtime->silence_size = 0; | 446 | runtime->silence_size = 0; |
477 | err = calc_boundary(runtime); | 447 | runtime->boundary = runtime->buffer_size; |
478 | if (err < 0) | 448 | while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) |
479 | goto _error; | 449 | runtime->boundary *= 2; |
480 | 450 | ||
481 | snd_pcm_timer_resolution_change(substream); | 451 | snd_pcm_timer_resolution_change(substream); |
482 | runtime->status->state = SNDRV_PCM_STATE_SETUP; | 452 | runtime->status->state = SNDRV_PCM_STATE_SETUP; |
483 | 453 | ||
484 | pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY, | 454 | if (substream->latency_pm_qos_req) { |
485 | substream->latency_id); | 455 | pm_qos_remove_request(substream->latency_pm_qos_req); |
456 | substream->latency_pm_qos_req = NULL; | ||
457 | } | ||
486 | if ((usecs = period_to_usecs(runtime)) >= 0) | 458 | if ((usecs = period_to_usecs(runtime)) >= 0) |
487 | pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY, | 459 | substream->latency_pm_qos_req = pm_qos_add_request( |
488 | substream->latency_id, usecs); | 460 | PM_QOS_CPU_DMA_LATENCY, usecs); |
489 | return 0; | 461 | return 0; |
490 | _error: | 462 | _error: |
491 | /* hardware might be unuseable from this time, | 463 | /* hardware might be unuseable from this time, |
@@ -540,8 +512,8 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream) | |||
540 | if (substream->ops->hw_free) | 512 | if (substream->ops->hw_free) |
541 | result = substream->ops->hw_free(substream); | 513 | result = substream->ops->hw_free(substream); |
542 | runtime->status->state = SNDRV_PCM_STATE_OPEN; | 514 | runtime->status->state = SNDRV_PCM_STATE_OPEN; |
543 | pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY, | 515 | pm_qos_remove_request(substream->latency_pm_qos_req); |
544 | substream->latency_id); | 516 | substream->latency_pm_qos_req = NULL; |
545 | return result; | 517 | return result; |
546 | } | 518 | } |
547 | 519 | ||
@@ -2107,7 +2079,9 @@ static int snd_pcm_open_file(struct file *file, | |||
2107 | static int snd_pcm_playback_open(struct inode *inode, struct file *file) | 2079 | static int snd_pcm_playback_open(struct inode *inode, struct file *file) |
2108 | { | 2080 | { |
2109 | struct snd_pcm *pcm; | 2081 | struct snd_pcm *pcm; |
2110 | 2082 | int err = nonseekable_open(inode, file); | |
2083 | if (err < 0) | ||
2084 | return err; | ||
2111 | pcm = snd_lookup_minor_data(iminor(inode), | 2085 | pcm = snd_lookup_minor_data(iminor(inode), |
2112 | SNDRV_DEVICE_TYPE_PCM_PLAYBACK); | 2086 | SNDRV_DEVICE_TYPE_PCM_PLAYBACK); |
2113 | return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK); | 2087 | return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK); |
@@ -2116,7 +2090,9 @@ static int snd_pcm_playback_open(struct inode *inode, struct file *file) | |||
2116 | static int snd_pcm_capture_open(struct inode *inode, struct file *file) | 2090 | static int snd_pcm_capture_open(struct inode *inode, struct file *file) |
2117 | { | 2091 | { |
2118 | struct snd_pcm *pcm; | 2092 | struct snd_pcm *pcm; |
2119 | 2093 | int err = nonseekable_open(inode, file); | |
2094 | if (err < 0) | ||
2095 | return err; | ||
2120 | pcm = snd_lookup_minor_data(iminor(inode), | 2096 | pcm = snd_lookup_minor_data(iminor(inode), |
2121 | SNDRV_DEVICE_TYPE_PCM_CAPTURE); | 2097 | SNDRV_DEVICE_TYPE_PCM_CAPTURE); |
2122 | return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE); | 2098 | return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE); |
@@ -3184,6 +3160,10 @@ static int snd_pcm_default_mmap(struct snd_pcm_substream *substream, | |||
3184 | substream->runtime->dma_area, | 3160 | substream->runtime->dma_area, |
3185 | substream->runtime->dma_addr, | 3161 | substream->runtime->dma_addr, |
3186 | area->vm_end - area->vm_start); | 3162 | area->vm_end - area->vm_start); |
3163 | #elif defined(CONFIG_MIPS) && defined(CONFIG_DMA_NONCOHERENT) | ||
3164 | if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV && | ||
3165 | !plat_device_is_coherent(substream->dma_buffer.dev.dev)) | ||
3166 | area->vm_page_prot = pgprot_noncached(area->vm_page_prot); | ||
3187 | #endif /* ARCH_HAS_DMA_MMAP_COHERENT */ | 3167 | #endif /* ARCH_HAS_DMA_MMAP_COHERENT */ |
3188 | /* mmap with fault handler */ | 3168 | /* mmap with fault handler */ |
3189 | area->vm_ops = &snd_pcm_vm_ops_data_fault; | 3169 | area->vm_ops = &snd_pcm_vm_ops_data_fault; |
@@ -3303,18 +3283,13 @@ static int snd_pcm_fasync(int fd, struct file * file, int on) | |||
3303 | struct snd_pcm_file * pcm_file; | 3283 | struct snd_pcm_file * pcm_file; |
3304 | struct snd_pcm_substream *substream; | 3284 | struct snd_pcm_substream *substream; |
3305 | struct snd_pcm_runtime *runtime; | 3285 | struct snd_pcm_runtime *runtime; |
3306 | int err = -ENXIO; | ||
3307 | 3286 | ||
3308 | lock_kernel(); | ||
3309 | pcm_file = file->private_data; | 3287 | pcm_file = file->private_data; |
3310 | substream = pcm_file->substream; | 3288 | substream = pcm_file->substream; |
3311 | if (PCM_RUNTIME_CHECK(substream)) | 3289 | if (PCM_RUNTIME_CHECK(substream)) |
3312 | goto out; | 3290 | return -ENXIO; |
3313 | runtime = substream->runtime; | 3291 | runtime = substream->runtime; |
3314 | err = fasync_helper(fd, file, on, &runtime->fasync); | 3292 | return fasync_helper(fd, file, on, &runtime->fasync); |
3315 | out: | ||
3316 | unlock_kernel(); | ||
3317 | return err; | ||
3318 | } | 3293 | } |
3319 | 3294 | ||
3320 | /* | 3295 | /* |
@@ -3434,14 +3409,28 @@ out: | |||
3434 | #endif /* CONFIG_SND_SUPPORT_OLD_API */ | 3409 | #endif /* CONFIG_SND_SUPPORT_OLD_API */ |
3435 | 3410 | ||
3436 | #ifndef CONFIG_MMU | 3411 | #ifndef CONFIG_MMU |
3437 | unsigned long dummy_get_unmapped_area(struct file *file, unsigned long addr, | 3412 | static unsigned long snd_pcm_get_unmapped_area(struct file *file, |
3438 | unsigned long len, unsigned long pgoff, | 3413 | unsigned long addr, |
3439 | unsigned long flags) | 3414 | unsigned long len, |
3440 | { | 3415 | unsigned long pgoff, |
3441 | return 0; | 3416 | unsigned long flags) |
3417 | { | ||
3418 | struct snd_pcm_file *pcm_file = file->private_data; | ||
3419 | struct snd_pcm_substream *substream = pcm_file->substream; | ||
3420 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
3421 | unsigned long offset = pgoff << PAGE_SHIFT; | ||
3422 | |||
3423 | switch (offset) { | ||
3424 | case SNDRV_PCM_MMAP_OFFSET_STATUS: | ||
3425 | return (unsigned long)runtime->status; | ||
3426 | case SNDRV_PCM_MMAP_OFFSET_CONTROL: | ||
3427 | return (unsigned long)runtime->control; | ||
3428 | default: | ||
3429 | return (unsigned long)runtime->dma_area + offset; | ||
3430 | } | ||
3442 | } | 3431 | } |
3443 | #else | 3432 | #else |
3444 | # define dummy_get_unmapped_area NULL | 3433 | # define snd_pcm_get_unmapped_area NULL |
3445 | #endif | 3434 | #endif |
3446 | 3435 | ||
3447 | /* | 3436 | /* |
@@ -3455,12 +3444,13 @@ const struct file_operations snd_pcm_f_ops[2] = { | |||
3455 | .aio_write = snd_pcm_aio_write, | 3444 | .aio_write = snd_pcm_aio_write, |
3456 | .open = snd_pcm_playback_open, | 3445 | .open = snd_pcm_playback_open, |
3457 | .release = snd_pcm_release, | 3446 | .release = snd_pcm_release, |
3447 | .llseek = no_llseek, | ||
3458 | .poll = snd_pcm_playback_poll, | 3448 | .poll = snd_pcm_playback_poll, |
3459 | .unlocked_ioctl = snd_pcm_playback_ioctl, | 3449 | .unlocked_ioctl = snd_pcm_playback_ioctl, |
3460 | .compat_ioctl = snd_pcm_ioctl_compat, | 3450 | .compat_ioctl = snd_pcm_ioctl_compat, |
3461 | .mmap = snd_pcm_mmap, | 3451 | .mmap = snd_pcm_mmap, |
3462 | .fasync = snd_pcm_fasync, | 3452 | .fasync = snd_pcm_fasync, |
3463 | .get_unmapped_area = dummy_get_unmapped_area, | 3453 | .get_unmapped_area = snd_pcm_get_unmapped_area, |
3464 | }, | 3454 | }, |
3465 | { | 3455 | { |
3466 | .owner = THIS_MODULE, | 3456 | .owner = THIS_MODULE, |
@@ -3468,11 +3458,12 @@ const struct file_operations snd_pcm_f_ops[2] = { | |||
3468 | .aio_read = snd_pcm_aio_read, | 3458 | .aio_read = snd_pcm_aio_read, |
3469 | .open = snd_pcm_capture_open, | 3459 | .open = snd_pcm_capture_open, |
3470 | .release = snd_pcm_release, | 3460 | .release = snd_pcm_release, |
3461 | .llseek = no_llseek, | ||
3471 | .poll = snd_pcm_capture_poll, | 3462 | .poll = snd_pcm_capture_poll, |
3472 | .unlocked_ioctl = snd_pcm_capture_ioctl, | 3463 | .unlocked_ioctl = snd_pcm_capture_ioctl, |
3473 | .compat_ioctl = snd_pcm_ioctl_compat, | 3464 | .compat_ioctl = snd_pcm_ioctl_compat, |
3474 | .mmap = snd_pcm_mmap, | 3465 | .mmap = snd_pcm_mmap, |
3475 | .fasync = snd_pcm_fasync, | 3466 | .fasync = snd_pcm_fasync, |
3476 | .get_unmapped_area = dummy_get_unmapped_area, | 3467 | .get_unmapped_area = snd_pcm_get_unmapped_area, |
3477 | } | 3468 | } |
3478 | }; | 3469 | }; |
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 0f5a194695d9..eb68326c37d4 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c | |||
@@ -376,6 +376,10 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) | |||
376 | if ((file->f_flags & O_APPEND) && !(file->f_flags & O_NONBLOCK)) | 376 | if ((file->f_flags & O_APPEND) && !(file->f_flags & O_NONBLOCK)) |
377 | return -EINVAL; /* invalid combination */ | 377 | return -EINVAL; /* invalid combination */ |
378 | 378 | ||
379 | err = nonseekable_open(inode, file); | ||
380 | if (err < 0) | ||
381 | return err; | ||
382 | |||
379 | if (maj == snd_major) { | 383 | if (maj == snd_major) { |
380 | rmidi = snd_lookup_minor_data(iminor(inode), | 384 | rmidi = snd_lookup_minor_data(iminor(inode), |
381 | SNDRV_DEVICE_TYPE_RAWMIDI); | 385 | SNDRV_DEVICE_TYPE_RAWMIDI); |
@@ -1391,6 +1395,7 @@ static const struct file_operations snd_rawmidi_f_ops = | |||
1391 | .write = snd_rawmidi_write, | 1395 | .write = snd_rawmidi_write, |
1392 | .open = snd_rawmidi_open, | 1396 | .open = snd_rawmidi_open, |
1393 | .release = snd_rawmidi_release, | 1397 | .release = snd_rawmidi_release, |
1398 | .llseek = no_llseek, | ||
1394 | .poll = snd_rawmidi_poll, | 1399 | .poll = snd_rawmidi_poll, |
1395 | .unlocked_ioctl = snd_rawmidi_ioctl, | 1400 | .unlocked_ioctl = snd_rawmidi_ioctl, |
1396 | .compat_ioctl = snd_rawmidi_ioctl_compat, | 1401 | .compat_ioctl = snd_rawmidi_ioctl_compat, |
diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c index d0d721c22eac..685712276ac9 100644 --- a/sound/core/seq/oss/seq_oss_init.c +++ b/sound/core/seq/oss/seq_oss_init.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "seq_oss_event.h" | 29 | #include "seq_oss_event.h" |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/moduleparam.h> | 31 | #include <linux/moduleparam.h> |
32 | #include <linux/slab.h> | ||
32 | 33 | ||
33 | /* | 34 | /* |
34 | * common variables | 35 | * common variables |
diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c index 9dfb2f77be60..677dc84590c7 100644 --- a/sound/core/seq/oss/seq_oss_midi.c +++ b/sound/core/seq/oss/seq_oss_midi.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <sound/seq_midi_event.h> | 28 | #include <sound/seq_midi_event.h> |
29 | #include "../seq_lock.h" | 29 | #include "../seq_lock.h" |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/slab.h> | ||
31 | 32 | ||
32 | 33 | ||
33 | /* | 34 | /* |
diff --git a/sound/core/seq/oss/seq_oss_readq.c b/sound/core/seq/oss/seq_oss_readq.c index f5de79f29f1e..73661c4ab82a 100644 --- a/sound/core/seq/oss/seq_oss_readq.c +++ b/sound/core/seq/oss/seq_oss_readq.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <sound/seq_oss_legacy.h> | 25 | #include <sound/seq_oss_legacy.h> |
26 | #include "../seq_lock.h" | 26 | #include "../seq_lock.h" |
27 | #include <linux/wait.h> | 27 | #include <linux/wait.h> |
28 | #include <linux/slab.h> | ||
28 | 29 | ||
29 | /* | 30 | /* |
30 | * constants | 31 | * constants |
diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c index 945a27c34a9d..ee44ab9593c0 100644 --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "seq_oss_midi.h" | 24 | #include "seq_oss_midi.h" |
25 | #include "../seq_lock.h" | 25 | #include "../seq_lock.h" |
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/slab.h> | ||
27 | 28 | ||
28 | /* | 29 | /* |
29 | * constants | 30 | * constants |
diff --git a/sound/core/seq/oss/seq_oss_timer.c b/sound/core/seq/oss/seq_oss_timer.c index c440fdacec93..ab59cbfbcaf2 100644 --- a/sound/core/seq/oss/seq_oss_timer.c +++ b/sound/core/seq/oss/seq_oss_timer.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "seq_oss_timer.h" | 23 | #include "seq_oss_timer.h" |
24 | #include "seq_oss_event.h" | 24 | #include "seq_oss_event.h" |
25 | #include <sound/seq_oss_legacy.h> | 25 | #include <sound/seq_oss_legacy.h> |
26 | #include <linux/slab.h> | ||
26 | 27 | ||
27 | /* | 28 | /* |
28 | */ | 29 | */ |
diff --git a/sound/core/seq/oss/seq_oss_writeq.c b/sound/core/seq/oss/seq_oss_writeq.c index 217424858191..d50338bbc21f 100644 --- a/sound/core/seq/oss/seq_oss_writeq.c +++ b/sound/core/seq/oss/seq_oss_writeq.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "../seq_lock.h" | 27 | #include "../seq_lock.h" |
28 | #include "../seq_clientmgr.h" | 28 | #include "../seq_clientmgr.h" |
29 | #include <linux/wait.h> | 29 | #include <linux/wait.h> |
30 | #include <linux/slab.h> | ||
30 | 31 | ||
31 | 32 | ||
32 | /* | 33 | /* |
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 48eca9ff9ee7..99a485f13648 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c | |||
@@ -318,6 +318,11 @@ static int snd_seq_open(struct inode *inode, struct file *file) | |||
318 | int c, mode; /* client id */ | 318 | int c, mode; /* client id */ |
319 | struct snd_seq_client *client; | 319 | struct snd_seq_client *client; |
320 | struct snd_seq_user_client *user; | 320 | struct snd_seq_user_client *user; |
321 | int err; | ||
322 | |||
323 | err = nonseekable_open(inode, file); | ||
324 | if (err < 0) | ||
325 | return err; | ||
321 | 326 | ||
322 | if (mutex_lock_interruptible(®ister_mutex)) | 327 | if (mutex_lock_interruptible(®ister_mutex)) |
323 | return -ERESTARTSYS; | 328 | return -ERESTARTSYS; |
@@ -2550,6 +2555,7 @@ static const struct file_operations snd_seq_f_ops = | |||
2550 | .write = snd_seq_write, | 2555 | .write = snd_seq_write, |
2551 | .open = snd_seq_open, | 2556 | .open = snd_seq_open, |
2552 | .release = snd_seq_release, | 2557 | .release = snd_seq_release, |
2558 | .llseek = no_llseek, | ||
2553 | .poll = snd_seq_poll, | 2559 | .poll = snd_seq_poll, |
2554 | .unlocked_ioctl = snd_seq_ioctl, | 2560 | .unlocked_ioctl = snd_seq_ioctl, |
2555 | .compat_ioctl = snd_seq_ioctl_compat, | 2561 | .compat_ioctl = snd_seq_ioctl_compat, |
diff --git a/sound/core/seq/seq_compat.c b/sound/core/seq/seq_compat.c index c956fe462569..81f7c109dc46 100644 --- a/sound/core/seq/seq_compat.c +++ b/sound/core/seq/seq_compat.c | |||
@@ -21,6 +21,7 @@ | |||
21 | /* This file included from seq.c */ | 21 | /* This file included from seq.c */ |
22 | 22 | ||
23 | #include <linux/compat.h> | 23 | #include <linux/compat.h> |
24 | #include <linux/slab.h> | ||
24 | 25 | ||
25 | struct snd_seq_port_info32 { | 26 | struct snd_seq_port_info32 { |
26 | struct snd_seq_addr addr; /* client/port numbers */ | 27 | struct snd_seq_addr addr; /* client/port numbers */ |
diff --git a/sound/core/seq/seq_system.c b/sound/core/seq/seq_system.c index 77884e62b648..c38b90cf3cb0 100644 --- a/sound/core/seq/seq_system.c +++ b/sound/core/seq/seq_system.c | |||
@@ -20,6 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/slab.h> | ||
23 | #include <sound/core.h> | 24 | #include <sound/core.h> |
24 | #include "seq_system.h" | 25 | #include "seq_system.h" |
25 | #include "seq_timer.h" | 26 | #include "seq_timer.h" |
diff --git a/sound/core/sound.c b/sound/core/sound.c index 563d1967a0ad..ac42af42b787 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c | |||
@@ -120,7 +120,29 @@ void *snd_lookup_minor_data(unsigned int minor, int type) | |||
120 | 120 | ||
121 | EXPORT_SYMBOL(snd_lookup_minor_data); | 121 | EXPORT_SYMBOL(snd_lookup_minor_data); |
122 | 122 | ||
123 | static int __snd_open(struct inode *inode, struct file *file) | 123 | #ifdef CONFIG_MODULES |
124 | static struct snd_minor *autoload_device(unsigned int minor) | ||
125 | { | ||
126 | int dev; | ||
127 | mutex_unlock(&sound_mutex); /* release lock temporarily */ | ||
128 | dev = SNDRV_MINOR_DEVICE(minor); | ||
129 | if (dev == SNDRV_MINOR_CONTROL) { | ||
130 | /* /dev/aloadC? */ | ||
131 | int card = SNDRV_MINOR_CARD(minor); | ||
132 | if (snd_cards[card] == NULL) | ||
133 | snd_request_card(card); | ||
134 | } else if (dev == SNDRV_MINOR_GLOBAL) { | ||
135 | /* /dev/aloadSEQ */ | ||
136 | snd_request_other(minor); | ||
137 | } | ||
138 | mutex_lock(&sound_mutex); /* reacuire lock */ | ||
139 | return snd_minors[minor]; | ||
140 | } | ||
141 | #else /* !CONFIG_MODULES */ | ||
142 | #define autoload_device(minor) NULL | ||
143 | #endif /* CONFIG_MODULES */ | ||
144 | |||
145 | static int snd_open(struct inode *inode, struct file *file) | ||
124 | { | 146 | { |
125 | unsigned int minor = iminor(inode); | 147 | unsigned int minor = iminor(inode); |
126 | struct snd_minor *mptr = NULL; | 148 | struct snd_minor *mptr = NULL; |
@@ -129,55 +151,36 @@ static int __snd_open(struct inode *inode, struct file *file) | |||
129 | 151 | ||
130 | if (minor >= ARRAY_SIZE(snd_minors)) | 152 | if (minor >= ARRAY_SIZE(snd_minors)) |
131 | return -ENODEV; | 153 | return -ENODEV; |
154 | mutex_lock(&sound_mutex); | ||
132 | mptr = snd_minors[minor]; | 155 | mptr = snd_minors[minor]; |
133 | if (mptr == NULL) { | 156 | if (mptr == NULL) { |
134 | #ifdef CONFIG_MODULES | 157 | mptr = autoload_device(minor); |
135 | int dev = SNDRV_MINOR_DEVICE(minor); | 158 | if (!mptr) { |
136 | if (dev == SNDRV_MINOR_CONTROL) { | 159 | mutex_unlock(&sound_mutex); |
137 | /* /dev/aloadC? */ | ||
138 | int card = SNDRV_MINOR_CARD(minor); | ||
139 | if (snd_cards[card] == NULL) | ||
140 | snd_request_card(card); | ||
141 | } else if (dev == SNDRV_MINOR_GLOBAL) { | ||
142 | /* /dev/aloadSEQ */ | ||
143 | snd_request_other(minor); | ||
144 | } | ||
145 | #ifndef CONFIG_SND_DYNAMIC_MINORS | ||
146 | /* /dev/snd/{controlC?,seq} */ | ||
147 | mptr = snd_minors[minor]; | ||
148 | if (mptr == NULL) | ||
149 | #endif | ||
150 | #endif | ||
151 | return -ENODEV; | 160 | return -ENODEV; |
161 | } | ||
152 | } | 162 | } |
153 | old_fops = file->f_op; | 163 | old_fops = file->f_op; |
154 | file->f_op = fops_get(mptr->f_ops); | 164 | file->f_op = fops_get(mptr->f_ops); |
155 | if (file->f_op == NULL) { | 165 | if (file->f_op == NULL) { |
156 | file->f_op = old_fops; | 166 | file->f_op = old_fops; |
157 | return -ENODEV; | 167 | err = -ENODEV; |
158 | } | 168 | } |
159 | if (file->f_op->open) | 169 | mutex_unlock(&sound_mutex); |
170 | if (err < 0) | ||
171 | return err; | ||
172 | |||
173 | if (file->f_op->open) { | ||
160 | err = file->f_op->open(inode, file); | 174 | err = file->f_op->open(inode, file); |
161 | if (err) { | 175 | if (err) { |
162 | fops_put(file->f_op); | 176 | fops_put(file->f_op); |
163 | file->f_op = fops_get(old_fops); | 177 | file->f_op = fops_get(old_fops); |
178 | } | ||
164 | } | 179 | } |
165 | fops_put(old_fops); | 180 | fops_put(old_fops); |
166 | return err; | 181 | return err; |
167 | } | 182 | } |
168 | 183 | ||
169 | |||
170 | /* BKL pushdown: nasty #ifdef avoidance wrapper */ | ||
171 | static int snd_open(struct inode *inode, struct file *file) | ||
172 | { | ||
173 | int ret; | ||
174 | |||
175 | lock_kernel(); | ||
176 | ret = __snd_open(inode, file); | ||
177 | unlock_kernel(); | ||
178 | return ret; | ||
179 | } | ||
180 | |||
181 | static const struct file_operations snd_fops = | 184 | static const struct file_operations snd_fops = |
182 | { | 185 | { |
183 | .owner = THIS_MODULE, | 186 | .owner = THIS_MODULE, |
diff --git a/sound/core/timer.c b/sound/core/timer.c index 73943651caed..13afb60999b9 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c | |||
@@ -1160,6 +1160,7 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri, | |||
1160 | { | 1160 | { |
1161 | struct snd_timer_user *tu = timeri->callback_data; | 1161 | struct snd_timer_user *tu = timeri->callback_data; |
1162 | struct snd_timer_tread r1; | 1162 | struct snd_timer_tread r1; |
1163 | unsigned long flags; | ||
1163 | 1164 | ||
1164 | if (event >= SNDRV_TIMER_EVENT_START && | 1165 | if (event >= SNDRV_TIMER_EVENT_START && |
1165 | event <= SNDRV_TIMER_EVENT_PAUSE) | 1166 | event <= SNDRV_TIMER_EVENT_PAUSE) |
@@ -1169,9 +1170,9 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri, | |||
1169 | r1.event = event; | 1170 | r1.event = event; |
1170 | r1.tstamp = *tstamp; | 1171 | r1.tstamp = *tstamp; |
1171 | r1.val = resolution; | 1172 | r1.val = resolution; |
1172 | spin_lock(&tu->qlock); | 1173 | spin_lock_irqsave(&tu->qlock, flags); |
1173 | snd_timer_user_append_to_tqueue(tu, &r1); | 1174 | snd_timer_user_append_to_tqueue(tu, &r1); |
1174 | spin_unlock(&tu->qlock); | 1175 | spin_unlock_irqrestore(&tu->qlock, flags); |
1175 | kill_fasync(&tu->fasync, SIGIO, POLL_IN); | 1176 | kill_fasync(&tu->fasync, SIGIO, POLL_IN); |
1176 | wake_up(&tu->qchange_sleep); | 1177 | wake_up(&tu->qchange_sleep); |
1177 | } | 1178 | } |
@@ -1237,6 +1238,11 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri, | |||
1237 | static int snd_timer_user_open(struct inode *inode, struct file *file) | 1238 | static int snd_timer_user_open(struct inode *inode, struct file *file) |
1238 | { | 1239 | { |
1239 | struct snd_timer_user *tu; | 1240 | struct snd_timer_user *tu; |
1241 | int err; | ||
1242 | |||
1243 | err = nonseekable_open(inode, file); | ||
1244 | if (err < 0) | ||
1245 | return err; | ||
1240 | 1246 | ||
1241 | tu = kzalloc(sizeof(*tu), GFP_KERNEL); | 1247 | tu = kzalloc(sizeof(*tu), GFP_KERNEL); |
1242 | if (tu == NULL) | 1248 | if (tu == NULL) |
@@ -1921,6 +1927,7 @@ static const struct file_operations snd_timer_f_ops = | |||
1921 | .read = snd_timer_user_read, | 1927 | .read = snd_timer_user_read, |
1922 | .open = snd_timer_user_open, | 1928 | .open = snd_timer_user_open, |
1923 | .release = snd_timer_user_release, | 1929 | .release = snd_timer_user_release, |
1930 | .llseek = no_llseek, | ||
1924 | .poll = snd_timer_user_poll, | 1931 | .poll = snd_timer_user_poll, |
1925 | .unlocked_ioctl = snd_timer_user_ioctl, | 1932 | .unlocked_ioctl = snd_timer_user_ioctl, |
1926 | .compat_ioctl = snd_timer_user_ioctl_compat, | 1933 | .compat_ioctl = snd_timer_user_ioctl_compat, |