aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /sound/core
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/control.c163
-rw-r--r--sound/core/device.c7
-rw-r--r--sound/core/hrtimer.c7
-rw-r--r--sound/core/info.c1
-rw-r--r--sound/core/init.c31
-rw-r--r--sound/core/jack.c1
-rw-r--r--sound/core/memalloc.c3
-rw-r--r--sound/core/misc.c40
-rw-r--r--sound/core/oss/linear.c10
-rw-r--r--sound/core/oss/mixer_oss.c44
-rw-r--r--sound/core/oss/mulaw.c2
-rw-r--r--sound/core/oss/pcm_oss.c74
-rw-r--r--sound/core/oss/pcm_plugin.c40
-rw-r--r--sound/core/oss/pcm_plugin.h11
-rw-r--r--sound/core/oss/route.c6
-rw-r--r--sound/core/pcm.c13
-rw-r--r--sound/core/pcm_lib.c81
-rw-r--r--sound/core/pcm_memory.c6
-rw-r--r--sound/core/pcm_misc.c35
-rw-r--r--sound/core/pcm_native.c44
-rw-r--r--sound/core/seq/oss/seq_oss.c1
-rw-r--r--sound/core/seq/seq.c4
-rw-r--r--sound/core/seq/seq_clientmgr.c7
-rw-r--r--sound/core/seq/seq_dummy.c2
-rw-r--r--sound/core/seq/seq_memory.c6
-rw-r--r--sound/core/seq/seq_memory.h4
-rw-r--r--sound/core/seq/seq_ports.c2
-rw-r--r--sound/core/seq/seq_queue.c2
-rw-r--r--sound/core/sound.c22
-rw-r--r--sound/core/timer.c15
-rw-r--r--sound/core/vmaster.c4
31 files changed, 447 insertions, 241 deletions
diff --git a/sound/core/control.c b/sound/core/control.c
index 45a818002d99..f8c5be464510 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -279,33 +279,31 @@ void snd_ctl_free_one(struct snd_kcontrol *kcontrol)
279 279
280EXPORT_SYMBOL(snd_ctl_free_one); 280EXPORT_SYMBOL(snd_ctl_free_one);
281 281
282static unsigned int snd_ctl_hole_check(struct snd_card *card, 282static bool snd_ctl_remove_numid_conflict(struct snd_card *card,
283 unsigned int count) 283 unsigned int count)
284{ 284{
285 struct snd_kcontrol *kctl; 285 struct snd_kcontrol *kctl;
286 286
287 list_for_each_entry(kctl, &card->controls, list) { 287 list_for_each_entry(kctl, &card->controls, list) {
288 if ((kctl->id.numid <= card->last_numid && 288 if (kctl->id.numid < card->last_numid + 1 + count &&
289 kctl->id.numid + kctl->count > card->last_numid) || 289 kctl->id.numid + kctl->count > card->last_numid + 1) {
290 (kctl->id.numid <= card->last_numid + count - 1 && 290 card->last_numid = kctl->id.numid + kctl->count - 1;
291 kctl->id.numid + kctl->count > card->last_numid + count - 1)) 291 return true;
292 return card->last_numid = kctl->id.numid + kctl->count - 1; 292 }
293 } 293 }
294 return card->last_numid; 294 return false;
295} 295}
296 296
297static int snd_ctl_find_hole(struct snd_card *card, unsigned int count) 297static int snd_ctl_find_hole(struct snd_card *card, unsigned int count)
298{ 298{
299 unsigned int last_numid, iter = 100000; 299 unsigned int iter = 100000;
300 300
301 last_numid = card->last_numid; 301 while (snd_ctl_remove_numid_conflict(card, count)) {
302 while (last_numid != snd_ctl_hole_check(card, count)) {
303 if (--iter == 0) { 302 if (--iter == 0) {
304 /* this situation is very unlikely */ 303 /* this situation is very unlikely */
305 snd_printk(KERN_ERR "unable to allocate new control numid\n"); 304 snd_printk(KERN_ERR "unable to allocate new control numid\n");
306 return -ENOMEM; 305 return -ENOMEM;
307 } 306 }
308 last_numid = card->last_numid;
309 } 307 }
310 return 0; 308 return 0;
311} 309}
@@ -368,6 +366,70 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
368EXPORT_SYMBOL(snd_ctl_add); 366EXPORT_SYMBOL(snd_ctl_add);
369 367
370/** 368/**
369 * snd_ctl_replace - replace the control instance of the card
370 * @card: the card instance
371 * @kcontrol: the control instance to replace
372 * @add_on_replace: add the control if not already added
373 *
374 * Replaces the given control. If the given control does not exist
375 * and the add_on_replace flag is set, the control is added. If the
376 * control exists, it is destroyed first.
377 *
378 * Returns zero if successful, or a negative error code on failure.
379 *
380 * It frees automatically the control which cannot be added or replaced.
381 */
382int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol,
383 bool add_on_replace)
384{
385 struct snd_ctl_elem_id id;
386 unsigned int idx;
387 struct snd_kcontrol *old;
388 int ret;
389
390 if (!kcontrol)
391 return -EINVAL;
392 if (snd_BUG_ON(!card || !kcontrol->info)) {
393 ret = -EINVAL;
394 goto error;
395 }
396 id = kcontrol->id;
397 down_write(&card->controls_rwsem);
398 old = snd_ctl_find_id(card, &id);
399 if (!old) {
400 if (add_on_replace)
401 goto add;
402 up_write(&card->controls_rwsem);
403 ret = -EINVAL;
404 goto error;
405 }
406 ret = snd_ctl_remove(card, old);
407 if (ret < 0) {
408 up_write(&card->controls_rwsem);
409 goto error;
410 }
411add:
412 if (snd_ctl_find_hole(card, kcontrol->count) < 0) {
413 up_write(&card->controls_rwsem);
414 ret = -ENOMEM;
415 goto error;
416 }
417 list_add_tail(&kcontrol->list, &card->controls);
418 card->controls_count += kcontrol->count;
419 kcontrol->id.numid = card->last_numid + 1;
420 card->last_numid += kcontrol->count;
421 up_write(&card->controls_rwsem);
422 for (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++)
423 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);
424 return 0;
425
426error:
427 snd_ctl_free_one(kcontrol);
428 return ret;
429}
430EXPORT_SYMBOL(snd_ctl_replace);
431
432/**
371 * snd_ctl_remove - remove the control from the card and release it 433 * snd_ctl_remove - remove the control from the card and release it
372 * @card: the card instance 434 * @card: the card instance
373 * @kcontrol: the control instance to remove 435 * @kcontrol: the control instance to remove
@@ -466,6 +528,52 @@ error:
466} 528}
467 529
468/** 530/**
531 * snd_ctl_activate_id - activate/inactivate the control of the given id
532 * @card: the card instance
533 * @id: the control id to activate/inactivate
534 * @active: non-zero to activate
535 *
536 * Finds the control instance with the given id, and activate or
537 * inactivate the control together with notification, if changed.
538 *
539 * Returns 0 if unchanged, 1 if changed, or a negative error code on failure.
540 */
541int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
542 int active)
543{
544 struct snd_kcontrol *kctl;
545 struct snd_kcontrol_volatile *vd;
546 unsigned int index_offset;
547 int ret;
548
549 down_write(&card->controls_rwsem);
550 kctl = snd_ctl_find_id(card, id);
551 if (kctl == NULL) {
552 ret = -ENOENT;
553 goto unlock;
554 }
555 index_offset = snd_ctl_get_ioff(kctl, &kctl->id);
556 vd = &kctl->vd[index_offset];
557 ret = 0;
558 if (active) {
559 if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE))
560 goto unlock;
561 vd->access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
562 } else {
563 if (vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE)
564 goto unlock;
565 vd->access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
566 }
567 ret = 1;
568 unlock:
569 up_write(&card->controls_rwsem);
570 if (ret > 0)
571 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_INFO, id);
572 return ret;
573}
574EXPORT_SYMBOL_GPL(snd_ctl_activate_id);
575
576/**
469 * snd_ctl_rename_id - replace the id of a control on the card 577 * snd_ctl_rename_id - replace the id of a control on the card
470 * @card: the card instance 578 * @card: the card instance
471 * @src_id: the old id 579 * @src_id: the old id
@@ -596,13 +704,12 @@ static int snd_ctl_elem_list(struct snd_card *card,
596 struct snd_ctl_elem_list list; 704 struct snd_ctl_elem_list list;
597 struct snd_kcontrol *kctl; 705 struct snd_kcontrol *kctl;
598 struct snd_ctl_elem_id *dst, *id; 706 struct snd_ctl_elem_id *dst, *id;
599 unsigned int offset, space, first, jidx; 707 unsigned int offset, space, jidx;
600 708
601 if (copy_from_user(&list, _list, sizeof(list))) 709 if (copy_from_user(&list, _list, sizeof(list)))
602 return -EFAULT; 710 return -EFAULT;
603 offset = list.offset; 711 offset = list.offset;
604 space = list.space; 712 space = list.space;
605 first = 0;
606 /* try limit maximum space */ 713 /* try limit maximum space */
607 if (space > 16384) 714 if (space > 16384)
608 return -ENOMEM; 715 return -ENOMEM;
@@ -1488,7 +1595,7 @@ int snd_ctl_create(struct snd_card *card)
1488} 1595}
1489 1596
1490/* 1597/*
1491 * Frequently used control callbacks 1598 * Frequently used control callbacks/helpers
1492 */ 1599 */
1493int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol, 1600int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol,
1494 struct snd_ctl_elem_info *uinfo) 1601 struct snd_ctl_elem_info *uinfo)
@@ -1513,3 +1620,29 @@ int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol,
1513} 1620}
1514 1621
1515EXPORT_SYMBOL(snd_ctl_boolean_stereo_info); 1622EXPORT_SYMBOL(snd_ctl_boolean_stereo_info);
1623
1624/**
1625 * snd_ctl_enum_info - fills the info structure for an enumerated control
1626 * @info: the structure to be filled
1627 * @channels: the number of the control's channels; often one
1628 * @items: the number of control values; also the size of @names
1629 * @names: an array containing the names of all control values
1630 *
1631 * Sets all required fields in @info to their appropriate values.
1632 * If the control's accessibility is not the default (readable and writable),
1633 * the caller has to fill @info->access.
1634 */
1635int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels,
1636 unsigned int items, const char *const names[])
1637{
1638 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1639 info->count = channels;
1640 info->value.enumerated.items = items;
1641 if (info->value.enumerated.item >= items)
1642 info->value.enumerated.item = items - 1;
1643 strlcpy(info->value.enumerated.name,
1644 names[info->value.enumerated.item],
1645 sizeof(info->value.enumerated.name));
1646 return 0;
1647}
1648EXPORT_SYMBOL(snd_ctl_enum_info);
diff --git a/sound/core/device.c b/sound/core/device.c
index a67dfac08c03..2d1ad4b0cd65 100644
--- a/sound/core/device.c
+++ b/sound/core/device.c
@@ -225,15 +225,16 @@ int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
225{ 225{
226 struct snd_device *dev; 226 struct snd_device *dev;
227 int err; 227 int err;
228 unsigned int range_low, range_high; 228 unsigned int range_low, range_high, type;
229 229
230 if (snd_BUG_ON(!card)) 230 if (snd_BUG_ON(!card))
231 return -ENXIO; 231 return -ENXIO;
232 range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE; 232 range_low = (__force unsigned int)cmd * SNDRV_DEV_TYPE_RANGE_SIZE;
233 range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1; 233 range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1;
234 __again: 234 __again:
235 list_for_each_entry(dev, &card->devices, list) { 235 list_for_each_entry(dev, &card->devices, list) {
236 if (dev->type >= range_low && dev->type <= range_high) { 236 type = (__force unsigned int)dev->type;
237 if (type >= range_low && type <= range_high) {
237 if ((err = snd_device_free(card, dev->device_data)) < 0) 238 if ((err = snd_device_free(card, dev->device_data)) < 0)
238 return err; 239 return err;
239 goto __again; 240 goto __again;
diff --git a/sound/core/hrtimer.c b/sound/core/hrtimer.c
index 7730575bfadd..b8b31c433d64 100644
--- a/sound/core/hrtimer.c
+++ b/sound/core/hrtimer.c
@@ -45,12 +45,13 @@ static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt)
45{ 45{
46 struct snd_hrtimer *stime = container_of(hrt, struct snd_hrtimer, hrt); 46 struct snd_hrtimer *stime = container_of(hrt, struct snd_hrtimer, hrt);
47 struct snd_timer *t = stime->timer; 47 struct snd_timer *t = stime->timer;
48 unsigned long oruns;
48 49
49 if (!atomic_read(&stime->running)) 50 if (!atomic_read(&stime->running))
50 return HRTIMER_NORESTART; 51 return HRTIMER_NORESTART;
51 52
52 hrtimer_forward_now(hrt, ns_to_ktime(t->sticks * resolution)); 53 oruns = hrtimer_forward_now(hrt, ns_to_ktime(t->sticks * resolution));
53 snd_timer_interrupt(stime->timer, t->sticks); 54 snd_timer_interrupt(stime->timer, t->sticks * oruns);
54 55
55 if (!atomic_read(&stime->running)) 56 if (!atomic_read(&stime->running))
56 return HRTIMER_NORESTART; 57 return HRTIMER_NORESTART;
@@ -104,7 +105,7 @@ static int snd_hrtimer_stop(struct snd_timer *t)
104} 105}
105 106
106static struct snd_timer_hardware hrtimer_hw = { 107static struct snd_timer_hardware hrtimer_hw = {
107 .flags = SNDRV_TIMER_HW_AUTO, 108 .flags = SNDRV_TIMER_HW_AUTO | SNDRV_TIMER_HW_TASKLET,
108 .open = snd_hrtimer_open, 109 .open = snd_hrtimer_open,
109 .close = snd_hrtimer_close, 110 .close = snd_hrtimer_close,
110 .start = snd_hrtimer_start, 111 .start = snd_hrtimer_start,
diff --git a/sound/core/info.c b/sound/core/info.c
index b70564ed8b37..7077f601da5a 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -23,7 +23,6 @@
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/slab.h>
26#include <linux/smp_lock.h>
27#include <linux/string.h> 26#include <linux/string.h>
28#include <sound/core.h> 27#include <sound/core.h>
29#include <sound/minors.h> 28#include <sound/minors.h>
diff --git a/sound/core/init.c b/sound/core/init.c
index ec4a50ce5656..2c041bb36ab3 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -342,7 +342,6 @@ static const struct file_operations snd_shutdown_f_ops =
342int snd_card_disconnect(struct snd_card *card) 342int snd_card_disconnect(struct snd_card *card)
343{ 343{
344 struct snd_monitor_file *mfile; 344 struct snd_monitor_file *mfile;
345 struct file *file;
346 int err; 345 int err;
347 346
348 if (!card) 347 if (!card)
@@ -366,8 +365,6 @@ int snd_card_disconnect(struct snd_card *card)
366 365
367 spin_lock(&card->files_lock); 366 spin_lock(&card->files_lock);
368 list_for_each_entry(mfile, &card->files_list, list) { 367 list_for_each_entry(mfile, &card->files_list, list) {
369 file = mfile->file;
370
371 /* it's critical part, use endless loop */ 368 /* it's critical part, use endless loop */
372 /* we have no room to fail */ 369 /* we have no room to fail */
373 mfile->disconnected_f_op = mfile->file->f_op; 370 mfile->disconnected_f_op = mfile->file->f_op;
@@ -395,12 +392,10 @@ int snd_card_disconnect(struct snd_card *card)
395 snd_printk(KERN_ERR "not all devices for card %i can be disconnected\n", card->number); 392 snd_printk(KERN_ERR "not all devices for card %i can be disconnected\n", card->number);
396 393
397 snd_info_card_disconnect(card); 394 snd_info_card_disconnect(card);
398#ifndef CONFIG_SYSFS_DEPRECATED
399 if (card->card_dev) { 395 if (card->card_dev) {
400 device_unregister(card->card_dev); 396 device_unregister(card->card_dev);
401 card->card_dev = NULL; 397 card->card_dev = NULL;
402 } 398 }
403#endif
404#ifdef CONFIG_PM 399#ifdef CONFIG_PM
405 wake_up(&card->power_sleep); 400 wake_up(&card->power_sleep);
406#endif 401#endif
@@ -516,7 +511,7 @@ static void snd_card_set_id_no_lock(struct snd_card *card, const char *nid)
516 id = card->id; 511 id = card->id;
517 512
518 if (*id == '\0') 513 if (*id == '\0')
519 strcpy(id, "default"); 514 strcpy(id, "Default");
520 515
521 while (1) { 516 while (1) {
522 if (loops-- == 0) { 517 if (loops-- == 0) {
@@ -573,7 +568,6 @@ void snd_card_set_id(struct snd_card *card, const char *nid)
573} 568}
574EXPORT_SYMBOL(snd_card_set_id); 569EXPORT_SYMBOL(snd_card_set_id);
575 570
576#ifndef CONFIG_SYSFS_DEPRECATED
577static ssize_t 571static ssize_t
578card_id_show_attr(struct device *dev, 572card_id_show_attr(struct device *dev,
579 struct device_attribute *attr, char *buf) 573 struct device_attribute *attr, char *buf)
@@ -607,11 +601,16 @@ card_id_store_attr(struct device *dev, struct device_attribute *attr,
607 return -EEXIST; 601 return -EEXIST;
608 } 602 }
609 for (idx = 0; idx < snd_ecards_limit; idx++) { 603 for (idx = 0; idx < snd_ecards_limit; idx++) {
610 if (snd_cards[idx] && !strcmp(snd_cards[idx]->id, buf1)) 604 if (snd_cards[idx] && !strcmp(snd_cards[idx]->id, buf1)) {
611 goto __exist; 605 if (card == snd_cards[idx])
606 goto __ok;
607 else
608 goto __exist;
609 }
612 } 610 }
613 strcpy(card->id, buf1); 611 strcpy(card->id, buf1);
614 snd_info_card_id_change(card); 612 snd_info_card_id_change(card);
613__ok:
615 mutex_unlock(&snd_card_mutex); 614 mutex_unlock(&snd_card_mutex);
616 615
617 return count; 616 return count;
@@ -630,7 +629,6 @@ card_number_show_attr(struct device *dev,
630 629
631static struct device_attribute card_number_attrs = 630static struct device_attribute card_number_attrs =
632 __ATTR(number, S_IRUGO, card_number_show_attr, NULL); 631 __ATTR(number, S_IRUGO, card_number_show_attr, NULL);
633#endif /* CONFIG_SYSFS_DEPRECATED */
634 632
635/** 633/**
636 * snd_card_register - register the soundcard 634 * snd_card_register - register the soundcard
@@ -641,7 +639,7 @@ static struct device_attribute card_number_attrs =
641 * external accesses. Thus, you should call this function at the end 639 * external accesses. Thus, you should call this function at the end
642 * of the initialization of the card. 640 * of the initialization of the card.
643 * 641 *
644 * Returns zero otherwise a negative error code if the registrain failed. 642 * Returns zero otherwise a negative error code if the registration failed.
645 */ 643 */
646int snd_card_register(struct snd_card *card) 644int snd_card_register(struct snd_card *card)
647{ 645{
@@ -649,7 +647,7 @@ int snd_card_register(struct snd_card *card)
649 647
650 if (snd_BUG_ON(!card)) 648 if (snd_BUG_ON(!card))
651 return -EINVAL; 649 return -EINVAL;
652#ifndef CONFIG_SYSFS_DEPRECATED 650
653 if (!card->card_dev) { 651 if (!card->card_dev) {
654 card->card_dev = device_create(sound_class, card->dev, 652 card->card_dev = device_create(sound_class, card->dev,
655 MKDEV(0, 0), card, 653 MKDEV(0, 0), card,
@@ -657,7 +655,7 @@ int snd_card_register(struct snd_card *card)
657 if (IS_ERR(card->card_dev)) 655 if (IS_ERR(card->card_dev))
658 card->card_dev = NULL; 656 card->card_dev = NULL;
659 } 657 }
660#endif 658
661 if ((err = snd_device_register_all(card)) < 0) 659 if ((err = snd_device_register_all(card)) < 0)
662 return err; 660 return err;
663 mutex_lock(&snd_card_mutex); 661 mutex_lock(&snd_card_mutex);
@@ -674,7 +672,6 @@ int snd_card_register(struct snd_card *card)
674 if (snd_mixer_oss_notify_callback) 672 if (snd_mixer_oss_notify_callback)
675 snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); 673 snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER);
676#endif 674#endif
677#ifndef CONFIG_SYSFS_DEPRECATED
678 if (card->card_dev) { 675 if (card->card_dev) {
679 err = device_create_file(card->card_dev, &card_id_attrs); 676 err = device_create_file(card->card_dev, &card_id_attrs);
680 if (err < 0) 677 if (err < 0)
@@ -683,7 +680,7 @@ int snd_card_register(struct snd_card *card)
683 if (err < 0) 680 if (err < 0)
684 return err; 681 return err;
685 } 682 }
686#endif 683
687 return 0; 684 return 0;
688} 685}
689 686
@@ -848,6 +845,7 @@ int snd_card_file_add(struct snd_card *card, struct file *file)
848 return -ENOMEM; 845 return -ENOMEM;
849 mfile->file = file; 846 mfile->file = file;
850 mfile->disconnected_f_op = NULL; 847 mfile->disconnected_f_op = NULL;
848 INIT_LIST_HEAD(&mfile->shutdown_list);
851 spin_lock(&card->files_lock); 849 spin_lock(&card->files_lock);
852 if (card->shutdown) { 850 if (card->shutdown) {
853 spin_unlock(&card->files_lock); 851 spin_unlock(&card->files_lock);
@@ -883,6 +881,9 @@ int snd_card_file_remove(struct snd_card *card, struct file *file)
883 list_for_each_entry(mfile, &card->files_list, list) { 881 list_for_each_entry(mfile, &card->files_list, list) {
884 if (mfile->file == file) { 882 if (mfile->file == file) {
885 list_del(&mfile->list); 883 list_del(&mfile->list);
884 spin_lock(&shutdown_lock);
885 list_del(&mfile->shutdown_list);
886 spin_unlock(&shutdown_lock);
886 if (mfile->disconnected_f_op) 887 if (mfile->disconnected_f_op)
887 fops_put(mfile->disconnected_f_op); 888 fops_put(mfile->disconnected_f_op);
888 found = mfile; 889 found = mfile;
diff --git a/sound/core/jack.c b/sound/core/jack.c
index 4902ae568730..53b53e97c896 100644
--- a/sound/core/jack.c
+++ b/sound/core/jack.c
@@ -141,6 +141,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
141 141
142fail_input: 142fail_input:
143 input_free_device(jack->input_dev); 143 input_free_device(jack->input_dev);
144 kfree(jack->id);
144 kfree(jack); 145 kfree(jack);
145 return err; 146 return err;
146} 147}
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index 9e92441f9b78..16bd9c03679b 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -192,7 +192,8 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,
192 dmab->bytes = 0; 192 dmab->bytes = 0;
193 switch (type) { 193 switch (type) {
194 case SNDRV_DMA_TYPE_CONTINUOUS: 194 case SNDRV_DMA_TYPE_CONTINUOUS:
195 dmab->area = snd_malloc_pages(size, (unsigned long)device); 195 dmab->area = snd_malloc_pages(size,
196 (__force gfp_t)(unsigned long)device);
196 dmab->addr = 0; 197 dmab->addr = 0;
197 break; 198 break;
198#ifdef CONFIG_HAS_DMA 199#ifdef CONFIG_HAS_DMA
diff --git a/sound/core/misc.c b/sound/core/misc.c
index 2c41825c836e..eb9fe2e1d291 100644
--- a/sound/core/misc.c
+++ b/sound/core/misc.c
@@ -58,26 +58,6 @@ static const char *sanity_file_name(const char *path)
58 else 58 else
59 return path; 59 return path;
60} 60}
61
62/* print file and line with a certain printk prefix */
63static int print_snd_pfx(unsigned int level, const char *path, int line,
64 const char *format)
65{
66 const char *file = sanity_file_name(path);
67 char tmp[] = "<0>";
68 const char *pfx = level ? KERN_DEBUG : KERN_DEFAULT;
69 int ret = 0;
70
71 if (format[0] == '<' && format[2] == '>') {
72 tmp[1] = format[1];
73 pfx = tmp;
74 ret = 1;
75 }
76 printk("%sALSA %s:%d: ", pfx, file, line);
77 return ret;
78}
79#else
80#define print_snd_pfx(level, path, line, format) 0
81#endif 61#endif
82 62
83#if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) 63#if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK)
@@ -85,15 +65,29 @@ void __snd_printk(unsigned int level, const char *path, int line,
85 const char *format, ...) 65 const char *format, ...)
86{ 66{
87 va_list args; 67 va_list args;
88 68#ifdef CONFIG_SND_VERBOSE_PRINTK
69 struct va_format vaf;
70 char verbose_fmt[] = KERN_DEFAULT "ALSA %s:%d %pV";
71#endif
72
89#ifdef CONFIG_SND_DEBUG 73#ifdef CONFIG_SND_DEBUG
90 if (debug < level) 74 if (debug < level)
91 return; 75 return;
92#endif 76#endif
77
93 va_start(args, format); 78 va_start(args, format);
94 if (print_snd_pfx(level, path, line, format)) 79#ifdef CONFIG_SND_VERBOSE_PRINTK
95 format += 3; /* skip the printk level-prefix */ 80 vaf.fmt = format;
81 vaf.va = &args;
82 if (format[0] == '<' && format[2] == '>') {
83 memcpy(verbose_fmt, format, 3);
84 vaf.fmt = format + 3;
85 } else if (level)
86 memcpy(verbose_fmt, KERN_DEBUG, 3);
87 printk(verbose_fmt, sanity_file_name(path), line, &vaf);
88#else
96 vprintk(format, args); 89 vprintk(format, args);
90#endif
97 va_end(args); 91 va_end(args);
98} 92}
99EXPORT_SYMBOL_GPL(__snd_printk); 93EXPORT_SYMBOL_GPL(__snd_printk);
diff --git a/sound/core/oss/linear.c b/sound/core/oss/linear.c
index 4c1d16827199..2045697f449d 100644
--- a/sound/core/oss/linear.c
+++ b/sound/core/oss/linear.c
@@ -90,11 +90,8 @@ static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin,
90 struct snd_pcm_plugin_channel *dst_channels, 90 struct snd_pcm_plugin_channel *dst_channels,
91 snd_pcm_uframes_t frames) 91 snd_pcm_uframes_t frames)
92{ 92{
93 struct linear_priv *data;
94
95 if (snd_BUG_ON(!plugin || !src_channels || !dst_channels)) 93 if (snd_BUG_ON(!plugin || !src_channels || !dst_channels))
96 return -ENXIO; 94 return -ENXIO;
97 data = (struct linear_priv *)plugin->extra_data;
98 if (frames == 0) 95 if (frames == 0)
99 return 0; 96 return 0;
100#ifdef CONFIG_SND_DEBUG 97#ifdef CONFIG_SND_DEBUG
@@ -114,7 +111,8 @@ static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin,
114 return frames; 111 return frames;
115} 112}
116 113
117static void init_data(struct linear_priv *data, int src_format, int dst_format) 114static void init_data(struct linear_priv *data,
115 snd_pcm_format_t src_format, snd_pcm_format_t dst_format)
118{ 116{
119 int src_le, dst_le, src_bytes, dst_bytes; 117 int src_le, dst_le, src_bytes, dst_bytes;
120 118
@@ -140,9 +138,9 @@ static void init_data(struct linear_priv *data, int src_format, int dst_format)
140 if (snd_pcm_format_signed(src_format) != 138 if (snd_pcm_format_signed(src_format) !=
141 snd_pcm_format_signed(dst_format)) { 139 snd_pcm_format_signed(dst_format)) {
142 if (dst_le) 140 if (dst_le)
143 data->flip = cpu_to_le32(0x80000000); 141 data->flip = (__force u32)cpu_to_le32(0x80000000);
144 else 142 else
145 data->flip = cpu_to_be32(0x80000000); 143 data->flip = (__force u32)cpu_to_be32(0x80000000);
146 } 144 }
147} 145}
148 146
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index f50ebf20df96..d8359cfeca15 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -77,7 +77,7 @@ static int snd_mixer_oss_release(struct inode *inode, struct file *file)
77 struct snd_mixer_oss_file *fmixer; 77 struct snd_mixer_oss_file *fmixer;
78 78
79 if (file->private_data) { 79 if (file->private_data) {
80 fmixer = (struct snd_mixer_oss_file *) file->private_data; 80 fmixer = file->private_data;
81 module_put(fmixer->card->module); 81 module_put(fmixer->card->module);
82 snd_card_file_remove(fmixer->card, file); 82 snd_card_file_remove(fmixer->card, file);
83 kfree(fmixer); 83 kfree(fmixer);
@@ -190,9 +190,10 @@ static int snd_mixer_oss_get_recsrc(struct snd_mixer_oss_file *fmixer)
190 return -EIO; 190 return -EIO;
191 if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */ 191 if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */
192 int err; 192 int err;
193 if ((err = mixer->get_recsrc(fmixer, &result)) < 0) 193 unsigned int index;
194 if ((err = mixer->get_recsrc(fmixer, &index)) < 0)
194 return err; 195 return err;
195 result = 1 << result; 196 result = 1 << index;
196 } else { 197 } else {
197 struct snd_mixer_oss_slot *pslot; 198 struct snd_mixer_oss_slot *pslot;
198 int chn; 199 int chn;
@@ -214,6 +215,7 @@ static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsr
214 struct snd_mixer_oss *mixer = fmixer->mixer; 215 struct snd_mixer_oss *mixer = fmixer->mixer;
215 struct snd_mixer_oss_slot *pslot; 216 struct snd_mixer_oss_slot *pslot;
216 int chn, active; 217 int chn, active;
218 unsigned int index;
217 int result = 0; 219 int result = 0;
218 220
219 if (mixer == NULL) 221 if (mixer == NULL)
@@ -222,8 +224,8 @@ static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsr
222 if (recsrc & ~mixer->oss_recsrc) 224 if (recsrc & ~mixer->oss_recsrc)
223 recsrc &= ~mixer->oss_recsrc; 225 recsrc &= ~mixer->oss_recsrc;
224 mixer->put_recsrc(fmixer, ffz(~recsrc)); 226 mixer->put_recsrc(fmixer, ffz(~recsrc));
225 mixer->get_recsrc(fmixer, &result); 227 mixer->get_recsrc(fmixer, &index);
226 result = 1 << result; 228 result = 1 << index;
227 } 229 }
228 for (chn = 0; chn < 31; chn++) { 230 for (chn = 0; chn < 31; chn++) {
229 pslot = &mixer->slots[chn]; 231 pslot = &mixer->slots[chn];
@@ -368,7 +370,7 @@ static int snd_mixer_oss_ioctl1(struct snd_mixer_oss_file *fmixer, unsigned int
368 370
369static long snd_mixer_oss_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 371static long snd_mixer_oss_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
370{ 372{
371 return snd_mixer_oss_ioctl1((struct snd_mixer_oss_file *) file->private_data, cmd, arg); 373 return snd_mixer_oss_ioctl1(file->private_data, cmd, arg);
372} 374}
373 375
374int snd_mixer_oss_ioctl_card(struct snd_card *card, unsigned int cmd, unsigned long arg) 376int snd_mixer_oss_ioctl_card(struct snd_card *card, unsigned int cmd, unsigned long arg)
@@ -582,7 +584,7 @@ static int snd_mixer_oss_get_volume1(struct snd_mixer_oss_file *fmixer,
582 struct snd_mixer_oss_slot *pslot, 584 struct snd_mixer_oss_slot *pslot,
583 int *left, int *right) 585 int *left, int *right)
584{ 586{
585 struct slot *slot = (struct slot *)pslot->private_data; 587 struct slot *slot = pslot->private_data;
586 588
587 *left = *right = 100; 589 *left = *right = 100;
588 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PVOLUME) { 590 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PVOLUME) {
@@ -618,8 +620,10 @@ static void snd_mixer_oss_put_volume1_vol(struct snd_mixer_oss_file *fmixer,
618 if (numid == ID_UNKNOWN) 620 if (numid == ID_UNKNOWN)
619 return; 621 return;
620 down_read(&card->controls_rwsem); 622 down_read(&card->controls_rwsem);
621 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) 623 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) {
624 up_read(&card->controls_rwsem);
622 return; 625 return;
626 }
623 uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); 627 uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
624 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); 628 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
625 if (uinfo == NULL || uctl == NULL) 629 if (uinfo == NULL || uctl == NULL)
@@ -658,7 +662,7 @@ static void snd_mixer_oss_put_volume1_sw(struct snd_mixer_oss_file *fmixer,
658 return; 662 return;
659 down_read(&card->controls_rwsem); 663 down_read(&card->controls_rwsem);
660 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) { 664 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) {
661 up_read(&fmixer->card->controls_rwsem); 665 up_read(&card->controls_rwsem);
662 return; 666 return;
663 } 667 }
664 uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); 668 uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
@@ -691,7 +695,7 @@ static int snd_mixer_oss_put_volume1(struct snd_mixer_oss_file *fmixer,
691 struct snd_mixer_oss_slot *pslot, 695 struct snd_mixer_oss_slot *pslot,
692 int left, int right) 696 int left, int right)
693{ 697{
694 struct slot *slot = (struct slot *)pslot->private_data; 698 struct slot *slot = pslot->private_data;
695 699
696 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PVOLUME) { 700 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PVOLUME) {
697 snd_mixer_oss_put_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PVOLUME], left, right); 701 snd_mixer_oss_put_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PVOLUME], left, right);
@@ -740,7 +744,7 @@ static int snd_mixer_oss_get_recsrc1_sw(struct snd_mixer_oss_file *fmixer,
740 struct snd_mixer_oss_slot *pslot, 744 struct snd_mixer_oss_slot *pslot,
741 int *active) 745 int *active)
742{ 746{
743 struct slot *slot = (struct slot *)pslot->private_data; 747 struct slot *slot = pslot->private_data;
744 int left, right; 748 int left, right;
745 749
746 left = right = 1; 750 left = right = 1;
@@ -753,7 +757,7 @@ static int snd_mixer_oss_get_recsrc1_route(struct snd_mixer_oss_file *fmixer,
753 struct snd_mixer_oss_slot *pslot, 757 struct snd_mixer_oss_slot *pslot,
754 int *active) 758 int *active)
755{ 759{
756 struct slot *slot = (struct slot *)pslot->private_data; 760 struct slot *slot = pslot->private_data;
757 int left, right; 761 int left, right;
758 762
759 left = right = 1; 763 left = right = 1;
@@ -766,7 +770,7 @@ static int snd_mixer_oss_put_recsrc1_sw(struct snd_mixer_oss_file *fmixer,
766 struct snd_mixer_oss_slot *pslot, 770 struct snd_mixer_oss_slot *pslot,
767 int active) 771 int active)
768{ 772{
769 struct slot *slot = (struct slot *)pslot->private_data; 773 struct slot *slot = pslot->private_data;
770 774
771 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CSWITCH], active, active, 0); 775 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CSWITCH], active, active, 0);
772 return 0; 776 return 0;
@@ -776,7 +780,7 @@ static int snd_mixer_oss_put_recsrc1_route(struct snd_mixer_oss_file *fmixer,
776 struct snd_mixer_oss_slot *pslot, 780 struct snd_mixer_oss_slot *pslot,
777 int active) 781 int active)
778{ 782{
779 struct slot *slot = (struct slot *)pslot->private_data; 783 struct slot *slot = pslot->private_data;
780 784
781 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CROUTE], active, active, 1); 785 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CROUTE], active, active, 1);
782 return 0; 786 return 0;
@@ -797,7 +801,7 @@ static int snd_mixer_oss_get_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
797 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); 801 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
798 if (uinfo == NULL || uctl == NULL) { 802 if (uinfo == NULL || uctl == NULL) {
799 err = -ENOMEM; 803 err = -ENOMEM;
800 goto __unlock; 804 goto __free_only;
801 } 805 }
802 down_read(&card->controls_rwsem); 806 down_read(&card->controls_rwsem);
803 kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0); 807 kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0);
@@ -813,7 +817,7 @@ static int snd_mixer_oss_get_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
813 if (!(mixer->mask_recsrc & (1 << idx))) 817 if (!(mixer->mask_recsrc & (1 << idx)))
814 continue; 818 continue;
815 pslot = &mixer->slots[idx]; 819 pslot = &mixer->slots[idx];
816 slot = (struct slot *)pslot->private_data; 820 slot = pslot->private_data;
817 if (slot->signature != SNDRV_MIXER_OSS_SIGNATURE) 821 if (slot->signature != SNDRV_MIXER_OSS_SIGNATURE)
818 continue; 822 continue;
819 if (!(slot->present & SNDRV_MIXER_OSS_PRESENT_CAPTURE)) 823 if (!(slot->present & SNDRV_MIXER_OSS_PRESENT_CAPTURE))
@@ -826,6 +830,7 @@ static int snd_mixer_oss_get_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
826 err = 0; 830 err = 0;
827 __unlock: 831 __unlock:
828 up_read(&card->controls_rwsem); 832 up_read(&card->controls_rwsem);
833 __free_only:
829 kfree(uctl); 834 kfree(uctl);
830 kfree(uinfo); 835 kfree(uinfo);
831 return err; 836 return err;
@@ -847,7 +852,7 @@ static int snd_mixer_oss_put_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
847 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); 852 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
848 if (uinfo == NULL || uctl == NULL) { 853 if (uinfo == NULL || uctl == NULL) {
849 err = -ENOMEM; 854 err = -ENOMEM;
850 goto __unlock; 855 goto __free_only;
851 } 856 }
852 down_read(&card->controls_rwsem); 857 down_read(&card->controls_rwsem);
853 kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0); 858 kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0);
@@ -861,7 +866,7 @@ static int snd_mixer_oss_put_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
861 if (!(mixer->mask_recsrc & (1 << idx))) 866 if (!(mixer->mask_recsrc & (1 << idx)))
862 continue; 867 continue;
863 pslot = &mixer->slots[idx]; 868 pslot = &mixer->slots[idx];
864 slot = (struct slot *)pslot->private_data; 869 slot = pslot->private_data;
865 if (slot->signature != SNDRV_MIXER_OSS_SIGNATURE) 870 if (slot->signature != SNDRV_MIXER_OSS_SIGNATURE)
866 continue; 871 continue;
867 if (!(slot->present & SNDRV_MIXER_OSS_PRESENT_CAPTURE)) 872 if (!(slot->present & SNDRV_MIXER_OSS_PRESENT_CAPTURE))
@@ -880,6 +885,7 @@ static int snd_mixer_oss_put_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
880 err = 0; 885 err = 0;
881 __unlock: 886 __unlock:
882 up_read(&card->controls_rwsem); 887 up_read(&card->controls_rwsem);
888 __free_only:
883 kfree(uctl); 889 kfree(uctl);
884 kfree(uinfo); 890 kfree(uinfo);
885 return err; 891 return err;
@@ -925,7 +931,7 @@ static int snd_mixer_oss_build_test(struct snd_mixer_oss *mixer, struct slot *sl
925 931
926static void snd_mixer_oss_slot_free(struct snd_mixer_oss_slot *chn) 932static void snd_mixer_oss_slot_free(struct snd_mixer_oss_slot *chn)
927{ 933{
928 struct slot *p = (struct slot *)chn->private_data; 934 struct slot *p = chn->private_data;
929 if (p) { 935 if (p) {
930 if (p->allocated && p->assigned) { 936 if (p->allocated && p->assigned) {
931 kfree(p->assigned->name); 937 kfree(p->assigned->name);
diff --git a/sound/core/oss/mulaw.c b/sound/core/oss/mulaw.c
index f7649d4d950b..7915564bd394 100644
--- a/sound/core/oss/mulaw.c
+++ b/sound/core/oss/mulaw.c
@@ -274,7 +274,7 @@ static snd_pcm_sframes_t mulaw_transfer(struct snd_pcm_plugin *plugin,
274 return frames; 274 return frames;
275} 275}
276 276
277static void init_data(struct mulaw_priv *data, int format) 277static void init_data(struct mulaw_priv *data, snd_pcm_format_t format)
278{ 278{
279#ifdef SNDRV_LITTLE_ENDIAN 279#ifdef SNDRV_LITTLE_ENDIAN
280 data->cvt_endian = snd_pcm_format_big_endian(format) > 0; 280 data->cvt_endian = snd_pcm_format_big_endian(format) > 0;
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 5c8c7dff8ede..23c34a02894b 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -41,6 +41,7 @@
41#include <sound/info.h> 41#include <sound/info.h>
42#include <linux/soundcard.h> 42#include <linux/soundcard.h>
43#include <sound/initval.h> 43#include <sound/initval.h>
44#include <sound/mixer_oss.h>
44 45
45#define OSS_ALSAEMULVER _SIOR ('M', 249, int) 46#define OSS_ALSAEMULVER _SIOR ('M', 249, int)
46 47
@@ -60,7 +61,6 @@ MODULE_PARM_DESC(nonblock_open, "Don't block opening busy PCM devices.");
60MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM); 61MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM);
61MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM1); 62MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM1);
62 63
63extern int snd_mixer_oss_ioctl_card(struct snd_card *card, unsigned int cmd, unsigned long arg);
64static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file); 64static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file);
65static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file); 65static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file);
66static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file); 66static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file);
@@ -453,8 +453,10 @@ static int snd_pcm_hw_param_near(struct snd_pcm_substream *pcm,
453 } else { 453 } else {
454 *params = *save; 454 *params = *save;
455 max = snd_pcm_hw_param_max(pcm, params, var, max, &maxdir); 455 max = snd_pcm_hw_param_max(pcm, params, var, max, &maxdir);
456 if (max < 0) 456 if (max < 0) {
457 kfree(save);
457 return max; 458 return max;
459 }
458 last = 1; 460 last = 1;
459 } 461 }
460 _end: 462 _end:
@@ -654,7 +656,7 @@ snd_pcm_uframes_t get_hw_ptr_period(struct snd_pcm_runtime *runtime)
654#define AFMT_AC3 0x00000400 656#define AFMT_AC3 0x00000400
655#define AFMT_VORBIS 0x00000800 657#define AFMT_VORBIS 0x00000800
656 658
657static int snd_pcm_oss_format_from(int format) 659static snd_pcm_format_t snd_pcm_oss_format_from(int format)
658{ 660{
659 switch (format) { 661 switch (format) {
660 case AFMT_MU_LAW: return SNDRV_PCM_FORMAT_MU_LAW; 662 case AFMT_MU_LAW: return SNDRV_PCM_FORMAT_MU_LAW;
@@ -678,7 +680,7 @@ static int snd_pcm_oss_format_from(int format)
678 } 680 }
679} 681}
680 682
681static int snd_pcm_oss_format_to(int format) 683static int snd_pcm_oss_format_to(snd_pcm_format_t format)
682{ 684{
683 switch (format) { 685 switch (format) {
684 case SNDRV_PCM_FORMAT_MU_LAW: return AFMT_MU_LAW; 686 case SNDRV_PCM_FORMAT_MU_LAW: return AFMT_MU_LAW;
@@ -841,7 +843,8 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
841 size_t oss_frame_size; 843 size_t oss_frame_size;
842 int err; 844 int err;
843 int direct; 845 int direct;
844 int format, sformat, n; 846 snd_pcm_format_t format, sformat;
847 int n;
845 struct snd_mask sformat_mask; 848 struct snd_mask sformat_mask;
846 struct snd_mask mask; 849 struct snd_mask mask;
847 850
@@ -866,11 +869,11 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
866 _snd_pcm_hw_param_min(sparams, SNDRV_PCM_HW_PARAM_PERIODS, 2, 0); 869 _snd_pcm_hw_param_min(sparams, SNDRV_PCM_HW_PARAM_PERIODS, 2, 0);
867 snd_mask_none(&mask); 870 snd_mask_none(&mask);
868 if (atomic_read(&substream->mmap_count)) 871 if (atomic_read(&substream->mmap_count))
869 snd_mask_set(&mask, SNDRV_PCM_ACCESS_MMAP_INTERLEAVED); 872 snd_mask_set(&mask, (__force int)SNDRV_PCM_ACCESS_MMAP_INTERLEAVED);
870 else { 873 else {
871 snd_mask_set(&mask, SNDRV_PCM_ACCESS_RW_INTERLEAVED); 874 snd_mask_set(&mask, (__force int)SNDRV_PCM_ACCESS_RW_INTERLEAVED);
872 if (!direct) 875 if (!direct)
873 snd_mask_set(&mask, SNDRV_PCM_ACCESS_RW_NONINTERLEAVED); 876 snd_mask_set(&mask, (__force int)SNDRV_PCM_ACCESS_RW_NONINTERLEAVED);
874 } 877 }
875 err = snd_pcm_hw_param_mask(substream, sparams, SNDRV_PCM_HW_PARAM_ACCESS, &mask); 878 err = snd_pcm_hw_param_mask(substream, sparams, SNDRV_PCM_HW_PARAM_ACCESS, &mask);
876 if (err < 0) { 879 if (err < 0) {
@@ -889,19 +892,22 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
889 else 892 else
890 sformat = snd_pcm_plug_slave_format(format, &sformat_mask); 893 sformat = snd_pcm_plug_slave_format(format, &sformat_mask);
891 894
892 if (sformat < 0 || !snd_mask_test(&sformat_mask, sformat)) { 895 if ((__force int)sformat < 0 ||
893 for (sformat = 0; sformat <= SNDRV_PCM_FORMAT_LAST; sformat++) { 896 !snd_mask_test(&sformat_mask, (__force int)sformat)) {
894 if (snd_mask_test(&sformat_mask, sformat) && 897 for (sformat = (__force snd_pcm_format_t)0;
898 (__force int)sformat <= (__force int)SNDRV_PCM_FORMAT_LAST;
899 sformat = (__force snd_pcm_format_t)((__force int)sformat + 1)) {
900 if (snd_mask_test(&sformat_mask, (__force int)sformat) &&
895 snd_pcm_oss_format_to(sformat) >= 0) 901 snd_pcm_oss_format_to(sformat) >= 0)
896 break; 902 break;
897 } 903 }
898 if (sformat > SNDRV_PCM_FORMAT_LAST) { 904 if ((__force int)sformat > (__force int)SNDRV_PCM_FORMAT_LAST) {
899 snd_printd("Cannot find a format!!!\n"); 905 snd_printd("Cannot find a format!!!\n");
900 err = -EINVAL; 906 err = -EINVAL;
901 goto failure; 907 goto failure;
902 } 908 }
903 } 909 }
904 err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0); 910 err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, (__force int)sformat, 0);
905 if (err < 0) 911 if (err < 0)
906 goto failure; 912 goto failure;
907 913
@@ -910,9 +916,9 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
910 } else { 916 } else {
911 _snd_pcm_hw_params_any(params); 917 _snd_pcm_hw_params_any(params);
912 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_ACCESS, 918 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_ACCESS,
913 SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0); 919 (__force int)SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0);
914 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_FORMAT, 920 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_FORMAT,
915 snd_pcm_oss_format_from(runtime->oss.format), 0); 921 (__force int)snd_pcm_oss_format_from(runtime->oss.format), 0);
916 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_CHANNELS, 922 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_CHANNELS,
917 runtime->oss.channels, 0); 923 runtime->oss.channels, 0);
918 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_RATE, 924 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_RATE,
@@ -1183,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
1183 if (in_kernel) { 1189 if (in_kernel) {
1184 mm_segment_t fs; 1190 mm_segment_t fs;
1185 fs = snd_enter_user(); 1191 fs = snd_enter_user();
1186 ret = snd_pcm_lib_write(substream, (void __user *)ptr, frames); 1192 ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
1187 snd_leave_user(fs); 1193 snd_leave_user(fs);
1188 } else { 1194 } else {
1189 ret = snd_pcm_lib_write(substream, (void __user *)ptr, frames); 1195 ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
1190 } 1196 }
1191 if (ret != -EPIPE && ret != -ESTRPIPE) 1197 if (ret != -EPIPE && ret != -ESTRPIPE)
1192 break; 1198 break;
@@ -1228,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
1228 if (in_kernel) { 1234 if (in_kernel) {
1229 mm_segment_t fs; 1235 mm_segment_t fs;
1230 fs = snd_enter_user(); 1236 fs = snd_enter_user();
1231 ret = snd_pcm_lib_read(substream, (void __user *)ptr, frames); 1237 ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
1232 snd_leave_user(fs); 1238 snd_leave_user(fs);
1233 } else { 1239 } else {
1234 ret = snd_pcm_lib_read(substream, (void __user *)ptr, frames); 1240 ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
1235 } 1241 }
1236 if (ret == -EPIPE) { 1242 if (ret == -EPIPE) {
1237 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) { 1243 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
@@ -1331,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
1331 struct snd_pcm_plugin_channel *channels; 1337 struct snd_pcm_plugin_channel *channels;
1332 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8; 1338 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
1333 if (!in_kernel) { 1339 if (!in_kernel) {
1334 if (copy_from_user(runtime->oss.buffer, (const char __user *)buf, bytes)) 1340 if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
1335 return -EFAULT; 1341 return -EFAULT;
1336 buf = runtime->oss.buffer; 1342 buf = runtime->oss.buffer;
1337 } 1343 }
@@ -1427,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
1427 struct snd_pcm_runtime *runtime = substream->runtime; 1433 struct snd_pcm_runtime *runtime = substream->runtime;
1428 snd_pcm_sframes_t frames, frames1; 1434 snd_pcm_sframes_t frames, frames1;
1429#ifdef CONFIG_SND_PCM_OSS_PLUGINS 1435#ifdef CONFIG_SND_PCM_OSS_PLUGINS
1430 char __user *final_dst = (char __user *)buf; 1436 char __user *final_dst = (char __force __user *)buf;
1431 if (runtime->oss.plugin_first) { 1437 if (runtime->oss.plugin_first) {
1432 struct snd_pcm_plugin_channel *channels; 1438 struct snd_pcm_plugin_channel *channels;
1433 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8; 1439 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
@@ -1510,16 +1516,19 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
1510static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file) 1516static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file)
1511{ 1517{
1512 struct snd_pcm_substream *substream; 1518 struct snd_pcm_substream *substream;
1519 struct snd_pcm_runtime *runtime;
1520 int i;
1513 1521
1514 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; 1522 for (i = 0; i < 2; i++) {
1515 if (substream != NULL) { 1523 substream = pcm_oss_file->streams[i];
1516 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); 1524 if (!substream)
1517 substream->runtime->oss.prepare = 1; 1525 continue;
1518 } 1526 runtime = substream->runtime;
1519 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
1520 if (substream != NULL) {
1521 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); 1527 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
1522 substream->runtime->oss.prepare = 1; 1528 runtime->oss.prepare = 1;
1529 runtime->oss.buffer_used = 0;
1530 runtime->oss.prev_hw_ptr_period = 0;
1531 runtime->oss.period_ptr = 0;
1523 } 1532 }
1524 return 0; 1533 return 0;
1525} 1534}
@@ -1544,6 +1553,7 @@ static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size)
1544{ 1553{
1545 struct snd_pcm_runtime *runtime; 1554 struct snd_pcm_runtime *runtime;
1546 ssize_t result = 0; 1555 ssize_t result = 0;
1556 snd_pcm_state_t state;
1547 long res; 1557 long res;
1548 wait_queue_t wait; 1558 wait_queue_t wait;
1549 1559
@@ -1565,9 +1575,9 @@ static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size)
1565 result = 0; 1575 result = 0;
1566 set_current_state(TASK_INTERRUPTIBLE); 1576 set_current_state(TASK_INTERRUPTIBLE);
1567 snd_pcm_stream_lock_irq(substream); 1577 snd_pcm_stream_lock_irq(substream);
1568 res = runtime->status->state; 1578 state = runtime->status->state;
1569 snd_pcm_stream_unlock_irq(substream); 1579 snd_pcm_stream_unlock_irq(substream);
1570 if (res != SNDRV_PCM_STATE_RUNNING) { 1580 if (state != SNDRV_PCM_STATE_RUNNING) {
1571 set_current_state(TASK_RUNNING); 1581 set_current_state(TASK_RUNNING);
1572 break; 1582 break;
1573 } 1583 }
@@ -1653,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
1653 size1); 1663 size1);
1654 size1 /= runtime->channels; /* frames */ 1664 size1 /= runtime->channels; /* frames */
1655 fs = snd_enter_user(); 1665 fs = snd_enter_user();
1656 snd_pcm_lib_write(substream, (void __user *)runtime->oss.buffer, size1); 1666 snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
1657 snd_leave_user(fs); 1667 snd_leave_user(fs);
1658 } 1668 }
1659 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) { 1669 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index 6751daa3bb50..71cc3ddf5c15 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -264,7 +264,7 @@ snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pc
264 return frames; 264 return frames;
265} 265}
266 266
267static int snd_pcm_plug_formats(struct snd_mask *mask, int format) 267static int snd_pcm_plug_formats(struct snd_mask *mask, snd_pcm_format_t format)
268{ 268{
269 struct snd_mask formats = *mask; 269 struct snd_mask formats = *mask;
270 u64 linfmts = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S8 | 270 u64 linfmts = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S8 |
@@ -276,16 +276,16 @@ static int snd_pcm_plug_formats(struct snd_mask *mask, int format)
276 SNDRV_PCM_FMTBIT_U24_3BE | SNDRV_PCM_FMTBIT_S24_3BE | 276 SNDRV_PCM_FMTBIT_U24_3BE | SNDRV_PCM_FMTBIT_S24_3BE |
277 SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_S32_LE | 277 SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_S32_LE |
278 SNDRV_PCM_FMTBIT_U32_BE | SNDRV_PCM_FMTBIT_S32_BE); 278 SNDRV_PCM_FMTBIT_U32_BE | SNDRV_PCM_FMTBIT_S32_BE);
279 snd_mask_set(&formats, SNDRV_PCM_FORMAT_MU_LAW); 279 snd_mask_set(&formats, (__force int)SNDRV_PCM_FORMAT_MU_LAW);
280 280
281 if (formats.bits[0] & (u32)linfmts) 281 if (formats.bits[0] & (u32)linfmts)
282 formats.bits[0] |= (u32)linfmts; 282 formats.bits[0] |= (u32)linfmts;
283 if (formats.bits[1] & (u32)(linfmts >> 32)) 283 if (formats.bits[1] & (u32)(linfmts >> 32))
284 formats.bits[1] |= (u32)(linfmts >> 32); 284 formats.bits[1] |= (u32)(linfmts >> 32);
285 return snd_mask_test(&formats, format); 285 return snd_mask_test(&formats, (__force int)format);
286} 286}
287 287
288static int preferred_formats[] = { 288static snd_pcm_format_t preferred_formats[] = {
289 SNDRV_PCM_FORMAT_S16_LE, 289 SNDRV_PCM_FORMAT_S16_LE,
290 SNDRV_PCM_FORMAT_S16_BE, 290 SNDRV_PCM_FORMAT_S16_BE,
291 SNDRV_PCM_FORMAT_U16_LE, 291 SNDRV_PCM_FORMAT_U16_LE,
@@ -306,24 +306,25 @@ static int preferred_formats[] = {
306 SNDRV_PCM_FORMAT_U8 306 SNDRV_PCM_FORMAT_U8
307}; 307};
308 308
309int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask) 309snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format,
310 struct snd_mask *format_mask)
310{ 311{
311 int i; 312 int i;
312 313
313 if (snd_mask_test(format_mask, format)) 314 if (snd_mask_test(format_mask, (__force int)format))
314 return format; 315 return format;
315 if (! snd_pcm_plug_formats(format_mask, format)) 316 if (!snd_pcm_plug_formats(format_mask, format))
316 return -EINVAL; 317 return (__force snd_pcm_format_t)-EINVAL;
317 if (snd_pcm_format_linear(format)) { 318 if (snd_pcm_format_linear(format)) {
318 unsigned int width = snd_pcm_format_width(format); 319 unsigned int width = snd_pcm_format_width(format);
319 int unsignd = snd_pcm_format_unsigned(format) > 0; 320 int unsignd = snd_pcm_format_unsigned(format) > 0;
320 int big = snd_pcm_format_big_endian(format) > 0; 321 int big = snd_pcm_format_big_endian(format) > 0;
321 unsigned int badness, best = -1; 322 unsigned int badness, best = -1;
322 int best_format = -1; 323 snd_pcm_format_t best_format = (__force snd_pcm_format_t)-1;
323 for (i = 0; i < ARRAY_SIZE(preferred_formats); i++) { 324 for (i = 0; i < ARRAY_SIZE(preferred_formats); i++) {
324 int f = preferred_formats[i]; 325 snd_pcm_format_t f = preferred_formats[i];
325 unsigned int w; 326 unsigned int w;
326 if (!snd_mask_test(format_mask, f)) 327 if (!snd_mask_test(format_mask, (__force int)f))
327 continue; 328 continue;
328 w = snd_pcm_format_width(f); 329 w = snd_pcm_format_width(f);
329 if (w >= width) 330 if (w >= width)
@@ -337,17 +338,20 @@ int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask)
337 best = badness; 338 best = badness;
338 } 339 }
339 } 340 }
340 return best_format >= 0 ? best_format : -EINVAL; 341 if ((__force int)best_format >= 0)
342 return best_format;
343 else
344 return (__force snd_pcm_format_t)-EINVAL;
341 } else { 345 } else {
342 switch (format) { 346 switch (format) {
343 case SNDRV_PCM_FORMAT_MU_LAW: 347 case SNDRV_PCM_FORMAT_MU_LAW:
344 for (i = 0; i < ARRAY_SIZE(preferred_formats); ++i) { 348 for (i = 0; i < ARRAY_SIZE(preferred_formats); ++i) {
345 int format1 = preferred_formats[i]; 349 snd_pcm_format_t format1 = preferred_formats[i];
346 if (snd_mask_test(format_mask, format1)) 350 if (snd_mask_test(format_mask, (__force int)format1))
347 return format1; 351 return format1;
348 } 352 }
349 default: 353 default:
350 return -EINVAL; 354 return (__force snd_pcm_format_t)-EINVAL;
351 } 355 }
352 } 356 }
353} 357}
@@ -359,7 +363,7 @@ int snd_pcm_plug_format_plugins(struct snd_pcm_substream *plug,
359 struct snd_pcm_plugin_format tmpformat; 363 struct snd_pcm_plugin_format tmpformat;
360 struct snd_pcm_plugin_format dstformat; 364 struct snd_pcm_plugin_format dstformat;
361 struct snd_pcm_plugin_format srcformat; 365 struct snd_pcm_plugin_format srcformat;
362 int src_access, dst_access; 366 snd_pcm_access_t src_access, dst_access;
363 struct snd_pcm_plugin *plugin = NULL; 367 struct snd_pcm_plugin *plugin = NULL;
364 int err; 368 int err;
365 int stream = snd_pcm_plug_stream(plug); 369 int stream = snd_pcm_plug_stream(plug);
@@ -641,7 +645,7 @@ snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *plug, str
641} 645}
642 646
643int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_area, size_t dst_offset, 647int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_area, size_t dst_offset,
644 size_t samples, int format) 648 size_t samples, snd_pcm_format_t format)
645{ 649{
646 /* FIXME: sub byte resolution and odd dst_offset */ 650 /* FIXME: sub byte resolution and odd dst_offset */
647 unsigned char *dst; 651 unsigned char *dst;
@@ -688,7 +692,7 @@ int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_area, size_t dst
688 692
689int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_area, size_t src_offset, 693int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_area, size_t src_offset,
690 const struct snd_pcm_channel_area *dst_area, size_t dst_offset, 694 const struct snd_pcm_channel_area *dst_area, size_t dst_offset,
691 size_t samples, int format) 695 size_t samples, snd_pcm_format_t format)
692{ 696{
693 /* FIXME: sub byte resolution and odd dst_offset */ 697 /* FIXME: sub byte resolution and odd dst_offset */
694 char *src, *dst; 698 char *src, *dst;
diff --git a/sound/core/oss/pcm_plugin.h b/sound/core/oss/pcm_plugin.h
index b9afab603711..a5035c2369a6 100644
--- a/sound/core/oss/pcm_plugin.h
+++ b/sound/core/oss/pcm_plugin.h
@@ -46,7 +46,7 @@ struct snd_pcm_plugin_channel {
46}; 46};
47 47
48struct snd_pcm_plugin_format { 48struct snd_pcm_plugin_format {
49 int format; 49 snd_pcm_format_t format;
50 unsigned int rate; 50 unsigned int rate;
51 unsigned int channels; 51 unsigned int channels;
52}; 52};
@@ -58,7 +58,7 @@ struct snd_pcm_plugin {
58 struct snd_pcm_plugin_format dst_format; /* destination format */ 58 struct snd_pcm_plugin_format dst_format; /* destination format */
59 int src_width; /* sample width in bits */ 59 int src_width; /* sample width in bits */
60 int dst_width; /* sample width in bits */ 60 int dst_width; /* sample width in bits */
61 int access; 61 snd_pcm_access_t access;
62 snd_pcm_sframes_t (*src_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t dst_frames); 62 snd_pcm_sframes_t (*src_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t dst_frames);
63 snd_pcm_sframes_t (*dst_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t src_frames); 63 snd_pcm_sframes_t (*dst_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t src_frames);
64 snd_pcm_sframes_t (*client_channels)(struct snd_pcm_plugin *plugin, 64 snd_pcm_sframes_t (*client_channels)(struct snd_pcm_plugin *plugin,
@@ -125,7 +125,8 @@ int snd_pcm_plug_format_plugins(struct snd_pcm_substream *substream,
125 struct snd_pcm_hw_params *params, 125 struct snd_pcm_hw_params *params,
126 struct snd_pcm_hw_params *slave_params); 126 struct snd_pcm_hw_params *slave_params);
127 127
128int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask); 128snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format,
129 struct snd_mask *format_mask);
129 130
130int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin); 131int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin);
131 132
@@ -146,12 +147,12 @@ snd_pcm_sframes_t snd_pcm_plugin_client_channels(struct snd_pcm_plugin *plugin,
146 147
147int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_channel, 148int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_channel,
148 size_t dst_offset, 149 size_t dst_offset,
149 size_t samples, int format); 150 size_t samples, snd_pcm_format_t format);
150int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_channel, 151int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_channel,
151 size_t src_offset, 152 size_t src_offset,
152 const struct snd_pcm_channel_area *dst_channel, 153 const struct snd_pcm_channel_area *dst_channel,
153 size_t dst_offset, 154 size_t dst_offset,
154 size_t samples, int format); 155 size_t samples, snd_pcm_format_t format);
155 156
156void *snd_pcm_plug_buf_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t size); 157void *snd_pcm_plug_buf_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t size);
157void snd_pcm_plug_buf_unlock(struct snd_pcm_substream *plug, void *ptr); 158void snd_pcm_plug_buf_unlock(struct snd_pcm_substream *plug, void *ptr);
diff --git a/sound/core/oss/route.c b/sound/core/oss/route.c
index bbe25d8c450a..c8171f5783c8 100644
--- a/sound/core/oss/route.c
+++ b/sound/core/oss/route.c
@@ -25,7 +25,7 @@
25#include "pcm_plugin.h" 25#include "pcm_plugin.h"
26 26
27static void zero_areas(struct snd_pcm_plugin_channel *dvp, int ndsts, 27static void zero_areas(struct snd_pcm_plugin_channel *dvp, int ndsts,
28 snd_pcm_uframes_t frames, int format) 28 snd_pcm_uframes_t frames, snd_pcm_format_t format)
29{ 29{
30 int dst = 0; 30 int dst = 0;
31 for (; dst < ndsts; ++dst) { 31 for (; dst < ndsts; ++dst) {
@@ -38,7 +38,7 @@ static void zero_areas(struct snd_pcm_plugin_channel *dvp, int ndsts,
38 38
39static inline void copy_area(const struct snd_pcm_plugin_channel *src_channel, 39static inline void copy_area(const struct snd_pcm_plugin_channel *src_channel,
40 struct snd_pcm_plugin_channel *dst_channel, 40 struct snd_pcm_plugin_channel *dst_channel,
41 snd_pcm_uframes_t frames, int format) 41 snd_pcm_uframes_t frames, snd_pcm_format_t format)
42{ 42{
43 dst_channel->enabled = 1; 43 dst_channel->enabled = 1;
44 snd_pcm_area_copy(&src_channel->area, 0, &dst_channel->area, 0, frames, format); 44 snd_pcm_area_copy(&src_channel->area, 0, &dst_channel->area, 0, frames, format);
@@ -51,7 +51,7 @@ static snd_pcm_sframes_t route_transfer(struct snd_pcm_plugin *plugin,
51{ 51{
52 int nsrcs, ndsts, dst; 52 int nsrcs, ndsts, dst;
53 struct snd_pcm_plugin_channel *dvp; 53 struct snd_pcm_plugin_channel *dvp;
54 int format; 54 snd_pcm_format_t format;
55 55
56 if (snd_BUG_ON(!plugin || !src_channels || !dst_channels)) 56 if (snd_BUG_ON(!plugin || !src_channels || !dst_channels))
57 return -ENXIO; 57 return -ENXIO;
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index ac242a377aea..ee9abb2d9001 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -211,9 +211,9 @@ static char *snd_pcm_format_names[] = {
211 211
212const char *snd_pcm_format_name(snd_pcm_format_t format) 212const char *snd_pcm_format_name(snd_pcm_format_t format)
213{ 213{
214 if (format >= ARRAY_SIZE(snd_pcm_format_names)) 214 if ((__force unsigned int)format >= ARRAY_SIZE(snd_pcm_format_names))
215 return "Unknown"; 215 return "Unknown";
216 return snd_pcm_format_names[format]; 216 return snd_pcm_format_names[(__force unsigned int)format];
217} 217}
218EXPORT_SYMBOL_GPL(snd_pcm_format_name); 218EXPORT_SYMBOL_GPL(snd_pcm_format_name);
219 219
@@ -269,12 +269,12 @@ static const char *snd_pcm_stream_name(int stream)
269 269
270static const char *snd_pcm_access_name(snd_pcm_access_t access) 270static const char *snd_pcm_access_name(snd_pcm_access_t access)
271{ 271{
272 return snd_pcm_access_names[access]; 272 return snd_pcm_access_names[(__force int)access];
273} 273}
274 274
275static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat) 275static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat)
276{ 276{
277 return snd_pcm_subformat_names[subformat]; 277 return snd_pcm_subformat_names[(__force int)subformat];
278} 278}
279 279
280static const char *snd_pcm_tstamp_mode_name(int mode) 280static const char *snd_pcm_tstamp_mode_name(int mode)
@@ -284,7 +284,7 @@ static const char *snd_pcm_tstamp_mode_name(int mode)
284 284
285static const char *snd_pcm_state_name(snd_pcm_state_t state) 285static const char *snd_pcm_state_name(snd_pcm_state_t state)
286{ 286{
287 return snd_pcm_state_names[state]; 287 return snd_pcm_state_names[(__force int)state];
288} 288}
289 289
290#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) 290#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
@@ -364,8 +364,7 @@ static void snd_pcm_stream_proc_info_read(struct snd_info_entry *entry,
364static void snd_pcm_substream_proc_info_read(struct snd_info_entry *entry, 364static void snd_pcm_substream_proc_info_read(struct snd_info_entry *entry,
365 struct snd_info_buffer *buffer) 365 struct snd_info_buffer *buffer)
366{ 366{
367 snd_pcm_proc_info_read((struct snd_pcm_substream *)entry->private_data, 367 snd_pcm_proc_info_read(entry->private_data, buffer);
368 buffer);
369} 368}
370 369
371static void snd_pcm_substream_proc_hw_params_read(struct snd_info_entry *entry, 370static void snd_pcm_substream_proc_hw_params_read(struct snd_info_entry *entry,
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index e23e0e7ab26f..f1341308beda 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -189,6 +189,7 @@ static void xrun(struct snd_pcm_substream *substream)
189#define XRUN_LOG_CNT 10 189#define XRUN_LOG_CNT 10
190 190
191struct hwptr_log_entry { 191struct hwptr_log_entry {
192 unsigned int in_interrupt;
192 unsigned long jiffies; 193 unsigned long jiffies;
193 snd_pcm_uframes_t pos; 194 snd_pcm_uframes_t pos;
194 snd_pcm_uframes_t period_size; 195 snd_pcm_uframes_t period_size;
@@ -204,7 +205,7 @@ struct snd_pcm_hwptr_log {
204}; 205};
205 206
206static void xrun_log(struct snd_pcm_substream *substream, 207static void xrun_log(struct snd_pcm_substream *substream,
207 snd_pcm_uframes_t pos) 208 snd_pcm_uframes_t pos, int in_interrupt)
208{ 209{
209 struct snd_pcm_runtime *runtime = substream->runtime; 210 struct snd_pcm_runtime *runtime = substream->runtime;
210 struct snd_pcm_hwptr_log *log = runtime->hwptr_log; 211 struct snd_pcm_hwptr_log *log = runtime->hwptr_log;
@@ -220,10 +221,11 @@ static void xrun_log(struct snd_pcm_substream *substream,
220 return; 221 return;
221 } 222 }
222 entry = &log->entries[log->idx]; 223 entry = &log->entries[log->idx];
224 entry->in_interrupt = in_interrupt;
223 entry->jiffies = jiffies; 225 entry->jiffies = jiffies;
224 entry->pos = pos; 226 entry->pos = pos;
225 entry->period_size = runtime->period_size; 227 entry->period_size = runtime->period_size;
226 entry->buffer_size = runtime->buffer_size;; 228 entry->buffer_size = runtime->buffer_size;
227 entry->old_hw_ptr = runtime->status->hw_ptr; 229 entry->old_hw_ptr = runtime->status->hw_ptr;
228 entry->hw_ptr_base = runtime->hw_ptr_base; 230 entry->hw_ptr_base = runtime->hw_ptr_base;
229 log->idx = (log->idx + 1) % XRUN_LOG_CNT; 231 log->idx = (log->idx + 1) % XRUN_LOG_CNT;
@@ -246,9 +248,11 @@ static void xrun_log_show(struct snd_pcm_substream *substream)
246 entry = &log->entries[idx]; 248 entry = &log->entries[idx];
247 if (entry->period_size == 0) 249 if (entry->period_size == 0)
248 break; 250 break;
249 snd_printd("hwptr log: %s: j=%lu, pos=%ld/%ld/%ld, " 251 snd_printd("hwptr log: %s: %sj=%lu, pos=%ld/%ld/%ld, "
250 "hwptr=%ld/%ld\n", 252 "hwptr=%ld/%ld\n",
251 name, entry->jiffies, (unsigned long)entry->pos, 253 name, entry->in_interrupt ? "[Q] " : "",
254 entry->jiffies,
255 (unsigned long)entry->pos,
252 (unsigned long)entry->period_size, 256 (unsigned long)entry->period_size,
253 (unsigned long)entry->buffer_size, 257 (unsigned long)entry->buffer_size,
254 (unsigned long)entry->old_hw_ptr, 258 (unsigned long)entry->old_hw_ptr,
@@ -262,7 +266,7 @@ static void xrun_log_show(struct snd_pcm_substream *substream)
262#else /* ! CONFIG_SND_PCM_XRUN_DEBUG */ 266#else /* ! CONFIG_SND_PCM_XRUN_DEBUG */
263 267
264#define hw_ptr_error(substream, fmt, args...) do { } while (0) 268#define hw_ptr_error(substream, fmt, args...) do { } while (0)
265#define xrun_log(substream, pos) do { } while (0) 269#define xrun_log(substream, pos, in_interrupt) do { } while (0)
266#define xrun_log_show(substream) do { } while (0) 270#define xrun_log_show(substream) do { } while (0)
267 271
268#endif 272#endif
@@ -326,7 +330,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
326 } 330 }
327 pos -= pos % runtime->min_align; 331 pos -= pos % runtime->min_align;
328 if (xrun_debug(substream, XRUN_DEBUG_LOG)) 332 if (xrun_debug(substream, XRUN_DEBUG_LOG))
329 xrun_log(substream, pos); 333 xrun_log(substream, pos, in_interrupt);
330 hw_base = runtime->hw_ptr_base; 334 hw_base = runtime->hw_ptr_base;
331 new_hw_ptr = hw_base + pos; 335 new_hw_ptr = hw_base + pos;
332 if (in_interrupt) { 336 if (in_interrupt) {
@@ -334,11 +338,15 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
334 /* delta = "expected next hw_ptr" for in_interrupt != 0 */ 338 /* delta = "expected next hw_ptr" for in_interrupt != 0 */
335 delta = runtime->hw_ptr_interrupt + runtime->period_size; 339 delta = runtime->hw_ptr_interrupt + runtime->period_size;
336 if (delta > new_hw_ptr) { 340 if (delta > new_hw_ptr) {
337 hw_base += runtime->buffer_size; 341 /* check for double acknowledged interrupts */
338 if (hw_base >= runtime->boundary) 342 hdelta = jiffies - runtime->hw_ptr_jiffies;
339 hw_base = 0; 343 if (hdelta > runtime->hw_ptr_buffer_jiffies/2) {
340 new_hw_ptr = hw_base + pos; 344 hw_base += runtime->buffer_size;
341 goto __delta; 345 if (hw_base >= runtime->boundary)
346 hw_base = 0;
347 new_hw_ptr = hw_base + pos;
348 goto __delta;
349 }
342 } 350 }
343 } 351 }
344 /* new_hw_ptr might be lower than old_hw_ptr in case when */ 352 /* new_hw_ptr might be lower than old_hw_ptr in case when */
@@ -369,6 +377,29 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
369 (unsigned long)new_hw_ptr, 377 (unsigned long)new_hw_ptr,
370 (unsigned long)runtime->hw_ptr_base); 378 (unsigned long)runtime->hw_ptr_base);
371 } 379 }
380
381 if (runtime->no_period_wakeup) {
382 snd_pcm_sframes_t xrun_threshold;
383 /*
384 * Without regular period interrupts, we have to check
385 * the elapsed time to detect xruns.
386 */
387 jdelta = jiffies - runtime->hw_ptr_jiffies;
388 if (jdelta < runtime->hw_ptr_buffer_jiffies / 2)
389 goto no_delta_check;
390 hdelta = jdelta - delta * HZ / runtime->rate;
391 xrun_threshold = runtime->hw_ptr_buffer_jiffies / 2 + 1;
392 while (hdelta > xrun_threshold) {
393 delta += runtime->buffer_size;
394 hw_base += runtime->buffer_size;
395 if (hw_base >= runtime->boundary)
396 hw_base = 0;
397 new_hw_ptr = hw_base + pos;
398 hdelta -= runtime->hw_ptr_buffer_jiffies;
399 }
400 goto no_delta_check;
401 }
402
372 /* something must be really wrong */ 403 /* something must be really wrong */
373 if (delta >= runtime->buffer_size + runtime->period_size) { 404 if (delta >= runtime->buffer_size + runtime->period_size) {
374 hw_ptr_error(substream, 405 hw_ptr_error(substream,
@@ -438,6 +469,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
438 (long)old_hw_ptr); 469 (long)old_hw_ptr);
439 } 470 }
440 471
472 no_delta_check:
441 if (runtime->status->hw_ptr == new_hw_ptr) 473 if (runtime->status->hw_ptr == new_hw_ptr)
442 return 0; 474 return 0;
443 475
@@ -1066,8 +1098,10 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond,
1066 struct snd_pcm_hw_rule *new; 1098 struct snd_pcm_hw_rule *new;
1067 unsigned int new_rules = constrs->rules_all + 16; 1099 unsigned int new_rules = constrs->rules_all + 16;
1068 new = kcalloc(new_rules, sizeof(*c), GFP_KERNEL); 1100 new = kcalloc(new_rules, sizeof(*c), GFP_KERNEL);
1069 if (!new) 1101 if (!new) {
1102 va_end(args);
1070 return -ENOMEM; 1103 return -ENOMEM;
1104 }
1071 if (constrs->rules) { 1105 if (constrs->rules) {
1072 memcpy(new, constrs->rules, 1106 memcpy(new, constrs->rules,
1073 constrs->rules_num * sizeof(*c)); 1107 constrs->rules_num * sizeof(*c));
@@ -1083,8 +1117,10 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond,
1083 c->private = private; 1117 c->private = private;
1084 k = 0; 1118 k = 0;
1085 while (1) { 1119 while (1) {
1086 if (snd_BUG_ON(k >= ARRAY_SIZE(c->deps))) 1120 if (snd_BUG_ON(k >= ARRAY_SIZE(c->deps))) {
1121 va_end(args);
1087 return -EINVAL; 1122 return -EINVAL;
1123 }
1088 c->deps[k++] = dep; 1124 c->deps[k++] = dep;
1089 if (dep < 0) 1125 if (dep < 0)
1090 break; 1126 break;
@@ -1093,7 +1129,7 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond,
1093 constrs->rules_num++; 1129 constrs->rules_num++;
1094 va_end(args); 1130 va_end(args);
1095 return 0; 1131 return 0;
1096} 1132}
1097 1133
1098EXPORT_SYMBOL(snd_pcm_hw_rule_add); 1134EXPORT_SYMBOL(snd_pcm_hw_rule_add);
1099 1135
@@ -1720,8 +1756,18 @@ static int wait_for_avail(struct snd_pcm_substream *substream,
1720 wait_queue_t wait; 1756 wait_queue_t wait;
1721 int err = 0; 1757 int err = 0;
1722 snd_pcm_uframes_t avail = 0; 1758 snd_pcm_uframes_t avail = 0;
1723 long tout; 1759 long wait_time, tout;
1724 1760
1761 if (runtime->no_period_wakeup)
1762 wait_time = MAX_SCHEDULE_TIMEOUT;
1763 else {
1764 wait_time = 10;
1765 if (runtime->rate) {
1766 long t = runtime->period_size * 2 / runtime->rate;
1767 wait_time = max(t, wait_time);
1768 }
1769 wait_time = msecs_to_jiffies(wait_time * 1000);
1770 }
1725 init_waitqueue_entry(&wait, current); 1771 init_waitqueue_entry(&wait, current);
1726 add_wait_queue(&runtime->tsleep, &wait); 1772 add_wait_queue(&runtime->tsleep, &wait);
1727 for (;;) { 1773 for (;;) {
@@ -1729,9 +1775,8 @@ static int wait_for_avail(struct snd_pcm_substream *substream,
1729 err = -ERESTARTSYS; 1775 err = -ERESTARTSYS;
1730 break; 1776 break;
1731 } 1777 }
1732 set_current_state(TASK_INTERRUPTIBLE);
1733 snd_pcm_stream_unlock_irq(substream); 1778 snd_pcm_stream_unlock_irq(substream);
1734 tout = schedule_timeout(msecs_to_jiffies(10000)); 1779 tout = schedule_timeout_interruptible(wait_time);
1735 snd_pcm_stream_lock_irq(substream); 1780 snd_pcm_stream_lock_irq(substream);
1736 switch (runtime->status->state) { 1781 switch (runtime->status->state) {
1737 case SNDRV_PCM_STATE_SUSPENDED: 1782 case SNDRV_PCM_STATE_SUSPENDED:
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c
index 917e4055ee30..150cb7edffee 100644
--- a/sound/core/pcm_memory.c
+++ b/sound/core/pcm_memory.c
@@ -253,7 +253,7 @@ static int snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream,
253 * snd_pcm_lib_preallocate_pages - pre-allocation for the given DMA type 253 * snd_pcm_lib_preallocate_pages - pre-allocation for the given DMA type
254 * @substream: the pcm substream instance 254 * @substream: the pcm substream instance
255 * @type: DMA type (SNDRV_DMA_TYPE_*) 255 * @type: DMA type (SNDRV_DMA_TYPE_*)
256 * @data: DMA type dependant data 256 * @data: DMA type dependent data
257 * @size: the requested pre-allocation size in bytes 257 * @size: the requested pre-allocation size in bytes
258 * @max: the max. allowed pre-allocation size 258 * @max: the max. allowed pre-allocation size
259 * 259 *
@@ -278,10 +278,10 @@ int snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
278EXPORT_SYMBOL(snd_pcm_lib_preallocate_pages); 278EXPORT_SYMBOL(snd_pcm_lib_preallocate_pages);
279 279
280/** 280/**
281 * snd_pcm_lib_preallocate_pages_for_all - pre-allocation for continous memory type (all substreams) 281 * snd_pcm_lib_preallocate_pages_for_all - pre-allocation for continuous memory type (all substreams)
282 * @pcm: the pcm instance 282 * @pcm: the pcm instance
283 * @type: DMA type (SNDRV_DMA_TYPE_*) 283 * @type: DMA type (SNDRV_DMA_TYPE_*)
284 * @data: DMA type dependant data 284 * @data: DMA type dependent data
285 * @size: the requested pre-allocation size in bytes 285 * @size: the requested pre-allocation size in bytes
286 * @max: the max. allowed pre-allocation size 286 * @max: the max. allowed pre-allocation size
287 * 287 *
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c
index 434af3c56d52..88f02e3866e0 100644
--- a/sound/core/pcm_misc.c
+++ b/sound/core/pcm_misc.c
@@ -35,7 +35,10 @@ struct pcm_format_data {
35 unsigned char silence[8]; /* silence data to fill */ 35 unsigned char silence[8]; /* silence data to fill */
36}; 36};
37 37
38static struct pcm_format_data pcm_formats[SNDRV_PCM_FORMAT_LAST+1] = { 38/* we do lots of calculations on snd_pcm_format_t; shut up sparse */
39#define INT __force int
40
41static struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = {
39 [SNDRV_PCM_FORMAT_S8] = { 42 [SNDRV_PCM_FORMAT_S8] = {
40 .width = 8, .phys = 8, .le = -1, .signd = 1, 43 .width = 8, .phys = 8, .le = -1, .signd = 1,
41 .silence = {}, 44 .silence = {},
@@ -215,9 +218,9 @@ static struct pcm_format_data pcm_formats[SNDRV_PCM_FORMAT_LAST+1] = {
215int snd_pcm_format_signed(snd_pcm_format_t format) 218int snd_pcm_format_signed(snd_pcm_format_t format)
216{ 219{
217 int val; 220 int val;
218 if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) 221 if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
219 return -EINVAL; 222 return -EINVAL;
220 if ((val = pcm_formats[format].signd) < 0) 223 if ((val = pcm_formats[(INT)format].signd) < 0)
221 return -EINVAL; 224 return -EINVAL;
222 return val; 225 return val;
223} 226}
@@ -266,9 +269,9 @@ EXPORT_SYMBOL(snd_pcm_format_linear);
266int snd_pcm_format_little_endian(snd_pcm_format_t format) 269int snd_pcm_format_little_endian(snd_pcm_format_t format)
267{ 270{
268 int val; 271 int val;
269 if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) 272 if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
270 return -EINVAL; 273 return -EINVAL;
271 if ((val = pcm_formats[format].le) < 0) 274 if ((val = pcm_formats[(INT)format].le) < 0)
272 return -EINVAL; 275 return -EINVAL;
273 return val; 276 return val;
274} 277}
@@ -304,9 +307,9 @@ EXPORT_SYMBOL(snd_pcm_format_big_endian);
304int snd_pcm_format_width(snd_pcm_format_t format) 307int snd_pcm_format_width(snd_pcm_format_t format)
305{ 308{
306 int val; 309 int val;
307 if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) 310 if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
308 return -EINVAL; 311 return -EINVAL;
309 if ((val = pcm_formats[format].width) == 0) 312 if ((val = pcm_formats[(INT)format].width) == 0)
310 return -EINVAL; 313 return -EINVAL;
311 return val; 314 return val;
312} 315}
@@ -323,9 +326,9 @@ EXPORT_SYMBOL(snd_pcm_format_width);
323int snd_pcm_format_physical_width(snd_pcm_format_t format) 326int snd_pcm_format_physical_width(snd_pcm_format_t format)
324{ 327{
325 int val; 328 int val;
326 if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) 329 if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
327 return -EINVAL; 330 return -EINVAL;
328 if ((val = pcm_formats[format].phys) == 0) 331 if ((val = pcm_formats[(INT)format].phys) == 0)
329 return -EINVAL; 332 return -EINVAL;
330 return val; 333 return val;
331} 334}
@@ -358,11 +361,11 @@ EXPORT_SYMBOL(snd_pcm_format_size);
358 */ 361 */
359const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format) 362const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format)
360{ 363{
361 if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) 364 if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
362 return NULL; 365 return NULL;
363 if (! pcm_formats[format].phys) 366 if (! pcm_formats[(INT)format].phys)
364 return NULL; 367 return NULL;
365 return pcm_formats[format].silence; 368 return pcm_formats[(INT)format].silence;
366} 369}
367 370
368EXPORT_SYMBOL(snd_pcm_format_silence_64); 371EXPORT_SYMBOL(snd_pcm_format_silence_64);
@@ -382,16 +385,16 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int
382 int width; 385 int width;
383 unsigned char *dst, *pat; 386 unsigned char *dst, *pat;
384 387
385 if (format < 0 || format > SNDRV_PCM_FORMAT_LAST) 388 if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
386 return -EINVAL; 389 return -EINVAL;
387 if (samples == 0) 390 if (samples == 0)
388 return 0; 391 return 0;
389 width = pcm_formats[format].phys; /* physical width */ 392 width = pcm_formats[(INT)format].phys; /* physical width */
390 pat = pcm_formats[format].silence; 393 pat = pcm_formats[(INT)format].silence;
391 if (! width) 394 if (! width)
392 return -EINVAL; 395 return -EINVAL;
393 /* signed or 1 byte data */ 396 /* signed or 1 byte data */
394 if (pcm_formats[format].signd == 1 || width <= 8) { 397 if (pcm_formats[(INT)format].signd == 1 || width <= 8) {
395 unsigned int bytes = samples * width / 8; 398 unsigned int bytes = samples * width / 8;
396 memset(data, *pat, bytes); 399 memset(data, *pat, bytes);
397 return 0; 400 return 0;
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index d4eb2ef80784..1c6be91dfb98 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -22,7 +22,6 @@
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/file.h> 23#include <linux/file.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/smp_lock.h>
26#include <linux/time.h> 25#include <linux/time.h>
27#include <linux/pm_qos_params.h> 26#include <linux/pm_qos_params.h>
28#include <linux/uio.h> 27#include <linux/uio.h>
@@ -142,7 +141,7 @@ int snd_pcm_info_user(struct snd_pcm_substream *substream,
142 141
143#ifdef RULES_DEBUG 142#ifdef RULES_DEBUG
144#define HW_PARAM(v) [SNDRV_PCM_HW_PARAM_##v] = #v 143#define HW_PARAM(v) [SNDRV_PCM_HW_PARAM_##v] = #v
145char *snd_pcm_hw_param_names[] = { 144static const char * const snd_pcm_hw_param_names[] = {
146 HW_PARAM(ACCESS), 145 HW_PARAM(ACCESS),
147 HW_PARAM(FORMAT), 146 HW_PARAM(FORMAT),
148 HW_PARAM(SUBFORMAT), 147 HW_PARAM(SUBFORMAT),
@@ -423,6 +422,9 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
423 runtime->info = params->info; 422 runtime->info = params->info;
424 runtime->rate_num = params->rate_num; 423 runtime->rate_num = params->rate_num;
425 runtime->rate_den = params->rate_den; 424 runtime->rate_den = params->rate_den;
425 runtime->no_period_wakeup =
426 (params->info & SNDRV_PCM_INFO_NO_PERIOD_WAKEUP) &&
427 (params->flags & SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP);
426 428
427 bits = snd_pcm_format_physical_width(runtime->format); 429 bits = snd_pcm_format_physical_width(runtime->format);
428 runtime->sample_bits = bits; 430 runtime->sample_bits = bits;
@@ -458,7 +460,7 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
458 PM_QOS_CPU_DMA_LATENCY, usecs); 460 PM_QOS_CPU_DMA_LATENCY, usecs);
459 return 0; 461 return 0;
460 _error: 462 _error:
461 /* hardware might be unuseable from this time, 463 /* hardware might be unusable from this time,
462 so we force application to retry to set 464 so we force application to retry to set
463 the correct hardware parameter settings */ 465 the correct hardware parameter settings */
464 runtime->status->state = SNDRV_PCM_STATE_OPEN; 466 runtime->status->state = SNDRV_PCM_STATE_OPEN;
@@ -864,6 +866,8 @@ static void snd_pcm_post_start(struct snd_pcm_substream *substream, int state)
864 struct snd_pcm_runtime *runtime = substream->runtime; 866 struct snd_pcm_runtime *runtime = substream->runtime;
865 snd_pcm_trigger_tstamp(substream); 867 snd_pcm_trigger_tstamp(substream);
866 runtime->hw_ptr_jiffies = jiffies; 868 runtime->hw_ptr_jiffies = jiffies;
869 runtime->hw_ptr_buffer_jiffies = (runtime->buffer_size * HZ) /
870 runtime->rate;
867 runtime->status->state = state; 871 runtime->status->state = state;
868 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && 872 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
869 runtime->silence_size > 0) 873 runtime->silence_size > 0)
@@ -937,7 +941,7 @@ static struct action_ops snd_pcm_action_stop = {
937 * 941 *
938 * The state of each stream is then changed to the given state unconditionally. 942 * The state of each stream is then changed to the given state unconditionally.
939 */ 943 */
940int snd_pcm_stop(struct snd_pcm_substream *substream, int state) 944int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state)
941{ 945{
942 return snd_pcm_action(&snd_pcm_action_stop, substream, state); 946 return snd_pcm_action(&snd_pcm_action_stop, substream, state);
943} 947}
@@ -983,7 +987,7 @@ static int snd_pcm_do_pause(struct snd_pcm_substream *substream, int push)
983 if (push) 987 if (push)
984 snd_pcm_update_hw_ptr(substream); 988 snd_pcm_update_hw_ptr(substream);
985 /* The jiffies check in snd_pcm_update_hw_ptr*() is done by 989 /* The jiffies check in snd_pcm_update_hw_ptr*() is done by
986 * a delta betwen the current jiffies, this gives a large enough 990 * a delta between the current jiffies, this gives a large enough
987 * delta, effectively to skip the check once. 991 * delta, effectively to skip the check once.
988 */ 992 */
989 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; 993 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000;
@@ -1477,11 +1481,20 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
1477 break; /* all drained */ 1481 break; /* all drained */
1478 init_waitqueue_entry(&wait, current); 1482 init_waitqueue_entry(&wait, current);
1479 add_wait_queue(&to_check->sleep, &wait); 1483 add_wait_queue(&to_check->sleep, &wait);
1480 set_current_state(TASK_INTERRUPTIBLE);
1481 snd_pcm_stream_unlock_irq(substream); 1484 snd_pcm_stream_unlock_irq(substream);
1482 up_read(&snd_pcm_link_rwsem); 1485 up_read(&snd_pcm_link_rwsem);
1483 snd_power_unlock(card); 1486 snd_power_unlock(card);
1484 tout = schedule_timeout(10 * HZ); 1487 if (runtime->no_period_wakeup)
1488 tout = MAX_SCHEDULE_TIMEOUT;
1489 else {
1490 tout = 10;
1491 if (runtime->rate) {
1492 long t = runtime->period_size * 2 / runtime->rate;
1493 tout = max(t, tout);
1494 }
1495 tout = msecs_to_jiffies(tout * 1000);
1496 }
1497 tout = schedule_timeout_interruptible(tout);
1485 snd_power_lock(card); 1498 snd_power_lock(card);
1486 down_read(&snd_pcm_link_rwsem); 1499 down_read(&snd_pcm_link_rwsem);
1487 snd_pcm_stream_lock_irq(substream); 1500 snd_pcm_stream_lock_irq(substream);
@@ -1514,13 +1527,11 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
1514static int snd_pcm_drop(struct snd_pcm_substream *substream) 1527static int snd_pcm_drop(struct snd_pcm_substream *substream)
1515{ 1528{
1516 struct snd_pcm_runtime *runtime; 1529 struct snd_pcm_runtime *runtime;
1517 struct snd_card *card;
1518 int result = 0; 1530 int result = 0;
1519 1531
1520 if (PCM_RUNTIME_CHECK(substream)) 1532 if (PCM_RUNTIME_CHECK(substream))
1521 return -ENXIO; 1533 return -ENXIO;
1522 runtime = substream->runtime; 1534 runtime = substream->runtime;
1523 card = substream->pcm->card;
1524 1535
1525 if (runtime->status->state == SNDRV_PCM_STATE_OPEN || 1536 if (runtime->status->state == SNDRV_PCM_STATE_OPEN ||
1526 runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED || 1537 runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED ||
@@ -2052,7 +2063,6 @@ static int snd_pcm_open_file(struct file *file,
2052{ 2063{
2053 struct snd_pcm_file *pcm_file; 2064 struct snd_pcm_file *pcm_file;
2054 struct snd_pcm_substream *substream; 2065 struct snd_pcm_substream *substream;
2055 struct snd_pcm_str *str;
2056 int err; 2066 int err;
2057 2067
2058 if (rpcm_file) 2068 if (rpcm_file)
@@ -2069,7 +2079,6 @@ static int snd_pcm_open_file(struct file *file,
2069 } 2079 }
2070 pcm_file->substream = substream; 2080 pcm_file->substream = substream;
2071 if (substream->ref_count == 1) { 2081 if (substream->ref_count == 1) {
2072 str = substream->pstr;
2073 substream->file = pcm_file; 2082 substream->file = pcm_file;
2074 substream->pcm_release = pcm_release_private; 2083 substream->pcm_release = pcm_release_private;
2075 } 2084 }
@@ -3011,11 +3020,9 @@ static const struct vm_operations_struct snd_pcm_vm_ops_status =
3011static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, 3020static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file,
3012 struct vm_area_struct *area) 3021 struct vm_area_struct *area)
3013{ 3022{
3014 struct snd_pcm_runtime *runtime;
3015 long size; 3023 long size;
3016 if (!(area->vm_flags & VM_READ)) 3024 if (!(area->vm_flags & VM_READ))
3017 return -EINVAL; 3025 return -EINVAL;
3018 runtime = substream->runtime;
3019 size = area->vm_end - area->vm_start; 3026 size = area->vm_end - area->vm_start;
3020 if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status))) 3027 if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status)))
3021 return -EINVAL; 3028 return -EINVAL;
@@ -3050,11 +3057,9 @@ static const struct vm_operations_struct snd_pcm_vm_ops_control =
3050static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, 3057static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file,
3051 struct vm_area_struct *area) 3058 struct vm_area_struct *area)
3052{ 3059{
3053 struct snd_pcm_runtime *runtime;
3054 long size; 3060 long size;
3055 if (!(area->vm_flags & VM_READ)) 3061 if (!(area->vm_flags & VM_READ))
3056 return -EINVAL; 3062 return -EINVAL;
3057 runtime = substream->runtime;
3058 size = area->vm_end - area->vm_start; 3063 size = area->vm_end - area->vm_start;
3059 if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))) 3064 if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control)))
3060 return -EINVAL; 3065 return -EINVAL;
@@ -3197,15 +3202,6 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream,
3197EXPORT_SYMBOL(snd_pcm_lib_mmap_iomem); 3202EXPORT_SYMBOL(snd_pcm_lib_mmap_iomem);
3198#endif /* SNDRV_PCM_INFO_MMAP */ 3203#endif /* SNDRV_PCM_INFO_MMAP */
3199 3204
3200/* mmap callback with pgprot_noncached */
3201int snd_pcm_lib_mmap_noncached(struct snd_pcm_substream *substream,
3202 struct vm_area_struct *area)
3203{
3204 area->vm_page_prot = pgprot_noncached(area->vm_page_prot);
3205 return snd_pcm_default_mmap(substream, area);
3206}
3207EXPORT_SYMBOL(snd_pcm_lib_mmap_noncached);
3208
3209/* 3205/*
3210 * mmap DMA buffer 3206 * mmap DMA buffer
3211 */ 3207 */
diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
index f25e3cc7ddfa..a1f1a2f00ccb 100644
--- a/sound/core/seq/oss/seq_oss.c
+++ b/sound/core/seq/oss/seq_oss.c
@@ -220,6 +220,7 @@ static const struct file_operations seq_oss_f_ops =
220 .poll = odev_poll, 220 .poll = odev_poll,
221 .unlocked_ioctl = odev_ioctl, 221 .unlocked_ioctl = odev_ioctl,
222 .compat_ioctl = odev_ioctl_compat, 222 .compat_ioctl = odev_ioctl_compat,
223 .llseek = noop_llseek,
223}; 224};
224 225
225static int __init 226static int __init
diff --git a/sound/core/seq/seq.c b/sound/core/seq/seq.c
index bf09a5ad1865..119fddb6fc99 100644
--- a/sound/core/seq/seq.c
+++ b/sound/core/seq/seq.c
@@ -32,6 +32,7 @@
32#include "seq_timer.h" 32#include "seq_timer.h"
33#include "seq_system.h" 33#include "seq_system.h"
34#include "seq_info.h" 34#include "seq_info.h"
35#include <sound/minors.h>
35#include <sound/seq_device.h> 36#include <sound/seq_device.h>
36 37
37#if defined(CONFIG_SND_SEQ_DUMMY_MODULE) 38#if defined(CONFIG_SND_SEQ_DUMMY_MODULE)
@@ -73,6 +74,9 @@ MODULE_PARM_DESC(seq_default_timer_subdevice, "The default timer subdevice numbe
73module_param(seq_default_timer_resolution, int, 0644); 74module_param(seq_default_timer_resolution, int, 0644);
74MODULE_PARM_DESC(seq_default_timer_resolution, "The default timer resolution in Hz."); 75MODULE_PARM_DESC(seq_default_timer_resolution, "The default timer resolution in Hz.");
75 76
77MODULE_ALIAS_CHARDEV(CONFIG_SND_MAJOR, SNDRV_MINOR_SEQUENCER);
78MODULE_ALIAS("devname:snd/seq");
79
76/* 80/*
77 * INIT PART 81 * INIT PART
78 */ 82 */
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 99a485f13648..f2436d33fbf7 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -1052,7 +1052,7 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf,
1052 } else { 1052 } else {
1053#ifdef CONFIG_COMPAT 1053#ifdef CONFIG_COMPAT
1054 if (client->convert32 && snd_seq_ev_is_varusr(&event)) { 1054 if (client->convert32 && snd_seq_ev_is_varusr(&event)) {
1055 void *ptr = compat_ptr(event.data.raw32.d[1]); 1055 void *ptr = (void __force *)compat_ptr(event.data.raw32.d[1]);
1056 event.data.ext.ptr = ptr; 1056 event.data.ext.ptr = ptr;
1057 } 1057 }
1058#endif 1058#endif
@@ -2407,7 +2407,7 @@ int snd_seq_kernel_client_ctl(int clientid, unsigned int cmd, void *arg)
2407 if (client == NULL) 2407 if (client == NULL)
2408 return -ENXIO; 2408 return -ENXIO;
2409 fs = snd_enter_user(); 2409 fs = snd_enter_user();
2410 result = snd_seq_do_ioctl(client, cmd, (void __user *)arg); 2410 result = snd_seq_do_ioctl(client, cmd, (void __force __user *)arg);
2411 snd_leave_user(fs); 2411 snd_leave_user(fs);
2412 return result; 2412 return result;
2413} 2413}
@@ -2497,9 +2497,6 @@ static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer,
2497} 2497}
2498 2498
2499 2499
2500void snd_seq_info_pool(struct snd_info_buffer *buffer,
2501 struct snd_seq_pool *pool, char *space);
2502
2503/* exported to seq_info.c */ 2500/* exported to seq_info.c */
2504void snd_seq_info_clients_read(struct snd_info_entry *entry, 2501void snd_seq_info_clients_read(struct snd_info_entry *entry,
2505 struct snd_info_buffer *buffer) 2502 struct snd_info_buffer *buffer)
diff --git a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c
index f3bdc54b429a..1d7d90ca455e 100644
--- a/sound/core/seq/seq_dummy.c
+++ b/sound/core/seq/seq_dummy.c
@@ -50,7 +50,7 @@
50 50
51 option snd-seq-dummy ports=4 51 option snd-seq-dummy ports=4
52 52
53 The modle option "duplex=1" enables duplex operation to the port. 53 The model option "duplex=1" enables duplex operation to the port.
54 In duplex mode, a pair of ports are created instead of single port, 54 In duplex mode, a pair of ports are created instead of single port,
55 and events are tunneled between pair-ports. For example, input to 55 and events are tunneled between pair-ports. For example, input to
56 port A is sent to output port of another port B and vice versa. 56 port A is sent to output port of another port B and vice versa.
diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c
index 7fb55436287f..7f50c1437675 100644
--- a/sound/core/seq/seq_memory.c
+++ b/sound/core/seq/seq_memory.c
@@ -86,7 +86,7 @@ int snd_seq_dump_var_event(const struct snd_seq_event *event,
86 86
87 if (event->data.ext.len & SNDRV_SEQ_EXT_USRPTR) { 87 if (event->data.ext.len & SNDRV_SEQ_EXT_USRPTR) {
88 char buf[32]; 88 char buf[32];
89 char __user *curptr = (char __user *)event->data.ext.ptr; 89 char __user *curptr = (char __force __user *)event->data.ext.ptr;
90 while (len > 0) { 90 while (len > 0) {
91 int size = sizeof(buf); 91 int size = sizeof(buf);
92 if (len < size) 92 if (len < size)
@@ -157,7 +157,7 @@ int snd_seq_expand_var_event(const struct snd_seq_event *event, int count, char
157 if (event->data.ext.len & SNDRV_SEQ_EXT_USRPTR) { 157 if (event->data.ext.len & SNDRV_SEQ_EXT_USRPTR) {
158 if (! in_kernel) 158 if (! in_kernel)
159 return -EINVAL; 159 return -EINVAL;
160 if (copy_from_user(buf, (void __user *)event->data.ext.ptr, len)) 160 if (copy_from_user(buf, (void __force __user *)event->data.ext.ptr, len))
161 return -EFAULT; 161 return -EFAULT;
162 return newlen; 162 return newlen;
163 } 163 }
@@ -343,7 +343,7 @@ int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event,
343 tmp->event = src->event; 343 tmp->event = src->event;
344 src = src->next; 344 src = src->next;
345 } else if (is_usrptr) { 345 } else if (is_usrptr) {
346 if (copy_from_user(&tmp->event, (char __user *)buf, size)) { 346 if (copy_from_user(&tmp->event, (char __force __user *)buf, size)) {
347 err = -EFAULT; 347 err = -EFAULT;
348 goto __error; 348 goto __error;
349 } 349 }
diff --git a/sound/core/seq/seq_memory.h b/sound/core/seq/seq_memory.h
index 63e91431a29f..4a2ec779b8a7 100644
--- a/sound/core/seq/seq_memory.h
+++ b/sound/core/seq/seq_memory.h
@@ -24,6 +24,8 @@
24#include <sound/seq_kernel.h> 24#include <sound/seq_kernel.h>
25#include <linux/poll.h> 25#include <linux/poll.h>
26 26
27struct snd_info_buffer;
28
27/* container for sequencer event (internal use) */ 29/* container for sequencer event (internal use) */
28struct snd_seq_event_cell { 30struct snd_seq_event_cell {
29 struct snd_seq_event event; 31 struct snd_seq_event event;
@@ -99,5 +101,7 @@ void snd_sequencer_memory_done(void);
99/* polling */ 101/* polling */
100int snd_seq_pool_poll_wait(struct snd_seq_pool *pool, struct file *file, poll_table *wait); 102int snd_seq_pool_poll_wait(struct snd_seq_pool *pool, struct file *file, poll_table *wait);
101 103
104void snd_seq_info_pool(struct snd_info_buffer *buffer,
105 struct snd_seq_pool *pool, char *space);
102 106
103#endif 107#endif
diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c
index 3bf7d73ac52e..e12bcd94b6db 100644
--- a/sound/core/seq/seq_ports.c
+++ b/sound/core/seq/seq_ports.c
@@ -412,7 +412,7 @@ int snd_seq_get_port_info(struct snd_seq_client_port * port,
412 * initialization or termination of devices (see seq_midi.c). 412 * initialization or termination of devices (see seq_midi.c).
413 * 413 *
414 * If callback_all option is set, the callback function is invoked 414 * If callback_all option is set, the callback function is invoked
415 * at each connnection/disconnection. 415 * at each connection/disconnection.
416 */ 416 */
417 417
418static int subscribe_port(struct snd_seq_client *client, 418static int subscribe_port(struct snd_seq_client *client,
diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c
index e7a8e9e4edb2..f9077361c119 100644
--- a/sound/core/seq/seq_queue.c
+++ b/sound/core/seq/seq_queue.c
@@ -467,13 +467,11 @@ int snd_seq_queue_timer_open(int queueid)
467int snd_seq_queue_timer_close(int queueid) 467int snd_seq_queue_timer_close(int queueid)
468{ 468{
469 struct snd_seq_queue *queue; 469 struct snd_seq_queue *queue;
470 struct snd_seq_timer *tmr;
471 int result = 0; 470 int result = 0;
472 471
473 queue = queueptr(queueid); 472 queue = queueptr(queueid);
474 if (queue == NULL) 473 if (queue == NULL)
475 return -EINVAL; 474 return -EINVAL;
476 tmr = queue->timer;
477 snd_seq_timer_close(queue); 475 snd_seq_timer_close(queue);
478 queuefree(queue); 476 queuefree(queue);
479 return result; 477 return result;
diff --git a/sound/core/sound.c b/sound/core/sound.c
index ac42af42b787..1c7a3efe1778 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -21,7 +21,6 @@
21 21
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/smp_lock.h>
25#include <linux/time.h> 24#include <linux/time.h>
26#include <linux/device.h> 25#include <linux/device.h>
27#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
@@ -184,18 +183,27 @@ static int snd_open(struct inode *inode, struct file *file)
184static const struct file_operations snd_fops = 183static const struct file_operations snd_fops =
185{ 184{
186 .owner = THIS_MODULE, 185 .owner = THIS_MODULE,
187 .open = snd_open 186 .open = snd_open,
187 .llseek = noop_llseek,
188}; 188};
189 189
190#ifdef CONFIG_SND_DYNAMIC_MINORS 190#ifdef CONFIG_SND_DYNAMIC_MINORS
191static int snd_find_free_minor(void) 191static int snd_find_free_minor(int type)
192{ 192{
193 int minor; 193 int minor;
194 194
195 /* static minors for module auto loading */
196 if (type == SNDRV_DEVICE_TYPE_SEQUENCER)
197 return SNDRV_MINOR_SEQUENCER;
198 if (type == SNDRV_DEVICE_TYPE_TIMER)
199 return SNDRV_MINOR_TIMER;
200
195 for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) { 201 for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) {
196 /* skip minors still used statically for autoloading devices */ 202 /* skip static minors still used for module auto loading */
197 if (SNDRV_MINOR_DEVICE(minor) == SNDRV_MINOR_CONTROL || 203 if (SNDRV_MINOR_DEVICE(minor) == SNDRV_MINOR_CONTROL)
198 minor == SNDRV_MINOR_SEQUENCER) 204 continue;
205 if (minor == SNDRV_MINOR_SEQUENCER ||
206 minor == SNDRV_MINOR_TIMER)
199 continue; 207 continue;
200 if (!snd_minors[minor]) 208 if (!snd_minors[minor])
201 return minor; 209 return minor;
@@ -269,7 +277,7 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
269 preg->private_data = private_data; 277 preg->private_data = private_data;
270 mutex_lock(&sound_mutex); 278 mutex_lock(&sound_mutex);
271#ifdef CONFIG_SND_DYNAMIC_MINORS 279#ifdef CONFIG_SND_DYNAMIC_MINORS
272 minor = snd_find_free_minor(); 280 minor = snd_find_free_minor(type);
273#else 281#else
274 minor = snd_kernel_minor(type, card, dev); 282 minor = snd_kernel_minor(type, card, dev);
275 if (minor >= 0 && snd_minors[minor]) 283 if (minor >= 0 && snd_minors[minor])
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 13afb60999b9..7c1cbf0a0dc4 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -34,8 +34,8 @@
34#include <sound/initval.h> 34#include <sound/initval.h>
35#include <linux/kmod.h> 35#include <linux/kmod.h>
36 36
37#if defined(CONFIG_SND_HPET) || defined(CONFIG_SND_HPET_MODULE) 37#if defined(CONFIG_SND_HRTIMER) || defined(CONFIG_SND_HRTIMER_MODULE)
38#define DEFAULT_TIMER_LIMIT 3 38#define DEFAULT_TIMER_LIMIT 4
39#elif defined(CONFIG_SND_RTCTIMER) || defined(CONFIG_SND_RTCTIMER_MODULE) 39#elif defined(CONFIG_SND_RTCTIMER) || defined(CONFIG_SND_RTCTIMER_MODULE)
40#define DEFAULT_TIMER_LIMIT 2 40#define DEFAULT_TIMER_LIMIT 2
41#else 41#else
@@ -52,6 +52,9 @@ MODULE_PARM_DESC(timer_limit, "Maximum global timers in system.");
52module_param(timer_tstamp_monotonic, int, 0444); 52module_param(timer_tstamp_monotonic, int, 0444);
53MODULE_PARM_DESC(timer_tstamp_monotonic, "Use posix monotonic clock source for timestamps (default)."); 53MODULE_PARM_DESC(timer_tstamp_monotonic, "Use posix monotonic clock source for timestamps (default).");
54 54
55MODULE_ALIAS_CHARDEV(CONFIG_SND_MAJOR, SNDRV_MINOR_TIMER);
56MODULE_ALIAS("devname:snd/timer");
57
55struct snd_timer_user { 58struct snd_timer_user {
56 struct snd_timer_instance *timeri; 59 struct snd_timer_instance *timeri;
57 int tread; /* enhanced read with timestamps and events */ 60 int tread; /* enhanced read with timestamps and events */
@@ -183,9 +186,8 @@ static void snd_timer_check_slave(struct snd_timer_instance *slave)
183 list_for_each_entry(master, &timer->open_list_head, open_list) { 186 list_for_each_entry(master, &timer->open_list_head, open_list) {
184 if (slave->slave_class == master->slave_class && 187 if (slave->slave_class == master->slave_class &&
185 slave->slave_id == master->slave_id) { 188 slave->slave_id == master->slave_id) {
186 list_del(&slave->open_list); 189 list_move_tail(&slave->open_list,
187 list_add_tail(&slave->open_list, 190 &master->slave_list_head);
188 &master->slave_list_head);
189 spin_lock_irq(&slave_active_lock); 191 spin_lock_irq(&slave_active_lock);
190 slave->master = master; 192 slave->master = master;
191 slave->timer = master->timer; 193 slave->timer = master->timer;
@@ -411,8 +413,7 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
411static int snd_timer_start1(struct snd_timer *timer, struct snd_timer_instance *timeri, 413static int snd_timer_start1(struct snd_timer *timer, struct snd_timer_instance *timeri,
412 unsigned long sticks) 414 unsigned long sticks)
413{ 415{
414 list_del(&timeri->active_list); 416 list_move_tail(&timeri->active_list, &timer->active_list_head);
415 list_add_tail(&timeri->active_list, &timer->active_list_head);
416 if (timer->running) { 417 if (timer->running) {
417 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE) 418 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
418 goto __start_now; 419 goto __start_now;
diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c
index 3b9b550109cb..a39d3d8c2f9c 100644
--- a/sound/core/vmaster.c
+++ b/sound/core/vmaster.c
@@ -18,7 +18,7 @@
18 * a subset of information returned via ctl info callback 18 * a subset of information returned via ctl info callback
19 */ 19 */
20struct link_ctl_info { 20struct link_ctl_info {
21 int type; /* value type */ 21 snd_ctl_elem_type_t type; /* value type */
22 int count; /* item count */ 22 int count; /* item count */
23 int min_val, max_val; /* min, max values */ 23 int min_val, max_val; /* min, max values */
24}; 24};
@@ -233,7 +233,7 @@ static void slave_free(struct snd_kcontrol *kcontrol)
233 * Add a slave control to the group with the given master control 233 * Add a slave control to the group with the given master control
234 * 234 *
235 * All slaves must be the same type (returning the same information 235 * All slaves must be the same type (returning the same information
236 * via info callback). The fucntion doesn't check it, so it's your 236 * via info callback). The function doesn't check it, so it's your
237 * responsibility. 237 * responsibility.
238 * 238 *
239 * Also, some additional limitations: 239 * Also, some additional limitations: