Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'sound-3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

Pull sound fixes from Takashi Iwai:
"This contains unexpectedly many changes in a wide range due to the
fixes for races at disconnection of USB audio devices. In the end, we
end up covering fairly core parts of sound subsystem.

Other than that, just a few usual small fixes."

* tag 'sound-3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
ALSA: ice1724: Fix rate setup after resume
ALSA: Avoid endless sleep after disconnect
ALSA: Add a reference counter to card instance
ALSA: usb-audio: Fix races at disconnection in mixer_quirks.c
ALSA: usb-audio: Use rwsem for disconnect protection
ALSA: usb-audio: Fix races at disconnection
ALSA: PCM: Fix some races at disconnection
ASoC: omap-dmic: Correct functional clock name
ASoC: zoom2: Fix compile error by including correct header files
ALSA: hda - Fix mute-LED setup for HP dv5 laptop

+303 -99
+3
include/sound/core.h
··· 132 132 int shutdown; /* this card is going down */ 133 133 int free_on_last_close; /* free in context of file_release */ 134 134 wait_queue_head_t shutdown_sleep; 135 + atomic_t refcount; /* refcount for disconnection */ 135 136 struct device *dev; /* device assigned to this card */ 136 137 struct device *card_dev; /* cardX object for sysfs */ 137 138 ··· 190 189 const struct file_operations *f_ops; /* file operations */ 191 190 void *private_data; /* private data for f_ops->open */ 192 191 struct device *dev; /* device for sysfs */ 192 + struct snd_card *card_ptr; /* assigned card instance */ 193 193 }; 194 194 195 195 /* return a device pointer linked to each sound device as a parent */ ··· 297 295 int snd_component_add(struct snd_card *card, const char *component); 298 296 int snd_card_file_add(struct snd_card *card, struct file *file); 299 297 int snd_card_file_remove(struct snd_card *card, struct file *file); 298 + void snd_card_unref(struct snd_card *card); 300 299 301 300 #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr)) 302 301
+7 -2
sound/core/compress_offload.c
··· 100 100 101 101 if (dirn != compr->direction) { 102 102 pr_err("this device doesn't support this direction\n"); 103 + snd_card_unref(compr->card); 103 104 return -EINVAL; 104 105 } 105 106 106 107 data = kzalloc(sizeof(*data), GFP_KERNEL); 107 - if (!data) 108 + if (!data) { 109 + snd_card_unref(compr->card); 108 110 return -ENOMEM; 111 + } 109 112 data->stream.ops = compr->ops; 110 113 data->stream.direction = dirn; 111 114 data->stream.private_data = compr->private_data; ··· 116 113 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); 117 114 if (!runtime) { 118 115 kfree(data); 116 + snd_card_unref(compr->card); 119 117 return -ENOMEM; 120 118 } 121 119 runtime->state = SNDRV_PCM_STATE_OPEN; ··· 130 126 kfree(runtime); 131 127 kfree(data); 132 128 } 133 - return ret; 129 + snd_card_unref(compr->card); 130 + return 0; 134 131 } 135 132 136 133 static int snd_compr_free(struct inode *inode, struct file *f)
+5
sound/core/control.c
··· 86 86 write_lock_irqsave(&card->ctl_files_rwlock, flags); 87 87 list_add_tail(&ctl->list, &card->ctl_files); 88 88 write_unlock_irqrestore(&card->ctl_files_rwlock, flags); 89 + snd_card_unref(card); 89 90 return 0; 90 91 91 92 __error: ··· 94 93 __error2: 95 94 snd_card_file_remove(card, file); 96 95 __error1: 96 + if (card) 97 + snd_card_unref(card); 97 98 return err; 98 99 } 99 100 ··· 1437 1434 spin_unlock_irq(&ctl->read_lock); 1438 1435 schedule(); 1439 1436 remove_wait_queue(&ctl->change_sleep, &wait); 1437 + if (ctl->card->shutdown) 1438 + return -ENODEV; 1440 1439 if (signal_pending(current)) 1441 1440 return -ERESTARTSYS; 1442 1441 spin_lock_irq(&ctl->read_lock);
+11 -1
sound/core/hwdep.c
··· 100 100 if (hw == NULL) 101 101 return -ENODEV; 102 102 103 - if (!try_module_get(hw->card->module)) 103 + if (!try_module_get(hw->card->module)) { 104 + snd_card_unref(hw->card); 104 105 return -EFAULT; 106 + } 105 107 106 108 init_waitqueue_entry(&wait, current); 107 109 add_wait_queue(&hw->open_wait, &wait); ··· 131 129 mutex_unlock(&hw->open_mutex); 132 130 schedule(); 133 131 mutex_lock(&hw->open_mutex); 132 + if (hw->card->shutdown) { 133 + err = -ENODEV; 134 + break; 135 + } 134 136 if (signal_pending(current)) { 135 137 err = -ERESTARTSYS; 136 138 break; ··· 154 148 mutex_unlock(&hw->open_mutex); 155 149 if (err < 0) 156 150 module_put(hw->card->module); 151 + snd_card_unref(hw->card); 157 152 return err; 158 153 } 159 154 ··· 466 459 mutex_unlock(&register_mutex); 467 460 return -EINVAL; 468 461 } 462 + mutex_lock(&hwdep->open_mutex); 463 + wake_up(&hwdep->open_wait); 469 464 #ifdef CONFIG_SND_OSSEMUL 470 465 if (hwdep->ossreg) 471 466 snd_unregister_oss_device(hwdep->oss_type, hwdep->card, hwdep->device); 472 467 #endif 473 468 snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device); 474 469 list_del_init(&hwdep->list); 470 + mutex_unlock(&hwdep->open_mutex); 475 471 mutex_unlock(&register_mutex); 476 472 return 0; 477 473 }
+30 -20
sound/core/init.c
··· 213 213 spin_lock_init(&card->files_lock); 214 214 INIT_LIST_HEAD(&card->files_list); 215 215 init_waitqueue_head(&card->shutdown_sleep); 216 + atomic_set(&card->refcount, 0); 216 217 #ifdef CONFIG_PM 217 218 mutex_init(&card->power_lock); 218 219 init_waitqueue_head(&card->power_sleep); ··· 447 446 return 0; 448 447 } 449 448 449 + /** 450 + * snd_card_unref - release the reference counter 451 + * @card: the card instance 452 + * 453 + * Decrements the reference counter. When it reaches to zero, wake up 454 + * the sleeper and call the destructor if needed. 455 + */ 456 + void snd_card_unref(struct snd_card *card) 457 + { 458 + if (atomic_dec_and_test(&card->refcount)) { 459 + wake_up(&card->shutdown_sleep); 460 + if (card->free_on_last_close) 461 + snd_card_do_free(card); 462 + } 463 + } 464 + EXPORT_SYMBOL(snd_card_unref); 465 + 450 466 int snd_card_free_when_closed(struct snd_card *card) 451 467 { 452 - int free_now = 0; 453 - int ret = snd_card_disconnect(card); 454 - if (ret) 468 + int ret; 469 + 470 + atomic_inc(&card->refcount); 471 + ret = snd_card_disconnect(card); 472 + if (ret) { 473 + atomic_dec(&card->refcount); 455 474 return ret; 475 + } 456 476 457 - spin_lock(&card->files_lock); 458 - if (list_empty(&card->files_list)) 459 - free_now = 1; 460 - else 461 - card->free_on_last_close = 1; 462 - spin_unlock(&card->files_lock); 463 - 464 - if (free_now) 477 + card->free_on_last_close = 1; 478 + if (atomic_dec_and_test(&card->refcount)) 465 479 snd_card_do_free(card); 466 480 return 0; 467 481 } ··· 490 474 return ret; 491 475 492 476 /* wait, until all devices are ready for the free operation */ 493 - wait_event(card->shutdown_sleep, list_empty(&card->files_list)); 477 + wait_event(card->shutdown_sleep, !atomic_read(&card->refcount)); 494 478 snd_card_do_free(card); 495 479 return 0; 496 480 } ··· 902 886 return -ENODEV; 903 887 } 904 888 list_add(&mfile->list, &card->files_list); 889 + atomic_inc(&card->refcount); 905 890 spin_unlock(&card->files_lock); 906 891 return 0; 907 892 } ··· 925 908 int snd_card_file_remove(struct snd_card *card, struct file *file) 926 909 { 927 910 struct snd_monitor_file *mfile, *found = NULL; 928 - int last_close = 0; 929 911 930 912 spin_lock(&card->files_lock); 931 913 list_for_each_entry(mfile, &card->files_list, list) { ··· 939 923 break; 940 924 } 941 925 } 942 - if (list_empty(&card->files_list)) 943 - last_close = 1; 944 926 spin_unlock(&card->files_lock); 945 - if (last_close) { 946 - wake_up(&card->shutdown_sleep); 947 - if (card->free_on_last_close) 948 - snd_card_do_free(card); 949 - } 950 927 if (!found) { 951 928 snd_printk(KERN_ERR "ALSA card file remove problem (%p)\n", file); 952 929 return -ENOENT; 953 930 } 954 931 kfree(found); 932 + snd_card_unref(card); 955 933 return 0; 956 934 } 957 935
+8 -2
sound/core/oss/mixer_oss.c
··· 52 52 SNDRV_OSS_DEVICE_TYPE_MIXER); 53 53 if (card == NULL) 54 54 return -ENODEV; 55 - if (card->mixer_oss == NULL) 55 + if (card->mixer_oss == NULL) { 56 + snd_card_unref(card); 56 57 return -ENODEV; 58 + } 57 59 err = snd_card_file_add(card, file); 58 - if (err < 0) 60 + if (err < 0) { 61 + snd_card_unref(card); 59 62 return err; 63 + } 60 64 fmixer = kzalloc(sizeof(*fmixer), GFP_KERNEL); 61 65 if (fmixer == NULL) { 62 66 snd_card_file_remove(card, file); 67 + snd_card_unref(card); 63 68 return -ENOMEM; 64 69 } 65 70 fmixer->card = card; ··· 73 68 if (!try_module_get(card->module)) { 74 69 kfree(fmixer); 75 70 snd_card_file_remove(card, file); 71 + snd_card_unref(card); 76 72 return -EFAULT; 77 73 } 78 74 return 0;
+6
sound/core/oss/pcm_oss.c
··· 2441 2441 mutex_unlock(&pcm->open_mutex); 2442 2442 schedule(); 2443 2443 mutex_lock(&pcm->open_mutex); 2444 + if (pcm->card->shutdown) { 2445 + err = -ENODEV; 2446 + break; 2447 + } 2444 2448 if (signal_pending(current)) { 2445 2449 err = -ERESTARTSYS; 2446 2450 break; ··· 2461 2457 __error2: 2462 2458 snd_card_file_remove(pcm->card, file); 2463 2459 __error1: 2460 + if (pcm) 2461 + snd_card_unref(pcm->card); 2464 2462 return err; 2465 2463 } 2466 2464
+11 -2
sound/core/pcm.c
··· 1086 1086 if (list_empty(&pcm->list)) 1087 1087 goto unlock; 1088 1088 1089 + mutex_lock(&pcm->open_mutex); 1090 + wake_up(&pcm->open_wait); 1089 1091 list_del_init(&pcm->list); 1090 1092 for (cidx = 0; cidx < 2; cidx++) 1091 - for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) 1092 - if (substream->runtime) 1093 + for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) { 1094 + snd_pcm_stream_lock_irq(substream); 1095 + if (substream->runtime) { 1093 1096 substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED; 1097 + wake_up(&substream->runtime->sleep); 1098 + wake_up(&substream->runtime->tsleep); 1099 + } 1100 + snd_pcm_stream_unlock_irq(substream); 1101 + } 1094 1102 list_for_each_entry(notify, &snd_pcm_notify_list, list) { 1095 1103 notify->n_disconnect(pcm); 1096 1104 } ··· 1118 1110 pcm->streams[cidx].chmap_kctl = NULL; 1119 1111 } 1120 1112 } 1113 + mutex_unlock(&pcm->open_mutex); 1121 1114 unlock: 1122 1115 mutex_unlock(&register_mutex); 1123 1116 return 0;
+27 -6
sound/core/pcm_native.c
··· 369 369 return usecs; 370 370 } 371 371 372 + static void snd_pcm_set_state(struct snd_pcm_substream *substream, int state) 373 + { 374 + snd_pcm_stream_lock_irq(substream); 375 + if (substream->runtime->status->state != SNDRV_PCM_STATE_DISCONNECTED) 376 + substream->runtime->status->state = state; 377 + snd_pcm_stream_unlock_irq(substream); 378 + } 379 + 372 380 static int snd_pcm_hw_params(struct snd_pcm_substream *substream, 373 381 struct snd_pcm_hw_params *params) 374 382 { ··· 460 452 runtime->boundary *= 2; 461 453 462 454 snd_pcm_timer_resolution_change(substream); 463 - runtime->status->state = SNDRV_PCM_STATE_SETUP; 455 + snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP); 464 456 465 457 if (pm_qos_request_active(&substream->latency_pm_qos_req)) 466 458 pm_qos_remove_request(&substream->latency_pm_qos_req); ··· 472 464 /* hardware might be unusable from this time, 473 465 so we force application to retry to set 474 466 the correct hardware parameter settings */ 475 - runtime->status->state = SNDRV_PCM_STATE_OPEN; 467 + snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); 476 468 if (substream->ops->hw_free != NULL) 477 469 substream->ops->hw_free(substream); 478 470 return err; ··· 520 512 return -EBADFD; 521 513 if (substream->ops->hw_free) 522 514 result = substream->ops->hw_free(substream); 523 - runtime->status->state = SNDRV_PCM_STATE_OPEN; 515 + snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); 524 516 pm_qos_remove_request(&substream->latency_pm_qos_req); 525 517 return result; 526 518 } ··· 1328 1320 { 1329 1321 struct snd_pcm_runtime *runtime = substream->runtime; 1330 1322 runtime->control->appl_ptr = runtime->status->hw_ptr; 1331 - runtime->status->state = SNDRV_PCM_STATE_PREPARED; 1323 + snd_pcm_set_state(substream, SNDRV_PCM_STATE_PREPARED); 1332 1324 } 1333 1325 1334 1326 static struct action_ops snd_pcm_action_prepare = { ··· 1518 1510 down_read(&snd_pcm_link_rwsem); 1519 1511 snd_pcm_stream_lock_irq(substream); 1520 1512 remove_wait_queue(&to_check->sleep, &wait); 1513 + if (card->shutdown) { 1514 + result = -ENODEV; 1515 + break; 1516 + } 1521 1517 if (tout == 0) { 1522 1518 if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) 1523 1519 result = -ESTRPIPE; ··· 1646 1634 write_unlock_irq(&snd_pcm_link_rwlock); 1647 1635 up_write(&snd_pcm_link_rwsem); 1648 1636 _nolock: 1637 + snd_card_unref(substream1->pcm->card); 1649 1638 fput_light(file, fput_needed); 1650 1639 if (res < 0) 1651 1640 kfree(group); ··· 2121 2108 return err; 2122 2109 pcm = snd_lookup_minor_data(iminor(inode), 2123 2110 SNDRV_DEVICE_TYPE_PCM_PLAYBACK); 2124 - return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK); 2111 + err = snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK); 2112 + snd_card_unref(pcm->card); 2113 + return err; 2125 2114 } 2126 2115 2127 2116 static int snd_pcm_capture_open(struct inode *inode, struct file *file) ··· 2134 2119 return err; 2135 2120 pcm = snd_lookup_minor_data(iminor(inode), 2136 2121 SNDRV_DEVICE_TYPE_PCM_CAPTURE); 2137 - return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE); 2122 + err = snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE); 2123 + snd_card_unref(pcm->card); 2124 + return err; 2138 2125 } 2139 2126 2140 2127 static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream) ··· 2173 2156 mutex_unlock(&pcm->open_mutex); 2174 2157 schedule(); 2175 2158 mutex_lock(&pcm->open_mutex); 2159 + if (pcm->card->shutdown) { 2160 + err = -ENODEV; 2161 + break; 2162 + } 2176 2163 if (signal_pending(current)) { 2177 2164 err = -ERESTARTSYS; 2178 2165 break;
+25 -1
sound/core/rawmidi.c
··· 379 379 if (rmidi == NULL) 380 380 return -ENODEV; 381 381 382 - if (!try_module_get(rmidi->card->module)) 382 + if (!try_module_get(rmidi->card->module)) { 383 + snd_card_unref(rmidi->card); 383 384 return -ENXIO; 385 + } 384 386 385 387 mutex_lock(&rmidi->open_mutex); 386 388 card = rmidi->card; ··· 424 422 mutex_unlock(&rmidi->open_mutex); 425 423 schedule(); 426 424 mutex_lock(&rmidi->open_mutex); 425 + if (rmidi->card->shutdown) { 426 + err = -ENODEV; 427 + break; 428 + } 427 429 if (signal_pending(current)) { 428 430 err = -ERESTARTSYS; 429 431 break; ··· 446 440 #endif 447 441 file->private_data = rawmidi_file; 448 442 mutex_unlock(&rmidi->open_mutex); 443 + snd_card_unref(rmidi->card); 449 444 return 0; 450 445 451 446 __error: ··· 454 447 __error_card: 455 448 mutex_unlock(&rmidi->open_mutex); 456 449 module_put(rmidi->card->module); 450 + snd_card_unref(rmidi->card); 457 451 return err; 458 452 } 459 453 ··· 999 991 spin_unlock_irq(&runtime->lock); 1000 992 schedule(); 1001 993 remove_wait_queue(&runtime->sleep, &wait); 994 + if (rfile->rmidi->card->shutdown) 995 + return -ENODEV; 1002 996 if (signal_pending(current)) 1003 997 return result > 0 ? result : -ERESTARTSYS; 1004 998 if (!runtime->avail) ··· 1244 1234 spin_unlock_irq(&runtime->lock); 1245 1235 timeout = schedule_timeout(30 * HZ); 1246 1236 remove_wait_queue(&runtime->sleep, &wait); 1237 + if (rfile->rmidi->card->shutdown) 1238 + return -ENODEV; 1247 1239 if (signal_pending(current)) 1248 1240 return result > 0 ? result : -ERESTARTSYS; 1249 1241 if (!runtime->avail && !timeout) ··· 1621 1609 static int snd_rawmidi_dev_disconnect(struct snd_device *device) 1622 1610 { 1623 1611 struct snd_rawmidi *rmidi = device->device_data; 1612 + int dir; 1624 1613 1625 1614 mutex_lock(&register_mutex); 1615 + mutex_lock(&rmidi->open_mutex); 1616 + wake_up(&rmidi->open_wait); 1626 1617 list_del_init(&rmidi->list); 1618 + for (dir = 0; dir < 2; dir++) { 1619 + struct snd_rawmidi_substream *s; 1620 + list_for_each_entry(s, &rmidi->streams[dir].substreams, list) { 1621 + if (s->runtime) 1622 + wake_up(&s->runtime->sleep); 1623 + } 1624 + } 1625 + 1627 1626 #ifdef CONFIG_SND_OSSEMUL 1628 1627 if (rmidi->ossreg) { 1629 1628 if ((int)rmidi->device == midi_map[rmidi->card->number]) { ··· 1649 1626 } 1650 1627 #endif /* CONFIG_SND_OSSEMUL */ 1651 1628 snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); 1629 + mutex_unlock(&rmidi->open_mutex); 1652 1630 mutex_unlock(&register_mutex); 1653 1631 return 0; 1654 1632 }
+9 -2
sound/core/sound.c
··· 98 98 * 99 99 * Checks that a minor device with the specified type is registered, and returns 100 100 * its user data pointer. 101 + * 102 + * This function increments the reference counter of the card instance 103 + * if an associated instance with the given minor number and type is found. 104 + * The caller must call snd_card_unref() appropriately later. 101 105 */ 102 106 void *snd_lookup_minor_data(unsigned int minor, int type) 103 107 { ··· 112 108 return NULL; 113 109 mutex_lock(&sound_mutex); 114 110 mreg = snd_minors[minor]; 115 - if (mreg && mreg->type == type) 111 + if (mreg && mreg->type == type) { 116 112 private_data = mreg->private_data; 117 - else 113 + if (mreg->card_ptr) 114 + atomic_inc(&mreg->card_ptr->refcount); 115 + } else 118 116 private_data = NULL; 119 117 mutex_unlock(&sound_mutex); 120 118 return private_data; ··· 281 275 preg->device = dev; 282 276 preg->f_ops = f_ops; 283 277 preg->private_data = private_data; 278 + preg->card_ptr = card; 284 279 mutex_lock(&sound_mutex); 285 280 #ifdef CONFIG_SND_DYNAMIC_MINORS 286 281 minor = snd_find_free_minor(type);
+8 -2
sound/core/sound_oss.c
··· 40 40 static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS]; 41 41 static DEFINE_MUTEX(sound_oss_mutex); 42 42 43 + /* NOTE: This function increments the refcount of the associated card like 44 + * snd_lookup_minor_data(); the caller must call snd_card_unref() appropriately 45 + */ 43 46 void *snd_lookup_oss_minor_data(unsigned int minor, int type) 44 47 { 45 48 struct snd_minor *mreg; ··· 52 49 return NULL; 53 50 mutex_lock(&sound_oss_mutex); 54 51 mreg = snd_oss_minors[minor]; 55 - if (mreg && mreg->type == type) 52 + if (mreg && mreg->type == type) { 56 53 private_data = mreg->private_data; 57 - else 54 + if (mreg->card_ptr) 55 + atomic_inc(&mreg->card_ptr->refcount); 56 + } else 58 57 private_data = NULL; 59 58 mutex_unlock(&sound_oss_mutex); 60 59 return private_data; ··· 128 123 preg->device = dev; 129 124 preg->f_ops = f_ops; 130 125 preg->private_data = private_data; 126 + preg->card_ptr = card; 131 127 mutex_lock(&sound_oss_mutex); 132 128 snd_oss_minors[minor] = preg; 133 129 minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
+2
sound/pci/hda/patch_sigmatel.c
··· 1763 1763 "HP", STAC_HP_ZEPHYR), 1764 1764 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660, 1765 1765 "HP Mini", STAC_92HD83XXX_HP_LED), 1766 + SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E, 1767 + "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED), 1766 1768 {} /* terminator */ 1767 1769 }; 1768 1770
+6 -1
sound/pci/ice1712/ice1724.c
··· 2859 2859 ice->set_spdif_clock(ice, 0); 2860 2860 } else { 2861 2861 /* internal on-card clock */ 2862 - snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 1); 2862 + int rate; 2863 + if (ice->cur_rate) 2864 + rate = ice->cur_rate; 2865 + else 2866 + rate = ice->pro_rate_default; 2867 + snd_vt1724_set_pro_rate(ice, rate, 1); 2863 2868 } 2864 2869 2865 2870 update_spdif_bits(ice, ice->pm_saved_spdif_ctrl);
+2 -2
sound/soc/omap/omap-dmic.c
··· 464 464 465 465 mutex_init(&dmic->mutex); 466 466 467 - dmic->fclk = clk_get(dmic->dev, "dmic_fck"); 467 + dmic->fclk = clk_get(dmic->dev, "fck"); 468 468 if (IS_ERR(dmic->fclk)) { 469 - dev_err(dmic->dev, "cant get dmic_fck\n"); 469 + dev_err(dmic->dev, "cant get fck\n"); 470 470 return -ENODEV; 471 471 } 472 472
+2 -3
sound/soc/omap/zoom2.c
··· 21 21 22 22 #include <linux/clk.h> 23 23 #include <linux/platform_device.h> 24 + #include <linux/gpio.h> 24 25 #include <sound/core.h> 25 26 #include <sound/pcm.h> 26 27 #include <sound/soc.h> 27 28 28 29 #include <asm/mach-types.h> 29 - #include <mach/hardware.h> 30 - #include <mach/gpio.h> 31 - #include <mach/board-zoom.h> 32 30 #include <linux/platform_data/asoc-ti-mcbsp.h> 31 + #include <linux/platform_data/gpio-omap.h> 33 32 34 33 /* Register descriptions for twl4030 codec part */ 35 34 #include <linux/mfd/twl4030-audio.h>
+8 -4
sound/usb/card.c
··· 339 339 } 340 340 341 341 mutex_init(&chip->mutex); 342 - mutex_init(&chip->shutdown_mutex); 342 + init_rwsem(&chip->shutdown_rwsem); 343 343 chip->index = idx; 344 344 chip->dev = dev; 345 345 chip->card = card; ··· 560 560 561 561 card = chip->card; 562 562 mutex_lock(&register_mutex); 563 - mutex_lock(&chip->shutdown_mutex); 563 + down_write(&chip->shutdown_rwsem); 564 564 chip->shutdown = 1; 565 565 chip->num_interfaces--; 566 566 if (chip->num_interfaces <= 0) { ··· 582 582 snd_usb_mixer_disconnect(p); 583 583 } 584 584 usb_chip[chip->index] = NULL; 585 - mutex_unlock(&chip->shutdown_mutex); 585 + up_write(&chip->shutdown_rwsem); 586 586 mutex_unlock(&register_mutex); 587 587 snd_card_free_when_closed(card); 588 588 } else { 589 - mutex_unlock(&chip->shutdown_mutex); 589 + up_write(&chip->shutdown_rwsem); 590 590 mutex_unlock(&register_mutex); 591 591 } 592 592 } ··· 618 618 { 619 619 int err = -ENODEV; 620 620 621 + down_read(&chip->shutdown_rwsem); 621 622 if (!chip->shutdown && !chip->probing) 622 623 err = usb_autopm_get_interface(chip->pm_intf); 624 + up_read(&chip->shutdown_rwsem); 623 625 624 626 return err; 625 627 } 626 628 627 629 void snd_usb_autosuspend(struct snd_usb_audio *chip) 628 630 { 631 + down_read(&chip->shutdown_rwsem); 629 632 if (!chip->shutdown && !chip->probing) 630 633 usb_autopm_put_interface(chip->pm_intf); 634 + up_read(&chip->shutdown_rwsem); 631 635 } 632 636 633 637 static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
+1
sound/usb/card.h
··· 126 126 struct snd_usb_endpoint *sync_endpoint; 127 127 unsigned long flags; 128 128 bool need_setup_ep; /* (re)configure EP at prepare? */ 129 + unsigned int speed; /* USB_SPEED_XXX */ 129 130 130 131 u64 formats; /* format bitmasks (all or'ed) */ 131 132 unsigned int num_formats; /* number of supported audio formats (list) */
+43 -22
sound/usb/mixer.c
··· 287 287 unsigned char buf[2]; 288 288 int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1; 289 289 int timeout = 10; 290 - int err; 290 + int idx = 0, err; 291 291 292 292 err = snd_usb_autoresume(cval->mixer->chip); 293 293 if (err < 0) 294 294 return -EIO; 295 + down_read(&chip->shutdown_rwsem); 295 296 while (timeout-- > 0) { 297 + if (chip->shutdown) 298 + break; 299 + idx = snd_usb_ctrl_intf(chip) | (cval->id << 8); 296 300 if (snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), request, 297 301 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 298 - validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), 299 - buf, val_len) >= val_len) { 302 + validx, idx, buf, val_len) >= val_len) { 300 303 *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len)); 301 - snd_usb_autosuspend(cval->mixer->chip); 302 - return 0; 304 + err = 0; 305 + goto out; 303 306 } 304 307 } 305 - snd_usb_autosuspend(cval->mixer->chip); 306 308 snd_printdd(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", 307 - request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type); 308 - return -EINVAL; 309 + request, validx, idx, cval->val_type); 310 + err = -EINVAL; 311 + 312 + out: 313 + up_read(&chip->shutdown_rwsem); 314 + snd_usb_autosuspend(cval->mixer->chip); 315 + return err; 309 316 } 310 317 311 318 static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) ··· 320 313 struct snd_usb_audio *chip = cval->mixer->chip; 321 314 unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */ 322 315 unsigned char *val; 323 - int ret, size; 316 + int idx = 0, ret, size; 324 317 __u8 bRequest; 325 318 326 319 if (request == UAC_GET_CUR) { ··· 337 330 if (ret) 338 331 goto error; 339 332 340 - ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest, 333 + down_read(&chip->shutdown_rwsem); 334 + if (chip->shutdown) 335 + ret = -ENODEV; 336 + else { 337 + idx = snd_usb_ctrl_intf(chip) | (cval->id << 8); 338 + ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest, 341 339 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 342 - validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), 343 - buf, size); 340 + validx, idx, buf, size); 341 + } 342 + up_read(&chip->shutdown_rwsem); 344 343 snd_usb_autosuspend(chip); 345 344 346 345 if (ret < 0) { 347 346 error: 348 347 snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", 349 - request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type); 348 + request, validx, idx, cval->val_type); 350 349 return ret; 351 350 } 352 351 ··· 430 417 { 431 418 struct snd_usb_audio *chip = cval->mixer->chip; 432 419 unsigned char buf[2]; 433 - int val_len, err, timeout = 10; 420 + int idx = 0, val_len, err, timeout = 10; 434 421 435 422 if (cval->mixer->protocol == UAC_VERSION_1) { 436 423 val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1; ··· 453 440 err = snd_usb_autoresume(chip); 454 441 if (err < 0) 455 442 return -EIO; 456 - while (timeout-- > 0) 443 + down_read(&chip->shutdown_rwsem); 444 + while (timeout-- > 0) { 445 + if (chip->shutdown) 446 + break; 447 + idx = snd_usb_ctrl_intf(chip) | (cval->id << 8); 457 448 if (snd_usb_ctl_msg(chip->dev, 458 449 usb_sndctrlpipe(chip->dev, 0), request, 459 450 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, 460 - validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), 461 - buf, val_len) >= 0) { 462 - snd_usb_autosuspend(chip); 463 - return 0; 451 + validx, idx, buf, val_len) >= 0) { 452 + err = 0; 453 + goto out; 464 454 } 465 - snd_usb_autosuspend(chip); 455 + } 466 456 snd_printdd(KERN_ERR "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n", 467 - request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type, buf[0], buf[1]); 468 - return -EINVAL; 457 + request, validx, idx, cval->val_type, buf[0], buf[1]); 458 + err = -EINVAL; 459 + 460 + out: 461 + up_read(&chip->shutdown_rwsem); 462 + snd_usb_autosuspend(chip); 463 + return err; 469 464 } 470 465 471 466 static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int value)
+51 -7
sound/usb/mixer_quirks.c
··· 283 283 if (value > 1) 284 284 return -EINVAL; 285 285 changed = value != mixer->audigy2nx_leds[index]; 286 + down_read(&mixer->chip->shutdown_rwsem); 287 + if (mixer->chip->shutdown) { 288 + err = -ENODEV; 289 + goto out; 290 + } 286 291 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3042)) 287 292 err = snd_usb_ctl_msg(mixer->chip->dev, 288 293 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24, ··· 304 299 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24, 305 300 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, 306 301 value, index + 2, NULL, 0); 302 + out: 303 + up_read(&mixer->chip->shutdown_rwsem); 307 304 if (err < 0) 308 305 return err; 309 306 mixer->audigy2nx_leds[index] = value; ··· 399 392 400 393 for (i = 0; jacks[i].name; ++i) { 401 394 snd_iprintf(buffer, "%s: ", jacks[i].name); 402 - err = snd_usb_ctl_msg(mixer->chip->dev, 395 + down_read(&mixer->chip->shutdown_rwsem); 396 + if (mixer->chip->shutdown) 397 + err = 0; 398 + else 399 + err = snd_usb_ctl_msg(mixer->chip->dev, 403 400 usb_rcvctrlpipe(mixer->chip->dev, 0), 404 401 UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS | 405 402 USB_RECIP_INTERFACE, 0, 406 403 jacks[i].unitid << 8, buf, 3); 404 + up_read(&mixer->chip->shutdown_rwsem); 407 405 if (err == 3 && (buf[0] == 3 || buf[0] == 6)) 408 406 snd_iprintf(buffer, "%02x %02x\n", buf[1], buf[2]); 409 407 else ··· 438 426 else 439 427 new_status = old_status & ~0x02; 440 428 changed = new_status != old_status; 441 - err = snd_usb_ctl_msg(mixer->chip->dev, 429 + down_read(&mixer->chip->shutdown_rwsem); 430 + if (mixer->chip->shutdown) 431 + err = -ENODEV; 432 + else 433 + err = snd_usb_ctl_msg(mixer->chip->dev, 442 434 usb_sndctrlpipe(mixer->chip->dev, 0), 0x08, 443 435 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, 444 436 50, 0, &new_status, 1); 437 + up_read(&mixer->chip->shutdown_rwsem); 445 438 if (err < 0) 446 439 return err; 447 440 mixer->xonar_u1_status = new_status; ··· 485 468 u8 bRequest = (kcontrol->private_value >> 16) & 0xff; 486 469 u16 wIndex = kcontrol->private_value & 0xffff; 487 470 u8 tmp; 471 + int ret; 488 472 489 - int ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest, 473 + down_read(&mixer->chip->shutdown_rwsem); 474 + if (mixer->chip->shutdown) 475 + ret = -ENODEV; 476 + else 477 + ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest, 490 478 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 491 479 0, cpu_to_le16(wIndex), 492 480 &tmp, sizeof(tmp), 1000); 481 + up_read(&mixer->chip->shutdown_rwsem); 493 482 494 483 if (ret < 0) { 495 484 snd_printk(KERN_ERR ··· 516 493 u8 bRequest = (kcontrol->private_value >> 16) & 0xff; 517 494 u16 wIndex = kcontrol->private_value & 0xffff; 518 495 u16 wValue = ucontrol->value.integer.value[0]; 496 + int ret; 519 497 520 - int ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), bRequest, 498 + down_read(&mixer->chip->shutdown_rwsem); 499 + if (mixer->chip->shutdown) 500 + ret = -ENODEV; 501 + else 502 + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), bRequest, 521 503 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, 522 504 cpu_to_le16(wValue), cpu_to_le16(wIndex), 523 505 NULL, 0, 1000); 506 + up_read(&mixer->chip->shutdown_rwsem); 524 507 525 508 if (ret < 0) { 526 509 snd_printk(KERN_ERR ··· 685 656 return -EINVAL; 686 657 687 658 688 - err = snd_usb_ctl_msg(chip->dev, 659 + down_read(&mixer->chip->shutdown_rwsem); 660 + if (mixer->chip->shutdown) 661 + err = -ENODEV; 662 + else 663 + err = snd_usb_ctl_msg(chip->dev, 689 664 usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR, 690 665 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 691 666 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8), 692 667 value, val_len); 668 + up_read(&mixer->chip->shutdown_rwsem); 693 669 if (err < 0) 694 670 return err; 695 671 ··· 737 703 738 704 if (!pval->is_cached) { 739 705 /* Read current value */ 740 - err = snd_usb_ctl_msg(chip->dev, 706 + down_read(&mixer->chip->shutdown_rwsem); 707 + if (mixer->chip->shutdown) 708 + err = -ENODEV; 709 + else 710 + err = snd_usb_ctl_msg(chip->dev, 741 711 usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR, 742 712 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 743 713 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8), 744 714 value, val_len); 715 + up_read(&mixer->chip->shutdown_rwsem); 745 716 if (err < 0) 746 717 return err; 747 718 ··· 758 719 if (cur_val != new_val) { 759 720 value[0] = new_val; 760 721 value[1] = 0; 761 - err = snd_usb_ctl_msg(chip->dev, 722 + down_read(&mixer->chip->shutdown_rwsem); 723 + if (mixer->chip->shutdown) 724 + err = -ENODEV; 725 + else 726 + err = snd_usb_ctl_msg(chip->dev, 762 727 usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR, 763 728 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, 764 729 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8), 765 730 value, val_len); 731 + up_read(&mixer->chip->shutdown_rwsem); 766 732 if (err < 0) 767 733 return err; 768 734
+34 -19
sound/usb/pcm.c
··· 71 71 unsigned int hwptr_done; 72 72 73 73 subs = (struct snd_usb_substream *)substream->runtime->private_data; 74 + if (subs->stream->chip->shutdown) 75 + return SNDRV_PCM_POS_XRUN; 74 76 spin_lock(&subs->lock); 75 77 hwptr_done = subs->hwptr_done; 76 78 substream->runtime->delay = snd_usb_pcm_delay(subs, ··· 446 444 { 447 445 int ret; 448 446 449 - mutex_lock(&subs->stream->chip->shutdown_mutex); 450 447 /* format changed */ 451 448 stop_endpoints(subs, 0, 0, 0); 452 449 ret = snd_usb_endpoint_set_params(subs->data_endpoint, ··· 456 455 subs->cur_audiofmt, 457 456 subs->sync_endpoint); 458 457 if (ret < 0) 459 - goto unlock; 458 + return ret; 460 459 461 460 if (subs->sync_endpoint) 462 461 ret = snd_usb_endpoint_set_params(subs->data_endpoint, ··· 466 465 subs->cur_rate, 467 466 subs->cur_audiofmt, 468 467 NULL); 469 - 470 - unlock: 471 - mutex_unlock(&subs->stream->chip->shutdown_mutex); 472 468 return ret; 473 469 } 474 470 ··· 503 505 return -EINVAL; 504 506 } 505 507 506 - if ((ret = set_format(subs, fmt)) < 0) 508 + down_read(&subs->stream->chip->shutdown_rwsem); 509 + if (subs->stream->chip->shutdown) 510 + ret = -ENODEV; 511 + else 512 + ret = set_format(subs, fmt); 513 + up_read(&subs->stream->chip->shutdown_rwsem); 514 + if (ret < 0) 507 515 return ret; 508 516 509 517 subs->interface = fmt->iface; ··· 531 527 subs->cur_audiofmt = NULL; 532 528 subs->cur_rate = 0; 533 529 subs->period_bytes = 0; 534 - mutex_lock(&subs->stream->chip->shutdown_mutex); 535 - stop_endpoints(subs, 0, 1, 1); 536 - deactivate_endpoints(subs); 537 - mutex_unlock(&subs->stream->chip->shutdown_mutex); 530 + down_read(&subs->stream->chip->shutdown_rwsem); 531 + if (!subs->stream->chip->shutdown) { 532 + stop_endpoints(subs, 0, 1, 1); 533 + deactivate_endpoints(subs); 534 + } 535 + up_read(&subs->stream->chip->shutdown_rwsem); 538 536 return snd_pcm_lib_free_vmalloc_buffer(substream); 539 537 } 540 538 ··· 558 552 return -ENXIO; 559 553 } 560 554 561 - if (snd_BUG_ON(!subs->data_endpoint)) 562 - return -EIO; 555 + down_read(&subs->stream->chip->shutdown_rwsem); 556 + if (subs->stream->chip->shutdown) { 557 + ret = -ENODEV; 558 + goto unlock; 559 + } 560 + if (snd_BUG_ON(!subs->data_endpoint)) { 561 + ret = -EIO; 562 + goto unlock; 563 + } 563 564 564 565 ret = set_format(subs, subs->cur_audiofmt); 565 566 if (ret < 0) 566 - return ret; 567 + goto unlock; 567 568 568 569 iface = usb_ifnum_to_if(subs->dev, subs->cur_audiofmt->iface); 569 570 alts = &iface->altsetting[subs->cur_audiofmt->altset_idx]; ··· 580 567 subs->cur_audiofmt, 581 568 subs->cur_rate); 582 569 if (ret < 0) 583 - return ret; 570 + goto unlock; 584 571 585 572 if (subs->need_setup_ep) { 586 573 ret = configure_endpoint(subs); 587 574 if (ret < 0) 588 - return ret; 575 + goto unlock; 589 576 subs->need_setup_ep = false; 590 577 } 591 578 ··· 605 592 /* for playback, submit the URBs now; otherwise, the first hwptr_done 606 593 * updates for all URBs would happen at the same time when starting */ 607 594 if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) 608 - return start_endpoints(subs, 1); 595 + ret = start_endpoints(subs, 1); 609 596 610 - return 0; 597 + unlock: 598 + up_read(&subs->stream->chip->shutdown_rwsem); 599 + return ret; 611 600 } 612 601 613 602 static struct snd_pcm_hardware snd_usb_hardware = ··· 662 647 return 0; 663 648 } 664 649 /* check whether the period time is >= the data packet interval */ 665 - if (snd_usb_get_speed(subs->dev) != USB_SPEED_FULL) { 650 + if (subs->speed != USB_SPEED_FULL) { 666 651 ptime = 125 * (1 << fp->datainterval); 667 652 if (ptime > pt->max || (ptime == pt->max && pt->openmax)) { 668 653 hwc_debug(" > check: ptime %u > max %u\n", ptime, pt->max); ··· 940 925 return err; 941 926 942 927 param_period_time_if_needed = SNDRV_PCM_HW_PARAM_PERIOD_TIME; 943 - if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) 928 + if (subs->speed == USB_SPEED_FULL) 944 929 /* full speed devices have fixed data packet interval */ 945 930 ptmin = 1000; 946 931 if (ptmin == 1000)
+2 -2
sound/usb/proc.c
··· 108 108 } 109 109 snd_iprintf(buffer, "\n"); 110 110 } 111 - if (snd_usb_get_speed(subs->dev) != USB_SPEED_FULL) 111 + if (subs->speed != USB_SPEED_FULL) 112 112 snd_iprintf(buffer, " Data packet interval: %d us\n", 113 113 125 * (1 << fp->datainterval)); 114 114 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize); ··· 124 124 return; 125 125 snd_iprintf(buffer, " Packet Size = %d\n", ep->curpacksize); 126 126 snd_iprintf(buffer, " Momentary freq = %u Hz (%#x.%04x)\n", 127 - snd_usb_get_speed(subs->dev) == USB_SPEED_FULL 127 + subs->speed == USB_SPEED_FULL 128 128 ? get_full_speed_hz(ep->freqm) 129 129 : get_high_speed_hz(ep->freqm), 130 130 ep->freqm >> 16, ep->freqm & 0xffff);
+1
sound/usb/stream.c
··· 90 90 subs->direction = stream; 91 91 subs->dev = as->chip->dev; 92 92 subs->txfr_quirk = as->chip->txfr_quirk; 93 + subs->speed = snd_usb_get_speed(subs->dev); 93 94 94 95 snd_usb_set_pcm_ops(as->pcm, stream); 95 96
+1 -1
sound/usb/usbaudio.h
··· 37 37 struct usb_interface *pm_intf; 38 38 u32 usb_id; 39 39 struct mutex mutex; 40 - struct mutex shutdown_mutex; 40 + struct rw_semaphore shutdown_rwsem; 41 41 unsigned int shutdown:1; 42 42 unsigned int probing:1; 43 43 unsigned int autosuspended:1;