Changeset 767
- Timestamp:
- Apr 13, 2025, 3:27:12 AM (8 days ago)
- Location:
- GPL/branches/uniaud32-exp
- Files:
-
- 44 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/control.c ¶
r766 r767 47 47 static int snd_ctl_open(struct inode *inode, struct file *file) 48 48 { 49 unsigned long flags; 49 50 struct snd_card *card; 50 51 struct snd_ctl_file *ctl; … … 82 83 ctl->pid = get_pid(task_pid(current)); 83 84 file->private_data = ctl; 84 scoped_guard(write_lock_irqsave, &card->controls_rwlock)85 write_lock_irqsave(&card->controls_rwlock, flags); 85 86 list_add_tail(&ctl->list, &card->ctl_files); 87 write_unlock_irqrestore(&card->controls_rwlock, flags); 86 88 snd_card_unref(card); 87 89 return 0; … … 99 101 static void snd_ctl_empty_read_queue(struct snd_ctl_file * ctl) 100 102 { 103 unsigned long flags; 101 104 struct snd_kctl_event *cread; 102 105 103 guard(spinlock_irqsave)(&ctl->read_lock);106 spin_lock_irqsave(&ctl->read_lock, flags); 104 107 while (!list_empty(&ctl->events)) { 105 108 cread = snd_kctl_event(ctl->events.next); … … 107 110 kfree(cread); 108 111 } 112 spin_unlock_irqrestore(&ctl->read_lock, flags); 109 113 } 110 114 111 115 static int snd_ctl_release(struct inode *inode, struct file *file) 112 116 { 117 unsigned long flags; 113 118 struct snd_card *card; 114 119 struct snd_ctl_file *ctl; … … 120 125 card = ctl->card; 121 126 122 scoped_guard(write_lock_irqsave, &card->controls_rwlock)127 write_lock_irqsave(&card->controls_rwlock, flags); 123 128 list_del(&ctl->list); 124 125 scoped_guard(rwsem_write, &card->controls_rwsem) {129 write_unlock_irqrestore(&card->controls_rwlock, flags); 130 down_write(&card->controls_rwsem); 126 131 list_for_each_entry(control, &card->controls, list, struct snd_kcontrol) 127 132 for (idx = 0; idx < control->count; idx++) 128 133 if (control->vd[idx].owner == ctl) 129 134 control->vd[idx].owner = NULL; 130 }135 up_write(&card->controls_rwsem); 131 136 132 137 snd_fasync_free(ctl->fasync); … … 152 157 struct snd_ctl_elem_id *id) 153 158 { 159 unsigned long flags; 154 160 struct snd_ctl_file *ctl; 155 161 struct snd_kctl_event *ev; … … 160 166 return; 161 167 162 guard(read_lock_irqsave)(&card->controls_rwlock);168 read_lock_irqsave(&card->controls_rwlock, flags); 163 169 //#if (IS_ENABLED(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS)) 164 170 #if defined(CONFIG_SND_MIXER_OSS) … … 168 174 if (!ctl->subscribed) 169 175 continue; 170 s coped_guard(spinlock, &ctl->read_lock) {176 spin_lock(&ctl->read_lock); 171 177 list_for_each_entry(ev, &ctl->events, list, struct snd_kctl_event) { 172 178 if (ev->id.numid == id->numid) { … … 185 191 _found: 186 192 wake_up(&ctl->change_sleep); 187 }193 spin_unlock(&ctl->read_lock); 188 194 snd_kill_fasync(ctl->fasync, SIGIO, POLL_IN); 189 195 } 196 read_unlock_irqrestore(&card->controls_rwlock, flags); 190 197 } 191 198 EXPORT_SYMBOL(snd_ctl_notify); … … 210 217 id.numid += ioff; 211 218 snd_ctl_notify(card, mask, &id); 212 guard(rwsem_read)(&snd_ctl_layer_rwsem);219 down_read(&snd_ctl_layer_rwsem); 213 220 for (lops = snd_ctl_layer; lops; lops = lops->next) 214 221 lops->lnotify(card, mask, kctl, ioff); 222 up_read(&snd_ctl_layer_rwsem); 215 223 } 216 224 EXPORT_SYMBOL(snd_ctl_notify_one); … … 505 513 return -ENOMEM; 506 514 507 scoped_guard(write_lock_irq, &card->controls_rwlock) {508 515 list_add_tail(&kcontrol->list, &card->controls); 509 516 card->controls_count += kcontrol->count; 510 517 kcontrol->id.numid = card->last_numid + 1; 511 518 card->last_numid += kcontrol->count; 512 }513 519 514 520 add_hash_entries(card, kcontrol); … … 531 537 goto error; 532 538 533 scoped_guard(rwsem_write, &card->controls_rwsem)539 down_write(&card->controls_rwsem); 534 540 err = __snd_ctl_add_replace(card, kcontrol, mode); 541 up_write(&card->controls_rwsem); 535 542 536 543 if (err < 0) … … 595 602 if (snd_BUG_ON(!card || !kcontrol)) 596 603 return -EINVAL; 604 list_del(&kcontrol->list); 597 605 598 606 if (remove_hash) 599 607 remove_hash_entries(card, kcontrol); 600 608 601 scoped_guard(write_lock_irq, &card->controls_rwlock) {602 list_del(&kcontrol->list);603 609 card->controls_count -= kcontrol->count; 604 }605 606 610 for (idx = 0; idx < kcontrol->count; idx++) 607 611 snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_REMOVE, kcontrol, idx); … … 631 635 int snd_ctl_remove(struct snd_card *card, struct snd_kcontrol *kcontrol) 632 636 { 633 if (!kcontrol) 634 return 0; 635 guard(rwsem_write)(&card->controls_rwsem); 636 return snd_ctl_remove_locked(card, kcontrol); 637 int ret; 638 639 down_write(&card->controls_rwsem); 640 ret = snd_ctl_remove_locked(card, kcontrol); 641 up_write(&card->controls_rwsem); 642 return ret; 637 643 } 638 644 EXPORT_SYMBOL(snd_ctl_remove); … … 651 657 { 652 658 struct snd_kcontrol *kctl; 653 654 guard(rwsem_write)(&card->controls_rwsem); 659 int ret; 660 661 down_write(&card->controls_rwsem); 655 662 kctl = snd_ctl_find_id(card, id); 656 if (kctl == NULL) 663 if (kctl == NULL) { 664 up_write(&card->controls_rwsem); 657 665 return -ENOENT; 658 return snd_ctl_remove_locked(card, kctl); 666 } 667 ret = snd_ctl_remove_locked(card, kctl); 668 up_write(&card->controls_rwsem); 669 return ret; 659 670 } 660 671 EXPORT_SYMBOL(snd_ctl_remove_id); … … 675 686 struct snd_card *card = file->card; 676 687 struct snd_kcontrol *kctl; 677 int idx ;678 679 guard(rwsem_write)(&card->controls_rwsem);688 int idx, ret; 689 690 down_write(&card->controls_rwsem); 680 691 kctl = snd_ctl_find_id(card, id); 681 if (kctl == NULL) 682 return -ENOENT; 683 if (!(kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_USER)) 684 return -EINVAL; 692 if (kctl == NULL) { 693 ret = -ENOENT; 694 goto error; 695 } 696 if (!(kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_USER)) { 697 ret = -EINVAL; 698 goto error; 699 } 685 700 for (idx = 0; idx < kctl->count; idx++) 686 if (kctl->vd[idx].owner != NULL && kctl->vd[idx].owner != file) 687 return -EBUSY; 688 return snd_ctl_remove_locked(card, kctl); 701 if (kctl->vd[idx].owner != NULL && kctl->vd[idx].owner != file) { 702 ret = -EBUSY; 703 goto error; 704 } 705 ret = snd_ctl_remove_locked(card, kctl); 706 error: 707 up_write(&card->controls_rwsem); 708 return ret; 689 709 } 690 710 … … 763 783 int saved_numid; 764 784 765 guard(rwsem_write)(&card->controls_rwsem);785 down_write(&card->controls_rwsem); 766 786 kctl = snd_ctl_find_id(card, src_id); 767 if (kctl == NULL) 787 if (kctl == NULL) { 788 up_write(&card->controls_rwsem); 768 789 return -ENOENT; 790 } 769 791 saved_numid = kctl->id.numid; 770 792 remove_hash_entries(card, kctl); … … 772 794 kctl->id.numid = saved_numid; 773 795 add_hash_entries(card, kctl); 796 up_write(&card->controls_rwsem); 774 797 return 0; 775 798 } … … 789 812 const char *name) 790 813 { 791 guard(rwsem_write)(&card->controls_rwsem);814 down_write(&card->controls_rwsem); 792 815 remove_hash_entries(card, kctl); 793 816 … … 797 820 798 821 add_hash_entries(card, kctl); 822 up_write(&card->controls_rwsem); 799 823 } 800 824 EXPORT_SYMBOL(snd_ctl_rename); … … 806 830 struct snd_kcontrol *kctl; 807 831 808 guard(read_lock_irqsave)(&card->controls_rwlock);809 832 list_for_each_entry(kctl, &card->controls, list, struct snd_kcontrol) { 810 833 if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid) … … 869 892 #endif 870 893 /* no matching in hash table - try all as the last resort */ 871 guard(read_lock_irqsave)(&card->controls_rwlock);872 894 list_for_each_entry(kctl, &card->controls, list, struct snd_kcontrol) 873 895 if (elem_id_matches(kctl, id)) … … 885 907 if (! info) 886 908 return -ENOMEM; 887 scoped_guard(rwsem_read, &snd_ioctl_rwsem) {909 down_read(&snd_ioctl_rwsem); 888 910 info->card = card->number; 889 911 strscpy(info->id, card->id, sizeof(info->id)); … … 893 915 strscpy(info->mixername, card->mixername, sizeof(info->mixername)); 894 916 strscpy(info->components, card->components, sizeof(info->components)); 895 } 896 if (copy_to_user(arg, info, sizeof(struct snd_ctl_card_info))) 917 up_read(&snd_ioctl_rwsem); 918 if (copy_to_user(arg, info, sizeof(struct snd_ctl_card_info))) { 919 kfree(info); 897 920 return -EFAULT; 921 } 922 kfree(info); 898 923 return 0; 899 924 } … … 905 930 struct snd_ctl_elem_id id; 906 931 unsigned int offset, space, jidx; 932 int err = 0; 907 933 908 934 offset = list->offset; 909 935 space = list->space; 910 936 911 guard(rwsem_read)(&card->controls_rwsem);937 down_read(&card->controls_rwsem); 912 938 list->count = card->controls_count; 913 939 list->used = 0; 914 if (!space) 915 return 0; 940 if (space > 0) { 916 941 list_for_each_entry(kctl, &card->controls, list, struct snd_kcontrol) { 917 942 if (offset >= kctl->count) { … … 921 946 for (jidx = offset; jidx < kctl->count; jidx++) { 922 947 snd_ctl_build_ioff(&id, kctl, jidx); 923 if (copy_to_user(list->pids + list->used, &id, sizeof(id))) 924 return -EFAULT; 948 if (copy_to_user(list->pids + list->used, &id, 949 sizeof(id))) { 950 err = -EFAULT; 951 goto out; 952 } 925 953 list->used++; 926 954 if (!--space) 927 return 0;955 goto out; 928 956 } 929 957 offset = 0; 958 } 930 959 } 931 return 0; 960 out: 961 up_read(&card->controls_rwsem); 962 return err; 932 963 } 933 964 … … 1175 1206 struct snd_kcontrol *kctl; 1176 1207 1177 guard(rwsem_read)(&card->controls_rwsem); 1208 int result; 1209 1210 down_read(&card->controls_rwsem); 1178 1211 kctl = snd_ctl_find_id(card, &info->id); 1179 if (!kctl) 1180 return -ENOENT; 1181 return __snd_ctl_elem_info(card, kctl, info, ctl); 1212 if (kctl == NULL) 1213 result = -ENOENT; 1214 else 1215 result = __snd_ctl_elem_info(card, kctl, info, ctl); 1216 up_read(&card->controls_rwsem); 1217 return result; 1182 1218 } 1183 1219 … … 1216 1252 int ret; 1217 1253 1218 guard(rwsem_read)(&card->controls_rwsem);1254 down_read(&card->controls_rwsem); 1219 1255 kctl = snd_ctl_find_id(card, &control->id); 1220 if (!kctl) 1221 return -ENOENT; 1256 if (kctl == NULL) { 1257 ret = -ENOENT; 1258 goto unlock; 1259 } 1222 1260 1223 1261 index_offset = snd_ctl_get_ioff(kctl, &control->id); 1224 1262 vd = &kctl->vd[index_offset]; 1225 if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_READ) || !kctl->get) 1226 return -EPERM; 1263 if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_READ) || kctl->get == NULL) { 1264 ret = -EPERM; 1265 goto unlock; 1266 } 1227 1267 1228 1268 snd_ctl_build_ioff(&control->id, kctl, index_offset); … … 1234 1274 ret = __snd_ctl_elem_info(card, kctl, &info, NULL); 1235 1275 if (ret < 0) 1236 return ret;1276 goto unlock; 1237 1277 #endif 1238 1278 1239 1279 if (!snd_ctl_skip_validation(&info)) 1240 1280 fill_remaining_elem_value(control, &info, pattern); 1241 1281 ret = kctl->get(kctl, control); 1242 1282 if (ret < 0) 1243 return ret;1283 goto unlock; 1244 1284 if (!snd_ctl_skip_validation(&info) && 1245 1285 sanity_check_elem_value(card, control, &info, pattern) < 0) { … … 1249 1289 control->id.subdevice, control->id.name, 1250 1290 control->id.index); 1251 return -EINVAL; 1252 } 1253 return 0; 1291 ret = -EINVAL; 1292 goto unlock; 1293 } 1294 unlock: 1295 up_read(&card->controls_rwsem); 1296 return ret; 1254 1297 } 1255 1298 … … 1302 1345 snd_ctl_build_ioff(&control->id, kctl, index_offset); 1303 1346 /* validate input values */ 1347 #ifndef TARGET_OS2 1304 1348 if (IS_ENABLED(CONFIG_SND_CTL_INPUT_VALIDATION)) { 1305 1349 struct snd_ctl_elem_info info; … … 1312 1356 false); 1313 1357 } 1358 #endif 1314 1359 if (!result) 1315 1360 result = kctl->put(kctl, control); … … 1362 1407 struct snd_kcontrol *kctl; 1363 1408 struct snd_kcontrol_volatile *vd; 1409 int result; 1364 1410 1365 1411 if (copy_from_user(&id, _id, sizeof(id))) 1366 1412 return -EFAULT; 1367 guard(rwsem_write)(&card->controls_rwsem);1413 down_write(&card->controls_rwsem); 1368 1414 kctl = snd_ctl_find_id(card, &id); 1369 if (!kctl) 1370 return -ENOENT; 1415 if (kctl == NULL) { 1416 result = -ENOENT; 1417 } else { 1371 1418 vd = &kctl->vd[snd_ctl_get_ioff(kctl, &id)]; 1372 if (vd->owner) 1373 return -EBUSY; 1419 if (vd->owner != NULL) 1420 result = -EBUSY; 1421 else { 1374 1422 vd->owner = file; 1375 return 0; 1423 result = 0; 1424 } 1425 } 1426 up_write(&card->controls_rwsem); 1427 return result; 1376 1428 } 1377 1429 … … 1383 1435 struct snd_kcontrol *kctl; 1384 1436 struct snd_kcontrol_volatile *vd; 1437 int result; 1385 1438 1386 1439 if (copy_from_user(&id, _id, sizeof(id))) 1387 1440 return -EFAULT; 1388 guard(rwsem_write)(&card->controls_rwsem);1441 down_write(&card->controls_rwsem); 1389 1442 kctl = snd_ctl_find_id(card, &id); 1390 if (!kctl) 1391 return -ENOENT; 1443 if (kctl == NULL) { 1444 result = -ENOENT; 1445 } else { 1392 1446 vd = &kctl->vd[snd_ctl_get_ioff(kctl, &id)]; 1393 if (!vd->owner) 1394 return -EINVAL; 1395 if (vd->owner != file) 1396 return -EPERM; 1447 if (vd->owner == NULL) 1448 result = -EINVAL; 1449 else if (vd->owner != file) 1450 result = -EPERM; 1451 else { 1397 1452 vd->owner = NULL; 1398 return 0; 1453 result = 0; 1454 } 1455 } 1456 up_write(&card->controls_rwsem); 1457 return result; 1399 1458 } 1400 1459 … … 1677 1736 err = snd_ctl_check_elem_info(NULL, info); 1678 1737 if (err < 0) 1679 return err;1738 goto unlock; 1680 1739 /* user-space control doesn't allow zero-size data */ 1681 1740 if (info->count < 1) … … 1684 1743 alloc_size = compute_user_elem_size(private_size, count); 1685 1744 1686 guard(rwsem_write)(&card->controls_rwsem); 1687 if (check_user_elem_overflow(card, alloc_size)) 1688 return -ENOMEM; 1745 down_write(&card->controls_rwsem); 1746 if (check_user_elem_overflow(card, alloc_size)) { 1747 err = -ENOMEM; 1748 goto unlock; 1749 } 1689 1750 1690 1751 /* … … 1696 1757 err = snd_ctl_new(&kctl, count, access, file); 1697 1758 if (err < 0) 1698 return err;1759 goto unlock; 1699 1760 memcpy(&kctl->id, &info->id, sizeof(kctl->id)); 1700 1761 ue = kzalloc(alloc_size, GFP_KERNEL); 1701 1762 if (!ue) { 1702 1763 kfree(kctl); 1703 return -ENOMEM; 1764 err = -ENOMEM; 1765 goto unlock; 1704 1766 } 1705 1767 kctl->private_data = ue; … … 1719 1781 if (err < 0) { 1720 1782 snd_ctl_free_one(kctl); 1721 return err;1783 goto unlock; 1722 1784 } 1723 1785 } … … 1739 1801 if (err < 0) { 1740 1802 snd_ctl_free_one(kctl); 1741 return err;1803 goto unlock; 1742 1804 } 1743 1805 offset = snd_ctl_get_ioff(kctl, &info->id); … … 1750 1812 * which locks the element. 1751 1813 */ 1752 return 0; 1814 unlock: 1815 up_write(&card->controls_rwsem); 1816 return err; 1753 1817 } 1754 1818 … … 1951 2015 if (err < 0) 1952 2016 return err; 1953 scoped_guard(rwsem_read, &card->controls_rwsem)2017 down_read(&ctl->card->controls_rwsem); 1954 2018 err = snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_READ); 2019 up_read(&ctl->card->controls_rwsem); 1955 2020 snd_power_unref(card); 1956 2021 return err; … … 1959 2024 if (err < 0) 1960 2025 return err; 1961 scoped_guard(rwsem_write, &card->controls_rwsem)2026 down_write(&ctl->card->controls_rwsem); 1962 2027 err = snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_WRITE); 2028 up_write(&ctl->card->controls_rwsem); 2029 case SNDRV_CTL_IOCTL_TLV_COMMAND: 1963 2030 snd_power_unref(card); 1964 2031 return err; 1965 case SNDRV_CTL_IOCTL_TLV_COMMAND:1966 2032 err = snd_power_ref_and_wait(card); 1967 2033 if (err < 0) 1968 2034 return err; 1969 scoped_guard(rwsem_write, &card->controls_rwsem)2035 down_write(&ctl->card->controls_rwsem); 1970 2036 err = snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_CMD); 2037 up_write(&ctl->card->controls_rwsem); 1971 2038 snd_power_unref(card); 1972 2039 return err; … … 1976 2043 return put_user(SNDRV_CTL_POWER_D0, ip) ? -EFAULT : 0; 1977 2044 } 1978 1979 guard(rwsem_read)(&snd_ioctl_rwsem); 2045 down_read(&snd_ioctl_rwsem); 2046 1980 2047 list_for_each_entry(p, &snd_control_ioctls, list, struct snd_kctl_ioctl) { 1981 2048 err = p->fioctl(card, ctl, cmd, arg); 1982 if (err != -ENOIOCTLCMD) 2049 if (err != -ENOIOCTLCMD) { 2050 up_read(&snd_ioctl_rwsem); 1983 2051 return err; 1984 } 2052 } 2053 } 2054 up_read(&snd_ioctl_rwsem); 1985 2055 dev_dbg(card->dev, "unknown ioctl = 0x%x\n", cmd); 1986 2056 return -ENOTTY; … … 2074 2144 return -ENOMEM; 2075 2145 pn->fioctl = fcn; 2076 guard(rwsem_write)(&snd_ioctl_rwsem);2146 down_write(&snd_ioctl_rwsem); 2077 2147 list_add_tail(&pn->list, lists); 2148 up_write(&snd_ioctl_rwsem); 2078 2149 return 0; 2079 2150 } … … 2118 2189 if (snd_BUG_ON(!fcn)) 2119 2190 return -EINVAL; 2120 guard(rwsem_write)(&snd_ioctl_rwsem);2191 down_write(&snd_ioctl_rwsem); 2121 2192 list_for_each_entry(p, lists, list, struct snd_kctl_ioctl) { 2122 2193 if (p->fioctl == fcn) { … … 2127 2198 } 2128 2199 } 2200 up_write(&snd_ioctl_rwsem); 2129 2201 snd_BUG(); 2130 2202 return -EINVAL; … … 2173 2245 struct snd_ctl_file *kctl; 2174 2246 int subdevice = -1; 2175 2176 guard(read_lock_irqsave)(&card->controls_rwlock); 2247 unsigned long flags; 2248 2249 read_lock_irqsave(&card->controls_rwlock, flags); 2177 2250 list_for_each_entry(kctl, &card->ctl_files, list, struct snd_ctl_file) { 2178 2251 if (kctl->pid == task_pid(current)) { … … 2182 2255 } 2183 2256 } 2257 read_unlock_irqrestore(&card->controls_rwlock, flags); 2184 2258 return subdevice; 2185 2259 } … … 2211 2285 if (module_name == NULL) 2212 2286 return 0; 2213 scoped_guard(rwsem_read, &snd_ctl_layer_rwsem) {2287 down_read(&snd_ctl_layer_rwsem); 2214 2288 for (lops = snd_ctl_layer; lops; lops = lops->next) 2215 2289 if (strcmp(lops->module_name, module_name) == 0) 2290 break; 2291 up_read(&snd_ctl_layer_rwsem); 2292 if (lops) 2216 2293 return 0; 2217 }2218 2294 return request_module(module_name); 2219 2295 } … … 2232 2308 int card_number; 2233 2309 2234 scoped_guard(rwsem_write, &snd_ctl_layer_rwsem) {2310 down_write(&snd_ctl_layer_rwsem); 2235 2311 lops->next = snd_ctl_layer; 2236 2312 snd_ctl_layer = lops; 2237 }2313 up_write(&snd_ctl_layer_rwsem); 2238 2314 for (card_number = 0; card_number < SNDRV_CARDS; card_number++) { 2239 2315 card = snd_card_ref(card_number); 2240 2316 if (card) { 2241 scoped_guard(rwsem_read, &card->controls_rwsem)2317 down_read(&card->controls_rwsem); 2242 2318 lops->lregister(card); 2319 up_read(&card->controls_rwsem); 2243 2320 snd_card_unref(card); 2244 2321 } … … 2259 2336 struct snd_ctl_layer_ops *lops2, *prev_lops2; 2260 2337 2261 guard(rwsem_write)(&snd_ctl_layer_rwsem);2338 down_write(&snd_ctl_layer_rwsem); 2262 2339 for (lops2 = snd_ctl_layer, prev_lops2 = NULL; lops2; lops2 = lops2->next) { 2263 2340 if (lops2 == lops) { … … 2270 2347 prev_lops2 = lops2; 2271 2348 } 2349 up_write(&snd_ctl_layer_rwsem); 2272 2350 } 2273 2351 EXPORT_SYMBOL_GPL(snd_ctl_disconnect_layer); … … 2289 2367 }; 2290 2368 2369 #ifndef TARGET_OS2 2291 2370 /* call lops under rwsems; called from snd_ctl_dev_*() below() */ 2292 2371 #define call_snd_ctl_lops(_card, _op) \ … … 2298 2377 lops->_op(_card); \ 2299 2378 } while (0) 2379 #endif 2300 2380 2301 2381 /* … … 2305 2385 { 2306 2386 struct snd_card *card = device->device_data; 2387 struct snd_ctl_layer_ops *lops; 2307 2388 int err; 2308 2389 … … 2311 2392 if (err < 0) 2312 2393 return err; 2313 call_snd_ctl_lops(card, lregister); 2394 down_read(&card->controls_rwsem); 2395 down_read(&snd_ctl_layer_rwsem); 2396 for (lops = snd_ctl_layer; lops; lops = lops->next) 2397 lops->lregister(card); 2398 up_read(&snd_ctl_layer_rwsem); 2399 up_read(&card->controls_rwsem); 2314 2400 return 0; 2315 2401 } … … 2322 2408 struct snd_card *card = device->device_data; 2323 2409 struct snd_ctl_file *ctl; 2324 2325 scoped_guard(read_lock_irqsave, &card->controls_rwlock) { 2410 struct snd_ctl_layer_ops *lops; 2411 unsigned long flags; 2412 2413 read_lock_irqsave(&card->controls_rwlock, flags); 2326 2414 list_for_each_entry(ctl, &card->ctl_files, list, struct snd_ctl_file) { 2327 2415 wake_up(&ctl->change_sleep); 2328 2416 snd_kill_fasync(ctl->fasync, SIGIO, POLL_ERR); 2329 2417 } 2330 } 2331 2332 call_snd_ctl_lops(card, ldisconnect); 2418 read_unlock_irqrestore(&card->controls_rwlock, flags); 2419 2420 down_read(&card->controls_rwsem); 2421 down_read(&snd_ctl_layer_rwsem); 2422 for (lops = snd_ctl_layer; lops; lops = lops->next) 2423 lops->ldisconnect(card); 2424 up_read(&snd_ctl_layer_rwsem); 2425 up_read(&card->controls_rwsem); 2333 2426 return snd_unregister_device(card->ctl_dev); 2334 2427 } … … 2342 2435 struct snd_kcontrol *control; 2343 2436 2344 scoped_guard(rwsem_write, &card->controls_rwsem) {2437 down_write(&card->controls_rwsem); 2345 2438 while (!list_empty(&card->controls)) { 2346 2439 control = snd_kcontrol(card->controls.next); … … 2352 2445 xa_destroy(&card->ctl_hash); 2353 2446 #endif 2354 }2447 up_write(&card->controls_rwsem); 2355 2448 put_device(card->ctl_dev); 2356 2449 return 0; -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/hwdep.c ¶
r766 r767 150 150 struct module *mod = hw->card->module; 151 151 152 scoped_guard(mutex, &hw->open_mutex) {152 mutex_lock(&hw->open_mutex); 153 153 if (hw->ops.release) 154 154 err = hw->ops.release(hw, file); 155 155 if (hw->used > 0) 156 156 hw->used--; 157 }157 mutex_unlock(&hw->open_mutex); 158 158 wake_up(&hw->open_wait); 159 159 … … 273 273 if (get_user(device, (int __user *)arg)) 274 274 return -EFAULT; 275 276 scoped_guard(mutex, ®ister_mutex) { 275 mutex_lock(®ister_mutex); 276 277 277 if (device < 0) 278 278 device = 0; … … 289 289 if (device >= SNDRV_MINOR_HWDEPS) 290 290 device = -1; 291 }291 mutex_unlock(®ister_mutex); 292 292 if (put_user(device, (int __user *)arg)) 293 293 return -EFAULT; … … 297 297 { 298 298 struct snd_hwdep_info __user *info = (struct snd_hwdep_info __user *)arg; 299 int device ;299 int device, err; 300 300 struct snd_hwdep *hwdep; 301 301 302 302 if (get_user(device, &info->device)) 303 303 return -EFAULT; 304 scoped_guard(mutex, ®ister_mutex) {304 mutex_lock(®ister_mutex); 305 305 hwdep = snd_hwdep_search(card, device); 306 if (!hwdep) 307 return -ENXIO; 308 return snd_hwdep_info(hwdep, info); 309 } 310 break; 306 if (hwdep) 307 err = snd_hwdep_info(hwdep, info); 308 else 309 err = -ENXIO; 310 mutex_unlock(®ister_mutex); 311 return err; 311 312 } 312 313 } … … 422 423 int err; 423 424 424 guard(mutex)(®ister_mutex); 425 if (snd_hwdep_search(card, hwdep->device)) 425 mutex_lock(®ister_mutex); 426 if (snd_hwdep_search(card, hwdep->device)) { 427 mutex_unlock(®ister_mutex); 426 428 return -EBUSY; 429 } 427 430 list_add_tail(&hwdep->list, &snd_hwdep_devices); 428 431 err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP, … … 432 435 dev_err(hwdep->dev, "unable to register\n"); 433 436 list_del(&hwdep->list); 437 mutex_unlock(®ister_mutex); 434 438 return err; 435 439 } … … 451 455 } 452 456 #endif 457 mutex_unlock(®ister_mutex); 453 458 return 0; 454 459 } … … 460 465 if (snd_BUG_ON(!hwdep)) 461 466 return -ENXIO; 462 guard(mutex)(®ister_mutex); 463 if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) 467 mutex_lock(®ister_mutex); 468 if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) { 469 mutex_unlock(®ister_mutex); 464 470 return -EINVAL; 465 guard(mutex)(&hwdep->open_mutex); 471 } 472 mutex_lock(&hwdep->open_mutex); 466 473 wake_up(&hwdep->open_wait); 467 474 #ifdef CONFIG_SND_OSSEMUL … … 471 478 snd_unregister_device(hwdep->dev); 472 479 list_del_init(&hwdep->list); 480 mutex_unlock(&hwdep->open_mutex); 481 mutex_unlock(®ister_mutex); 473 482 return 0; 474 483 } … … 484 493 struct snd_hwdep *hwdep; 485 494 486 guard(mutex)(®ister_mutex);495 mutex_lock(®ister_mutex); 487 496 list_for_each_entry(hwdep, &snd_hwdep_devices, list, struct snd_hwdep) 488 497 snd_iprintf(buffer, "%02i-%02i: %s\n", 489 498 hwdep->card->number, hwdep->device, hwdep->name); 499 mutex_unlock(®ister_mutex); 490 500 } 491 501 -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/info.c ¶
r766 r767 107 107 struct snd_info_private_data *data; 108 108 struct snd_info_entry *entry; 109 loff_t size;109 loff_t ret = -EINVAL, size; 110 110 111 111 data = file->private_data; 112 112 entry = data->entry; 113 guard(mutex)(&entry->access);114 if (entry->c.ops->llseek) 115 ret urnentry->c.ops->llseek(entry,113 mutex_lock(&entry->access); 114 if (entry->c.ops->llseek) { 115 ret = entry->c.ops->llseek(entry, 116 116 data->file_private_data, 117 117 file, offset, orig); 118 goto out; 119 } 118 120 119 121 size = entry->size; … … 126 128 case SEEK_END: 127 129 if (!size) 128 return -EINVAL;130 goto out; 129 131 offset += size; 130 132 break; 131 133 default: 132 return -EINVAL;134 goto out; 133 135 } 134 136 if (offset < 0) 135 return -EINVAL;137 goto out; 136 138 if (size && offset > size) 137 139 offset = size; 138 140 file->f_pos = offset; 139 return offset; 141 ret = offset; 142 out: 143 mutex_unlock(&entry->access); 144 return ret; 140 145 } 141 146 … … 235 240 int mode, err; 236 241 237 guard(mutex)(&info_mutex);242 mutex_lock(&info_mutex); 238 243 err = alloc_info_private(entry, &data); 239 244 if (err < 0) 240 return err;245 goto unlock; 241 246 242 247 mode = file->f_flags & O_ACCMODE; … … 254 259 255 260 file->private_data = data; 261 mutex_unlock(&info_mutex); 256 262 return 0; 257 263 … … 259 265 kfree(data); 260 266 module_put(entry->module); 267 unlock: 268 mutex_unlock(&info_mutex); 261 269 return err; 262 270 } … … 300 308 loff_t pos; 301 309 size_t next; 310 int err = 0; 302 311 303 312 if (!entry->c.text.write) … … 310 319 if (next > 16 * 1024) 311 320 return -EIO; 312 guard(mutex)(&entry->access);321 mutex_lock(&entry->access); 313 322 buf = data->wbuffer; 314 323 if (!buf) { 315 324 data->wbuffer = buf = kzalloc(sizeof(*buf), GFP_KERNEL); 316 if (!buf) 317 return -ENOMEM; 325 if (!buf) { 326 err = -ENOMEM; 327 goto error; 328 } 318 329 } 319 330 if (next > buf->len) { … … 325 336 buf->len = PAGE_ALIGN(next); 326 337 } 327 if (copy_from_user(buf->buffer + pos, buffer, count)) 328 return -EFAULT; 338 if (copy_from_user(buf->buffer + pos, buffer, count)) { 339 err = -EFAULT; 340 goto error; 341 } 329 342 buf->size = next; 343 error: 344 mutex_unlock(&entry->access); 345 if (err < 0) 346 return err; 330 347 *offset = next; 331 348 return count; … … 352 369 int err; 353 370 354 guard(mutex)(&info_mutex);371 mutex_lock(&info_mutex); 355 372 err = alloc_info_private(entry, &data); 356 373 if (err < 0) 357 return err;374 goto unlock; 358 375 359 376 data->rbuffer = kzalloc(sizeof(*data->rbuffer), GFP_KERNEL); … … 369 386 if (err < 0) 370 387 goto error; 388 mutex_unlock(&info_mutex); 371 389 return 0; 372 390 … … 375 393 kfree(data); 376 394 module_put(entry->module); 395 unlock: 396 mutex_unlock(&info_mutex); 377 397 return err; 378 398 } … … 530 550 void snd_info_card_id_change(struct snd_card *card) 531 551 { 532 guard(mutex)(&info_mutex);552 mutex_lock(&info_mutex); 533 553 if (card->proc_root_link) { 534 554 proc_remove(card->proc_root_link); … … 539 559 snd_proc_root->p, 540 560 card->proc_root->name); 561 mutex_unlock(&info_mutex); 541 562 } 542 563 … … 554 575 proc_remove(card->proc_root->p); 555 576 556 guard(mutex)(&info_mutex);577 mutex_lock(&info_mutex); 557 578 if (card->proc_root) 558 579 snd_info_clear_entries(card->proc_root); 559 580 card->proc_root_link = NULL; 560 581 card->proc_root = NULL; 582 mutex_unlock(&info_mutex); 561 583 } 562 584 … … 682 704 entry->module = module; 683 705 if (parent) { 684 guard(mutex)(&parent->access);706 mutex_lock(&parent->access); 685 707 list_add_tail(&entry->list, &parent->children); 708 mutex_unlock(&parent->access); 686 709 } 687 710 return entry; … … 753 776 if (entry->p) { 754 777 proc_remove(entry->p); 755 guard(mutex)(&info_mutex);778 mutex_lock(&info_mutex); 756 779 snd_info_clear_entries(entry); 780 mutex_unlock(&info_mutex); 757 781 } 758 782 … … 763 787 p = entry->parent; 764 788 if (p) { 765 guard(mutex)(&p->access);789 mutex_lock(&p->access); 766 790 list_del(&entry->list); 791 mutex_unlock(&p->access); 767 792 } 768 793 kfree(entry->name); … … 780 805 return -ENXIO; 781 806 root = entry->parent == NULL ? snd_proc_root->p : entry->parent->p; 782 guard(mutex)(&info_mutex);807 mutex_lock(&info_mutex); 783 808 if (entry->p || !root) 784 return 0;809 goto unlock; 785 810 #ifndef TARGET_OS2 786 811 if (S_ISDIR(entry->mode)) { … … 802 827 #endif 803 828 entry->p = p; 829 unlock: 830 mutex_unlock(&info_mutex); 804 831 return 0; 805 832 } -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/info_oss.c ¶
r766 r767 30 30 if (snd_BUG_ON(num < 0 || num >= SNDRV_CARDS)) 31 31 return -ENXIO; 32 guard(mutex)(&strings);32 mutex_lock(&strings); 33 33 if (string == NULL) { 34 34 x = snd_sndstat_strings[num][dev]; … … 37 37 } else { 38 38 x = kstrdup(string, GFP_KERNEL); 39 if (x == NULL) 39 if (x == NULL) { 40 mutex_unlock(&strings); 40 41 return -ENOMEM; 41 42 } 43 } 42 44 snd_sndstat_strings[num][dev] = x; 45 mutex_unlock(&strings); 43 46 return 0; 44 47 } … … 51 54 52 55 snd_iprintf(buf, "\n%s:", id); 53 guard(mutex)(&strings);56 mutex_lock(&strings); 54 57 for (idx = 0; idx < SNDRV_CARDS; idx++) { 55 58 str = snd_sndstat_strings[idx][dev]; … … 62 65 } 63 66 } 67 mutex_unlock(&strings); 64 68 if (ok < 0) 65 69 snd_iprintf(buf, " NOT ENABLED IN CONFIG\n"); -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/init.c ¶
r766 r767 289 289 strscpy(card->id, xid, sizeof(card->id)); 290 290 err = 0; 291 scoped_guard(mutex, &snd_card_mutex) {291 mutex_lock(&snd_card_mutex); 292 292 if (idx < 0) /* first check the matching module-name slot */ 293 293 idx = get_slot_from_bitmask(idx, module_slot_match, module); … … 301 301 } else if (idx >= SNDRV_CARDS) 302 302 err = -ENODEV; 303 if (!err) {304 set_bit(idx, snd_cards_lock); /* lock it */305 if (idx >= snd_ecards_limit)306 snd_ecards_limit = idx + 1; /* increase the limit */307 }308 }309 303 if (err < 0) { 304 mutex_unlock(&snd_card_mutex); 310 305 dev_err(parent, "cannot find the slot for index %d (range 0-%i), error: %d\n", 311 306 idx, snd_ecards_limit - 1, err); … … 314 309 return err; 315 310 } 311 set_bit(idx, snd_cards_lock); /* lock it */ 312 if (idx >= snd_ecards_limit) 313 snd_ecards_limit = idx + 1; /* increase the limit */ 314 mutex_unlock(&snd_card_mutex); 316 315 card->dev = parent; 317 316 card->number = idx; … … 390 389 struct snd_card *card; 391 390 392 guard(mutex)(&snd_card_mutex);391 mutex_lock(&snd_card_mutex); 393 392 card = snd_cards[idx]; 394 393 if (card) 395 394 get_device(&card->card_dev); 395 mutex_unlock(&snd_card_mutex); 396 396 return card; 397 397 } … … 401 401 int snd_card_locked(int card) 402 402 { 403 guard(mutex)(&snd_card_mutex); 404 return test_bit(card, snd_cards_lock); 403 int locked; 404 405 mutex_lock(&snd_card_mutex); 406 locked = test_bit(card, snd_cards_lock); 407 mutex_unlock(&snd_card_mutex); 408 return locked; 405 409 } 406 410 … … 426 430 struct snd_monitor_file *df = NULL, *_df; 427 431 428 s coped_guard(spinlock, &shutdown_lock) {432 spin_lock(&shutdown_lock); 429 433 list_for_each_entry(_df, &shutdown_files, shutdown_list, struct snd_monitor_file) { 430 434 if (_df->file == file) { … … 434 438 } 435 439 } 436 }440 spin_unlock(&shutdown_lock); 437 441 438 442 if (likely(df)) { … … 503 507 return; 504 508 505 scoped_guard(spinlock, &card->files_lock) { 506 if (card->shutdown) 509 spin_lock(&card->files_lock); 510 if (card->shutdown) { 511 spin_unlock(&card->files_lock); 507 512 return; 513 } 508 514 card->shutdown = 1; 509 515 … … 514 520 mfile->disconnected_f_op = mfile->file->f_op; 515 521 516 scoped_guard(spinlock, &shutdown_lock)522 spin_lock(&shutdown_lock); 517 523 list_add(&mfile->shutdown_list, &shutdown_files); 524 spin_unlock(&shutdown_lock); 518 525 519 526 mfile->file->f_op = &snd_shutdown_f_ops; 520 527 //DAZ this does nothing. fops_get(mfile->file->f_op); 521 528 } 522 }529 spin_unlock(&card->files_lock); 523 530 524 531 #ifdef CONFIG_PM … … 556 563 557 564 /* disable fops (user space) operations for ALSA API */ 558 scoped_guard(mutex, &snd_card_mutex) {565 mutex_lock(&snd_card_mutex); 559 566 snd_cards[card->number] = NULL; 560 567 clear_bit(card->number, snd_cards_lock); 561 }568 mutex_unlock(&snd_card_mutex); 562 569 563 570 snd_power_sync_ref(card); … … 578 585 snd_card_disconnect(card); 579 586 580 guard(spinlock_irq)(&card->files_lock);587 spin_lock_irq(&card->files_lock); 581 588 wait_event_lock_irq(card->remove_sleep, 582 589 list_empty(&card->files_list), 583 590 card->files_lock); 591 spin_unlock_irq(&card->files_lock); 584 592 } 585 593 EXPORT_SYMBOL_GPL(snd_card_disconnect_sync); … … 777 785 if (card->id[0] != '\0') 778 786 return; 779 guard(mutex)(&snd_card_mutex);787 mutex_lock(&snd_card_mutex); 780 788 snd_card_set_id_no_lock(card, nid, nid); 789 mutex_unlock(&snd_card_mutex); 781 790 } 782 791 EXPORT_SYMBOL(snd_card_set_id); … … 807 816 memcpy(buf1, buf, copy); 808 817 buf1[copy] = '\0'; 809 guard(mutex)(&snd_card_mutex); 810 if (!card_id_ok(NULL, buf1)) 818 mutex_lock(&snd_card_mutex); 819 if (!card_id_ok(NULL, buf1)) { 820 mutex_unlock(&snd_card_mutex); 811 821 return -EEXIST; 822 } 812 823 strcpy(card->id, buf1); 813 824 snd_info_card_id_change(card); 825 mutex_unlock(&snd_card_mutex); 814 826 815 827 return count; … … 905 917 if (err < 0) 906 918 return err; 907 scoped_guard(mutex, &snd_card_mutex) {919 mutex_lock(&snd_card_mutex); 908 920 if (snd_cards[card->number]) { 909 921 /* already registered */ 922 mutex_unlock(&snd_card_mutex); 910 923 return snd_info_card_register(card); /* register pending info */ 911 924 } … … 913 926 /* make a unique id name from the given string */ 914 927 char tmpid[sizeof(card->id)]; 915 916 928 memcpy(tmpid, card->id, sizeof(card->id)); 917 929 snd_card_set_id_no_lock(card, tmpid, tmpid); … … 919 931 /* create an id from either shortname or longname */ 920 932 const char *src; 921 922 933 src = *card->shortname ? card->shortname : card->longname; 923 934 snd_card_set_id_no_lock(card, src, … … 925 936 } 926 937 snd_cards[card->number] = card; 927 }938 mutex_unlock(&snd_card_mutex); 928 939 err = snd_info_card_register(card); 929 940 if (err < 0) … … 946 957 947 958 for (idx = count = 0; idx < SNDRV_CARDS; idx++) { 948 guard(mutex)(&snd_card_mutex);959 mutex_lock(&snd_card_mutex); 949 960 card = snd_cards[idx]; 950 961 if (card) { … … 958 969 card->longname); 959 970 } 971 mutex_unlock(&snd_card_mutex); 960 972 } 961 973 if (!count) … … 970 982 971 983 for (idx = count = 0; idx < SNDRV_CARDS; idx++) { 972 guard(mutex)(&snd_card_mutex);984 mutex_lock(&snd_card_mutex); 973 985 card = snd_cards[idx]; 974 986 if (card) { … … 976 988 snd_iprintf(buffer, "%s\n", card->longname); 977 989 } 990 mutex_unlock(&snd_card_mutex); 978 991 } 979 992 if (!count) { … … 992 1005 993 1006 for (idx = 0; idx < SNDRV_CARDS; idx++) { 994 guard(mutex)(&snd_card_mutex);1007 mutex_lock(&snd_card_mutex); 995 1008 card = snd_cards[idx]; 996 1009 if (card) 997 1010 snd_iprintf(buffer, "%2i %s\n", 998 1011 idx, card->module->name); 1012 mutex_unlock(&snd_card_mutex); 999 1013 } 1000 1014 } … … 1078 1092 mfile->disconnected_f_op = NULL; 1079 1093 INIT_LIST_HEAD(&mfile->shutdown_list); 1080 guard(spinlock)(&card->files_lock);1094 spin_lock(&card->files_lock); 1081 1095 if (card->shutdown) { 1096 spin_unlock(&card->files_lock); 1082 1097 kfree(mfile); 1083 1098 return -ENODEV; … … 1106 1121 struct snd_monitor_file *mfile, *found = NULL; 1107 1122 1108 s coped_guard(spinlock, &card->files_lock) {1123 spin_lock(&card->files_lock); 1109 1124 list_for_each_entry(mfile, &card->files_list, list, struct snd_monitor_file) { 1110 1125 if (mfile->file == file) { 1111 1126 list_del(&mfile->list); 1112 scoped_guard(spinlock, &shutdown_lock)1127 spin_lock(&shutdown_lock); 1113 1128 list_del(&mfile->shutdown_list); 1129 spin_unlock(&shutdown_lock); 1114 1130 if (mfile->disconnected_f_op) 1115 1131 fops_put(mfile->disconnected_f_op); 1116 1132 found = mfile; 1117 1133 break; 1118 }1134 } 1119 1135 } 1120 1136 if (list_empty(&card->files_list)) 1121 1137 wake_up_all(&card->remove_sleep); 1122 }1138 spin_unlock(&card->files_lock); 1123 1139 if (!found) { 1124 1140 dev_err(card->dev, "card file remove problem (%p)\n", file); -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/oss/pcm_oss.c ¶
r766 r767 1637 1637 result = 0; 1638 1638 set_current_state(TASK_INTERRUPTIBLE); 1639 s coped_guard(pcm_stream_lock_irq, substream)1639 snd_pcm_stream_lock_irq(substream); 1640 1640 state = runtime->state; 1641 snd_pcm_stream_unlock_irq(substream); 1641 1642 if (state != SNDRV_PCM_STATE_RUNNING) { 1642 1643 set_current_state(TASK_RUNNING); … … 2347 2348 struct snd_pcm_oss_setup *setup; 2348 2349 2349 guard(mutex)(&pcm->streams[stream].oss.setup_mutex);2350 mutex_lock(&pcm->streams[stream].oss.setup_mutex); 2350 2351 do { 2351 2352 for (setup = pcm->streams[stream].oss.setup_list; setup; … … 2358 2359 if (setup) 2359 2360 *rsetup = *setup; 2361 mutex_unlock(&pcm->streams[stream].oss.setup_mutex); 2360 2362 } 2361 2363 … … 2852 2854 struct snd_pcm_runtime *runtime = psubstream->runtime; 2853 2855 poll_wait(file, &runtime->sleep, wait); 2854 s coped_guard(pcm_stream_lock_irq, psubstream) {2856 snd_pcm_stream_lock_irq(psubstream); 2855 2857 if (runtime->state != SNDRV_PCM_STATE_DRAINING && 2856 2858 (runtime->state != SNDRV_PCM_STATE_RUNNING || 2857 2859 snd_pcm_oss_playback_ready(psubstream))) 2858 2860 mask |= EPOLLOUT | EPOLLWRNORM; 2859 }2861 snd_pcm_stream_unlock_irq(psubstream); 2860 2862 } 2861 2863 if (csubstream != NULL) { … … 2863 2865 snd_pcm_state_t ostate; 2864 2866 poll_wait(file, &runtime->sleep, wait); 2865 s coped_guard(pcm_stream_lock_irq, csubstream) {2867 snd_pcm_stream_lock_irq(csubstream); 2866 2868 ostate = runtime->state; 2867 2869 if (ostate != SNDRV_PCM_STATE_RUNNING || 2868 2870 snd_pcm_oss_capture_ready(csubstream)) 2869 2871 mask |= EPOLLIN | EPOLLRDNORM; 2870 }2872 snd_pcm_stream_unlock_irq(csubstream); 2871 2873 if (ostate != SNDRV_PCM_STATE_RUNNING && runtime->oss.trigger) { 2872 2874 struct snd_pcm_oss_file ofile; … … 2965 2967 struct snd_pcm_str *pstr = entry->private_data; 2966 2968 struct snd_pcm_oss_setup *setup = pstr->oss.setup_list; 2967 guard(mutex)(&pstr->oss.setup_mutex);2969 mutex_lock(&pstr->oss.setup_mutex); 2968 2970 while (setup) { 2969 2971 snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n", … … 2979 2981 setup = setup->next; 2980 2982 } 2983 mutex_unlock(&pstr->oss.setup_mutex); 2981 2984 } 2982 2985 … … 3004 3007 3005 3008 while (!snd_info_get_line(buffer, line, sizeof(line))) { 3006 guard(mutex)(&pstr->oss.setup_mutex);3009 mutex_lock(&pstr->oss.setup_mutex); 3007 3010 memset(&template, 0, sizeof(template)); 3008 3011 ptr = snd_info_get_str(task_name, line, sizeof(task_name)); 3009 3012 if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) { 3010 3013 snd_pcm_oss_proc_free_setup_list(pstr); 3014 mutex_unlock(&pstr->oss.setup_mutex); 3011 3015 continue; 3012 3016 } … … 3048 3052 if (! setup) { 3049 3053 buffer->error = -ENOMEM; 3054 mutex_unlock(&pstr->oss.setup_mutex); 3050 3055 return; 3051 3056 } … … 3065 3070 } 3066 3071 *setup = template; 3072 mutex_unlock(&pstr->oss.setup_mutex); 3067 3073 } 3068 3074 } -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/pcm.c ¶
r766 r767 95 95 if (get_user(device, (int __user *)arg)) 96 96 return -EFAULT; 97 scoped_guard(mutex, ®ister_mutex)97 mutex_lock(®ister_mutex); 98 98 device = snd_pcm_next(card, device); 99 mutex_unlock(®ister_mutex); 99 100 if (put_user(device, (int __user *)arg)) 100 101 return -EFAULT; … … 109 110 struct snd_pcm_str *pstr; 110 111 struct snd_pcm_substream *substream; 112 int err; 111 113 112 114 info = (struct snd_pcm_info __user *)arg; … … 120 122 if (get_user(subdevice, &info->subdevice)) 121 123 return -EFAULT; 122 guard(mutex)(®ister_mutex);124 mutex_lock(®ister_mutex); 123 125 pcm = snd_pcm_get(card, device); 124 if (pcm == NULL) 125 return -ENXIO; 126 pstr = &pcm->streams[stream]; 127 if (pstr->substream_count == 0) 128 return -ENOENT; 129 if (subdevice >= pstr->substream_count) 130 return -ENXIO; 126 if (pcm == NULL) { 127 err = -ENXIO; 128 goto _error; 129 } 130 if (pstr->substream_count == 0) { 131 err = -ENOENT; 132 goto _error; 133 } 134 if (subdevice >= pstr->substream_count) { 135 err = -ENXIO; 136 goto _error; 137 } 131 138 for (substream = pstr->substream; substream; 132 139 substream = substream->next) 133 140 if (substream->number == (int)subdevice) 134 141 break; 135 if (substream == NULL) 136 return -ENXIO; 137 guard(mutex)(&pcm->open_mutex); 138 return snd_pcm_info_user(substream, info); 142 if (substream == NULL) { 143 err = -ENXIO; 144 goto _error; 145 } 146 mutex_lock(&pcm->open_mutex); 147 err = snd_pcm_info_user(substream, info); 148 mutex_unlock(&pcm->open_mutex); 149 _error: 150 mutex_unlock(®ister_mutex); 151 return err; 139 152 } 140 153 case SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE: … … 379 392 struct snd_pcm_runtime *runtime; 380 393 381 guard(mutex)(&substream->pcm->open_mutex);394 mutex_lock(&substream->pcm->open_mutex); 382 395 runtime = substream->runtime; 383 396 if (!runtime) { 384 397 snd_iprintf(buffer, "closed\n"); 385 return;398 goto unlock; 386 399 } 387 400 if (runtime->state == SNDRV_PCM_STATE_OPEN) { 388 401 snd_iprintf(buffer, "no setup\n"); 389 return;402 goto unlock; 390 403 } 391 404 snd_iprintf(buffer, "access: %s\n", snd_pcm_access_name(runtime->access)); … … 406 419 } 407 420 #endif 421 unlock: 422 mutex_unlock(&substream->pcm->open_mutex); 408 423 } 409 424 … … 414 429 struct snd_pcm_runtime *runtime; 415 430 416 guard(mutex)(&substream->pcm->open_mutex);431 mutex_lock(&substream->pcm->open_mutex); 417 432 runtime = substream->runtime; 418 433 if (!runtime) { 419 434 snd_iprintf(buffer, "closed\n"); 420 return;435 goto unlock; 421 436 } 422 437 if (runtime->state == SNDRV_PCM_STATE_OPEN) { 423 438 snd_iprintf(buffer, "no setup\n"); 424 return;439 goto unlock; 425 440 } 426 441 snd_iprintf(buffer, "tstamp_mode: %s\n", snd_pcm_tstamp_mode_name(runtime->tstamp_mode)); … … 432 447 snd_iprintf(buffer, "silence_size: %lu\n", runtime->silence_size); 433 448 snd_iprintf(buffer, "boundary: %lu\n", runtime->boundary); 449 unlock: 450 mutex_unlock(&substream->pcm->open_mutex); 434 451 } 435 452 … … 442 459 int err; 443 460 444 guard(mutex)(&substream->pcm->open_mutex);461 mutex_lock(&substream->pcm->open_mutex); 445 462 runtime = substream->runtime; 446 463 if (!runtime) { 447 464 snd_iprintf(buffer, "closed\n"); 448 return;465 goto unlock; 449 466 } 450 467 memset(&status, 0, sizeof(status)); … … 452 469 if (err < 0) { 453 470 snd_iprintf(buffer, "error %d\n", err); 454 return;471 goto unlock; 455 472 } 456 473 snd_iprintf(buffer, "state: %s\n", snd_pcm_state_name(status.state)); … … 469 486 snd_iprintf(buffer, "xrun_counter: %d\n", substream->xrun_counter); 470 487 #endif 488 unlock: 489 mutex_unlock(&substream->pcm->open_mutex); 471 490 } 472 491 … … 1003 1022 /* Avoid concurrent access to runtime via PCM timer interface */ 1004 1023 if (substream->timer) { 1005 s coped_guard(spinlock_irq, &substream->timer->lock)1024 spin_lock_irq(&substream->timer->lock); 1006 1025 substream->runtime = NULL; 1026 spin_unlock_irq(&substream->timer->lock); 1007 1027 } else { 1008 1028 substream->runtime = NULL; … … 1063 1083 pcm = device->device_data; 1064 1084 1065 guard(mutex)(®ister_mutex);1085 mutex_lock(®ister_mutex); 1066 1086 err = snd_pcm_add(pcm); 1067 1087 if (err) 1068 return err;1088 goto unlock; 1069 1089 for (cidx = 0; cidx < 2; cidx++) { 1070 1090 int devtype = -1; … … 1085 1105 if (err < 0) { 1086 1106 list_del_init(&pcm->list); 1087 return err;1107 goto unlock; 1088 1108 } 1089 1109 … … 1093 1113 1094 1114 pcm_call_notify(pcm, n_register); 1115 1116 unlock: 1117 mutex_unlock(®ister_mutex); 1095 1118 return err; 1096 1119 } … … 1102 1125 int cidx; 1103 1126 1104 guard(mutex)(®ister_mutex);1105 guard(mutex)(&pcm->open_mutex);1127 mutex_lock(®ister_mutex); 1128 mutex_lock(&pcm->open_mutex); 1106 1129 wake_up(&pcm->open_wait); 1107 1130 list_del_init(&pcm->list); … … 1130 1153 free_chmap(&pcm->streams[cidx]); 1131 1154 } 1155 mutex_unlock(&pcm->open_mutex); 1156 mutex_unlock(®ister_mutex); 1132 1157 return 0; 1133 1158 } … … 1154 1179 !notify->n_disconnect)) 1155 1180 return -EINVAL; 1156 guard(mutex)(®ister_mutex);1181 mutex_lock(®ister_mutex); 1157 1182 if (nfree) { 1158 1183 list_del(¬ify->list); … … 1164 1189 notify->n_register(pcm); 1165 1190 } 1191 mutex_unlock(®ister_mutex); 1166 1192 return 0; 1167 1193 } … … 1179 1205 struct snd_pcm *pcm; 1180 1206 1181 guard(mutex)(®ister_mutex);1207 mutex_lock(®ister_mutex); 1182 1208 list_for_each_entry(pcm, &snd_pcm_devices, list, struct snd_pcm) { 1183 1209 snd_iprintf(buffer, "%02i-%02i: %s : %s", … … 1191 1217 snd_iprintf(buffer, "\n"); 1192 1218 } 1219 mutex_unlock(®ister_mutex); 1193 1220 } 1194 1221 -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/pcm_lib.c ¶
r766 r767 1801 1801 { 1802 1802 struct snd_pcm_runtime *runtime = substream->runtime; 1803 1804 guard(pcm_stream_lock_irqsave)(substream);1803 unsigned long flags; 1804 snd_pcm_stream_lock_irqsave(substream, flags); 1805 1805 if (snd_pcm_running(substream) && 1806 1806 snd_pcm_update_hw_ptr(substream) >= 0) … … 1810 1810 runtime->hw_ptr_wrap = 0; 1811 1811 } 1812 snd_pcm_stream_unlock_irqrestore(substream, flags); 1812 1813 return 0; 1813 1814 } … … 1970 1971 void snd_pcm_period_elapsed(struct snd_pcm_substream *substream) 1971 1972 { 1973 unsigned long flags; 1974 1972 1975 if (snd_BUG_ON(!substream)) 1973 1976 return; 1974 1977 1975 guard(pcm_stream_lock_irqsave)(substream);1978 snd_pcm_stream_lock_irqsave(substream, flags); 1976 1979 snd_pcm_period_elapsed_under_stream_lock(substream); 1980 snd_pcm_stream_unlock_irqrestore(substream, flags); 1977 1981 } 1978 1982 EXPORT_SYMBOL(snd_pcm_period_elapsed); -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/pcm_memory.c ¶
r766 r767 38 38 static void update_allocated_size(struct snd_card *card, ssize_t bytes) 39 39 { 40 guard(mutex)(&card->memory_mutex);40 mutex_lock(&card->memory_mutex); 41 41 __update_allocated_size(card, bytes); 42 mutex_unlock(&card->memory_mutex); 42 43 } 43 44 44 45 static void decrease_allocated_size(struct snd_card *card, size_t bytes) 45 46 { 46 guard(mutex)(&card->memory_mutex);47 mutex_lock(&card->memory_mutex); 47 48 WARN_ON(card->total_pcm_alloc_bytes < bytes); 48 49 __update_allocated_size(card, -(ssize_t)bytes); 50 mutex_unlock(&card->memory_mutex); 49 51 } 50 52 … … 56 58 57 59 /* check and reserve the requested size */ 58 scoped_guard(mutex, &card->memory_mutex) {60 mutex_lock(&card->memory_mutex); 59 61 if (max_alloc_per_card && 60 card->total_pcm_alloc_bytes + size > max_alloc_per_card) 62 card->total_pcm_alloc_bytes + size > max_alloc_per_card) { 63 mutex_unlock(&card->memory_mutex); 61 64 return -ENOMEM; 65 } 62 66 __update_allocated_size(card, size); 63 }67 mutex_unlock(&card->memory_mutex); 64 68 65 69 if (str == SNDRV_PCM_STREAM_PLAYBACK) … … 188 192 struct snd_card *card = substream->pcm->card; 189 193 char line[64], str[64]; 190 unsigned longsize;194 size_t size; 191 195 struct snd_dma_buffer new_dmab; 192 196 193 guard(mutex)(&substream->pcm->open_mutex);197 mutex_lock(&substream->pcm->open_mutex); 194 198 if (substream->runtime) { 195 199 buffer->error = -EBUSY; … … 198 202 if (!snd_info_get_line(buffer, line, sizeof(line))) { 199 203 snd_info_get_str(str, line, sizeof(str)); 200 buffer->error = kstrtoul(str, 10, &size); 201 if (buffer->error != 0) 202 return; 203 size *= 1024; 204 size = simple_strtoul(str, NULL, 10) * 1024; 204 205 if ((size != 0 && size < 8192) || size > substream->dma_max) { 205 206 buffer->error = -EINVAL; 206 return;207 goto unlock; 207 208 } 208 209 if (substream->dma_buffer.bytes == size) 209 return;210 goto unlock; 210 211 memset(&new_dmab, 0, sizeof(new_dmab)); 211 212 new_dmab.dev = substream->dma_buffer.dev; … … 221 222 substream->stream ? 'c' : 'p', substream->number, 222 223 substream->pcm->name, size); 223 return;224 goto unlock; 224 225 } 225 226 substream->buffer_bytes_max = size; -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/pcm_native.c ¶
r766 r767 620 620 snd_pcm_state_t state) 621 621 { 622 guard(pcm_stream_lock_irq)(substream);622 snd_pcm_stream_lock_irq(substream); 623 623 if (substream->runtime->state != SNDRV_PCM_STATE_DISCONNECTED) 624 624 __snd_pcm_set_state(substream->runtime, state); 625 snd_pcm_stream_unlock_irq(substream); 625 626 } 626 627 … … 750 751 if (err < 0) 751 752 return err; 752 s coped_guard(pcm_stream_lock_irq, substream) {753 snd_pcm_stream_lock_irq(substream); 753 754 switch (runtime->state) { 754 755 case SNDRV_PCM_STATE_OPEN: … … 757 758 if (!is_oss_stream(substream) && 758 759 atomic_read(&substream->mmap_count)) 759 760 err = -EBADFD; 760 761 break; 761 762 default: … … 763 764 break; 764 765 } 765 }766 snd_pcm_stream_unlock_irq(substream); 766 767 if (err) 767 768 goto unlock; … … 913 914 if (result < 0) 914 915 return result; 915 s coped_guard(pcm_stream_lock_irq, substream) {916 snd_pcm_stream_lock_irq(substream); 916 917 switch (runtime->state) { 917 918 case SNDRV_PCM_STATE_SETUP: 918 919 case SNDRV_PCM_STATE_PREPARED: 919 920 if (atomic_read(&substream->mmap_count)) 920 921 result = -EBADFD; 921 922 break; 922 923 default: … … 924 925 break; 925 926 } 926 }927 snd_pcm_stream_unlock_irq(substream); 927 928 if (result) 928 929 goto unlock; … … 944 945 return -ENXIO; 945 946 runtime = substream->runtime; 946 scoped_guard(pcm_stream_lock_irq, substream) { 947 if (runtime->state == SNDRV_PCM_STATE_OPEN) 947 snd_pcm_stream_lock_irq(substream); 948 if (runtime->state == SNDRV_PCM_STATE_OPEN) { 949 snd_pcm_stream_unlock_irq(substream); 948 950 return -EBADFD; 949 951 } 952 snd_pcm_stream_unlock_irq(substream); 950 953 951 954 if (params->tstamp_mode < 0 || … … 967 970 } 968 971 err = 0; 969 s coped_guard(pcm_stream_lock_irq, substream) {972 snd_pcm_stream_lock_irq(substream); 970 973 runtime->tstamp_mode = params->tstamp_mode; 971 974 if (params->proto >= SNDRV_PROTOCOL_VERSION(2, 0, 12)) … … 984 987 err = snd_pcm_update_state(substream, runtime); 985 988 } 986 }989 snd_pcm_stream_unlock_irq(substream); 987 990 return err; 988 991 } … … 1018 1021 struct snd_pcm_runtime *runtime = substream->runtime; 1019 1022 1020 guard(pcm_stream_lock_irq)(substream);1023 snd_pcm_stream_lock_irq(substream); 1021 1024 1022 1025 snd_pcm_unpack_audio_tstamp_config(status->audio_tstamp_data, … … 1039 1042 status->suspended_state = runtime->suspended_state; 1040 1043 if (status->state == SNDRV_PCM_STATE_OPEN) 1041 return 0;1044 goto _end; 1042 1045 status->trigger_tstamp_sec = runtime->trigger_tstamp.tv_sec; 1043 1046 status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec; … … 1084 1087 runtime->avail_max = 0; 1085 1088 runtime->overrange = 0; 1089 _end: 1090 snd_pcm_stream_unlock_irq(substream); 1086 1091 return 0; 1087 1092 } … … 1189 1194 channel = info->channel; 1190 1195 runtime = substream->runtime; 1191 scoped_guard(pcm_stream_lock_irq, substream) { 1192 if (runtime->state == SNDRV_PCM_STATE_OPEN) 1196 snd_pcm_stream_lock_irq(substream); 1197 if (runtime->state == SNDRV_PCM_STATE_OPEN) { 1198 snd_pcm_stream_unlock_irq(substream); 1193 1199 return -EBADFD; 1194 1200 } 1201 snd_pcm_stream_unlock_irq(substream); 1195 1202 if (channel >= runtime->channels) 1196 1203 return -EINVAL; … … 1413 1420 snd_pcm_state_t state) 1414 1421 { 1415 guard(pcm_stream_lock_irq)(substream); 1416 return snd_pcm_action(ops, substream, state); 1422 int res; 1423 1424 snd_pcm_stream_lock_irq(substream); 1425 res = snd_pcm_action(ops, substream, state); 1426 snd_pcm_stream_unlock_irq(substream); 1427 return res; 1417 1428 } 1418 1429 … … 1426 1437 1427 1438 /* Guarantee the group members won't change during non-atomic action */ 1428 guard(rwsem_read)(&snd_pcm_link_rwsem);1439 down_read(&snd_pcm_link_rwsem); 1429 1440 res = snd_pcm_buffer_access_lock(substream->runtime); 1430 1441 if (res < 0) 1431 return res;1442 goto unlock; 1432 1443 if (snd_pcm_stream_linked(substream)) 1433 1444 res = snd_pcm_action_group(ops, substream, state, false); … … 1435 1446 res = snd_pcm_action_single(ops, substream, state); 1436 1447 snd_pcm_buffer_access_unlock(substream->runtime); 1448 unlock: 1449 up_read(&snd_pcm_link_rwsem); 1437 1450 return res; 1438 1451 } … … 1604 1617 int snd_pcm_stop_xrun(struct snd_pcm_substream *substream) 1605 1618 { 1606 guard(pcm_stream_lock_irqsave)(substream); 1619 unsigned long flags; 1620 1621 snd_pcm_stream_lock_irqsave(substream, flags); 1607 1622 if (substream->runtime && snd_pcm_running(substream)) 1608 1623 __snd_pcm_xrun(substream); 1624 snd_pcm_stream_unlock_irqrestore(substream, flags); 1609 1625 return 0; 1610 1626 } … … 1758 1774 static int snd_pcm_suspend(struct snd_pcm_substream *substream) 1759 1775 { 1760 guard(pcm_stream_lock_irqsave)(substream); 1761 return snd_pcm_action(&snd_pcm_action_suspend, substream, 1776 int err; 1777 unsigned long flags; 1778 1779 snd_pcm_stream_lock_irqsave(substream, flags); 1780 err = snd_pcm_action(&snd_pcm_action_suspend, substream, 1762 1781 ACTION_ARG_IGNORE); 1782 snd_pcm_stream_unlock_irqrestore(substream, flags); 1783 return err; 1763 1784 } 1764 1785 … … 1878 1899 { 1879 1900 struct snd_pcm_runtime *runtime = substream->runtime; 1880 1881 guard(pcm_stream_lock_irq)(substream); 1901 int result; 1902 1903 snd_pcm_stream_lock_irq(substream); 1882 1904 switch (runtime->state) { 1883 1905 case SNDRV_PCM_STATE_XRUN: 1884 return 0; /* already there */ 1906 result = 0; /* already there */ 1907 break; 1885 1908 case SNDRV_PCM_STATE_RUNNING: 1886 1909 __snd_pcm_xrun(substream); 1887 return 0; 1910 result = 0; /* already there */ 1911 break; 1888 1912 default: 1889 return -EBADFD; 1890 } 1913 result -EBADFD; 1914 } 1915 snd_pcm_stream_unlock_irq(substream); 1916 return result; 1891 1917 } 1892 1918 … … 1917 1943 if (err < 0) 1918 1944 return err; 1919 guard(pcm_stream_lock_irq)(substream);1945 snd_pcm_stream_lock_irq(substream); 1920 1946 runtime->hw_ptr_base = 0; 1921 1947 runtime->hw_ptr_interrupt = runtime->status->hw_ptr - … … 1923 1949 runtime->silence_start = runtime->status->hw_ptr; 1924 1950 runtime->silence_filled = 0; 1951 snd_pcm_stream_unlock_irq(substream); 1925 1952 return 0; 1926 1953 } … … 1930 1957 { 1931 1958 struct snd_pcm_runtime *runtime = substream->runtime; 1932 guard(pcm_stream_lock_irq)(substream);1959 snd_pcm_stream_lock_irq(substream); 1933 1960 runtime->control->appl_ptr = runtime->status->hw_ptr; 1934 1961 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && 1935 1962 runtime->silence_size > 0) 1936 1963 snd_pcm_playback_silence(substream, ULONG_MAX); 1964 snd_pcm_stream_unlock_irq(substream); 1937 1965 } 1938 1966 … … 2010 2038 f_flags = substream->f_flags; 2011 2039 2012 s coped_guard(pcm_stream_lock_irq, substream) {2040 snd_pcm_stream_lock_irq(substream); 2013 2041 switch (substream->runtime->state) { 2014 2042 case SNDRV_PCM_STATE_PAUSED: … … 2019 2047 break; 2020 2048 } 2021 }2049 snd_pcm_stream_unlock_irq(substream); 2022 2050 2023 2051 return snd_pcm_action_nonatomic(&snd_pcm_action_prepare, … … 2236 2264 return -EBADFD; 2237 2265 2238 guard(pcm_stream_lock_irq)(substream);2266 snd_pcm_stream_lock_irq(substream); 2239 2267 /* resume pause */ 2240 2268 if (runtime->state == SNDRV_PCM_STATE_PAUSED) … … 2243 2271 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); 2244 2272 /* runtime->control->appl_ptr = runtime->status->hw_ptr; */ 2273 snd_pcm_stream_unlock_irq(substream); 2245 2274 2246 2275 return result; … … 2271 2300 static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) 2272 2301 { 2302 int res = 0; 2273 2303 struct snd_pcm_file *pcm_file; 2274 2304 struct snd_pcm_substream *substream1; … … 2283 2313 #endif 2284 2314 2285 if (!f d_file(f))2315 if (!f.file) 2286 2316 return -EBADFD; 2287 if (!is_pcm_file(fd_file(f))) 2288 return -EBADFD; 2289 2290 pcm_file = fd_file(f)->private_data; 2317 if (!is_pcm_file(f.file)) { 2318 res = -EBADFD; 2319 goto _badf; 2320 } 2321 pcm_file = f.file->private_data; 2291 2322 substream1 = pcm_file->substream; 2292 2323 … … 2295 2326 2296 2327 group = kzalloc(sizeof(*group), GFP_KERNEL); 2297 if (!group) 2298 return -ENOMEM; 2328 if (!group) { 2329 res = -ENOMEM; 2330 goto _nolock; 2331 } 2299 2332 snd_pcm_group_init(group); 2300 2333 2301 guard(rwsem_write)(&snd_pcm_link_rwsem);2334 down_write(&snd_pcm_link_rwsem); 2302 2335 if (substream->runtime->state == SNDRV_PCM_STATE_OPEN || 2303 2336 substream->runtime->state != substream1->runtime->state || 2304 substream->pcm->nonatomic != substream1->pcm->nonatomic) 2305 return -EBADFD; 2306 if (snd_pcm_stream_linked(substream1)) 2307 return -EALREADY; 2308 2309 scoped_guard(pcm_stream_lock_irq, substream) { 2337 substream->pcm->nonatomic != substream1->pcm->nonatomic) { 2338 res = -EBADFD; 2339 goto _end; 2340 } 2341 if (snd_pcm_stream_linked(substream1)) { 2342 res = -EALREADY; 2343 goto _end; 2344 } 2345 2346 snd_pcm_stream_lock_irq(substream); 2310 2347 if (!snd_pcm_stream_linked(substream)) { 2311 2348 snd_pcm_group_assign(substream, group); … … 2313 2350 } 2314 2351 target_group = substream->group; 2315 }2352 snd_pcm_stream_unlock_irq(substream); 2316 2353 2317 2354 snd_pcm_group_lock_irq(target_group, nonatomic); … … 2321 2358 snd_pcm_stream_unlock(substream1); 2322 2359 snd_pcm_group_unlock_irq(target_group, nonatomic); 2323 return 0; 2360 _end: 2361 up_write(&snd_pcm_link_rwsem); 2362 _nolock: 2363 kfree(group); 2364 _badf: 2365 #ifndef TARGET_OS2 2366 fdput(f); 2367 #endif 2368 return res; 2324 2369 } 2325 2370 … … 2336 2381 bool nonatomic = substream->pcm->nonatomic; 2337 2382 bool do_free = false; 2338 2339 guard(rwsem_write)(&snd_pcm_link_rwsem); 2340 2341 if (!snd_pcm_stream_linked(substream)) 2342 return -EALREADY; 2383 int res = 0; 2384 2385 down_write(&snd_pcm_link_rwsem); 2386 2387 if (!snd_pcm_stream_linked(substream)) { 2388 res = -EALREADY; 2389 goto _end; 2390 } 2343 2391 2344 2392 group = substream->group; … … 2359 2407 if (do_free) 2360 2408 kfree(group); 2361 return 0; 2409 2410 _end: 2411 up_write(&snd_pcm_link_rwsem); 2412 return res; 2362 2413 } 2363 2414 … … 2939 2990 snd_power_wait(pcm->card); 2940 2991 2941 scoped_guard(mutex, &pcm->open_mutex) {2992 mutex_lock(&pcm->open_mutex); 2942 2993 snd_pcm_release_substream(substream); 2943 2994 kfree(pcm_file); 2944 }2995 mutex_unlock(&pcm->open_mutex); 2945 2996 wake_up(&pcm->open_wait); 2946 2997 module_put(pcm->card->module); … … 3026 3077 return 0; 3027 3078 3028 s coped_guard(pcm_stream_lock_irq, substream) {3079 snd_pcm_stream_lock_irq(substream); 3029 3080 ret = do_pcm_hwsync(substream); 3030 3081 if (!ret) 3031 3082 ret = rewind_appl_ptr(substream, frames, 3032 3083 snd_pcm_hw_avail(substream)); 3033 }3084 snd_pcm_stream_unlock_irq(substream); 3034 3085 #ifndef TARGET_OS2 3035 3086 if (ret >= 0) … … 3047 3098 return 0; 3048 3099 3049 s coped_guard(pcm_stream_lock_irq, substream) {3100 snd_pcm_stream_lock_irq(substream); 3050 3101 ret = do_pcm_hwsync(substream); 3051 3102 if (!ret) 3052 3103 ret = forward_appl_ptr(substream, frames, 3053 3104 snd_pcm_avail(substream)); 3054 }3105 snd_pcm_stream_unlock_irq(substream); 3055 3106 #ifndef TARGET_OS2 3056 3107 if (ret >= 0) … … 3065 3116 int err; 3066 3117 3067 s coped_guard(pcm_stream_lock_irq, substream) {3118 snd_pcm_stream_lock_irq(substream); 3068 3119 err = do_pcm_hwsync(substream); 3069 3120 if (delay && !err) 3070 3121 *delay = snd_pcm_calc_delay(substream); 3071 }3122 snd_pcm_stream_unlock_irq(substream); 3072 3123 #ifndef TARGET_OS2 3073 3124 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_CPU); … … 3102 3153 return err; 3103 3154 } 3104 s coped_guard(pcm_stream_lock_irq, substream) {3155 snd_pcm_stream_lock_irq(substream); 3105 3156 if (!(sync_ptr.flags & SNDRV_PCM_SYNC_PTR_APPL)) { 3106 3157 err = pcm_lib_apply_appl_ptr(substream, 3107 3158 sync_ptr.c.control.appl_ptr); 3108 if (err < 0) 3159 if (err < 0) { 3160 snd_pcm_stream_unlock_irq(substream); 3109 3161 return err; 3162 } 3110 3163 } else { 3111 3164 sync_ptr.c.control.appl_ptr = control->appl_ptr; … … 3120 3173 sync_ptr.s.status.suspended_state = status->suspended_state; 3121 3174 sync_ptr.s.status.audio_tstamp = status->audio_tstamp; 3122 }3175 snd_pcm_stream_unlock_irq(substream); 3123 3176 #ifndef TARGET_OS2 3124 3177 if (!(sync_ptr.flags & SNDRV_PCM_SYNC_PTR_APPL)) … … 3208 3261 if (! boundary) 3209 3262 boundary = 0x7fffffff; 3210 s coped_guard(pcm_stream_lock_irq, substream) {3263 snd_pcm_stream_lock_irq(substream); 3211 3264 /* FIXME: we should consider the boundary for the sync from app */ 3212 3265 if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL)) { 3213 3266 err = pcm_lib_apply_appl_ptr(substream, 3214 3267 scontrol.appl_ptr); 3215 if (err < 0) 3268 if (err < 0) { 3269 snd_pcm_stream_unlock_irq(substream); 3216 3270 return err; 3271 } 3217 3272 } else 3218 3273 scontrol.appl_ptr = control->appl_ptr % boundary; … … 3226 3281 sstatus.suspended_state = status->suspended_state; 3227 3282 sstatus.audio_tstamp = status->audio_tstamp; 3228 }3283 snd_pcm_stream_unlock_irq(substream); 3229 3284 #ifndef TARGET_OS2 3230 3285 if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL)) … … 3584 3639 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) 3585 3640 return -EBADFD; 3586 if (! user_backed_iter(to))3641 if (!to->user_backed) 3587 3642 return -EINVAL; 3588 3643 if (to->nr_segs > 1024 || to->nr_segs != runtime->channels) … … 3623 3678 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) 3624 3679 return -EBADFD; 3625 if (! user_backed_iter(from))3680 if (!from->user_backed) 3626 3681 return -EINVAL; 3627 3682 if (from->nr_segs > 128 || from->nr_segs != runtime->channels || … … 3667 3722 3668 3723 mask = 0; 3669 guard(pcm_stream_lock_irq)(substream);3724 snd_pcm_stream_lock_irq(substream); 3670 3725 avail = snd_pcm_avail(substream); 3671 3726 switch (runtime->state) { … … 3687 3742 break; 3688 3743 } 3744 snd_pcm_stream_unlock_irq(substream); 3689 3745 return mask; 3690 3746 } -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/rawmidi.c ¶
r766 r767 124 124 static bool snd_rawmidi_ready(struct snd_rawmidi_substream *substream) 125 125 { 126 guard(spinlock_irqsave)(&substream->lock); 127 return __snd_rawmidi_ready(substream->runtime); 126 unsigned long flags; 127 bool ready; 128 129 spin_lock_irqsave(&substream->lock, flags); 130 ready = __snd_rawmidi_ready(substream->runtime); 131 spin_unlock_irqrestore(&substream->lock, flags); 132 return ready; 128 133 } 129 134 … … 254 259 bool is_input) 255 260 { 256 guard(spinlock_irqsave)(&substream->lock); 261 unsigned long flags; 262 263 spin_lock_irqsave(&substream->lock, flags); 257 264 if (substream->opened && substream->runtime) 258 265 __reset_runtime_ptrs(substream->runtime, is_input); 266 spin_unlock_irqrestore(&substream->lock, flags); 259 267 } 260 268 … … 273 281 struct snd_rawmidi_runtime *runtime; 274 282 275 s coped_guard(spinlock_irq, &substream->lock) {283 spin_lock_irq(&substream->lock); 276 284 runtime = substream->runtime; 277 if (!substream->opened || !runtime || !runtime->buffer) 278 return -EINVAL; 285 if (!substream->opened || !runtime || !runtime->buffer) { 286 err = -EINVAL; 287 } else { 279 288 snd_rawmidi_buffer_ref(runtime); 280 289 runtime->drain = 1; 281 290 } 291 spin_unlock_irq(&substream->lock); 292 if (err < 0) 293 return err; 282 294 283 295 #ifndef TARGET_OS2 … … 289 301 #endif 290 302 291 s coped_guard(spinlock_irq, &substream->lock) {303 spin_lock_irq(&substream->lock); 292 304 if (signal_pending(current)) 293 305 err = -ERESTARTSYS; … … 299 311 } 300 312 runtime->drain = 0; 301 }313 spin_unlock_irq(&substream->lock); 302 314 303 315 if (err != -ERESTARTSYS) { … … 310 322 } 311 323 312 s coped_guard(spinlock_irq, &substream->lock)324 spin_lock_irq(&substream->lock); 313 325 snd_rawmidi_buffer_unref(runtime); 326 spin_unlock_irq(&substream->lock); 314 327 315 328 return err; … … 375 388 return err; 376 389 } 377 guard(spinlock_irq)(&substream->lock);390 spin_lock_irq(&substream->lock); 378 391 substream->opened = 1; 379 392 substream->active_sensing = 0; … … 382 395 substream->pid = get_pid(task_pid(current)); 383 396 rmidi->streams[substream->stream].substream_opened++; 397 spin_unlock_irq(&substream->lock); 384 398 } 385 399 substream->use_count++; … … 444 458 return -ENXIO; 445 459 446 guard(mutex)(&rmidi->open_mutex);460 mutex_lock(&rmidi->open_mutex); 447 461 err = rawmidi_open_priv(rmidi, subdevice, mode, rfile); 462 mutex_unlock(&rmidi->open_mutex); 448 463 if (err < 0) 449 464 module_put(rmidi->card->module); … … 578 593 snd_rawmidi_buffer_ref_sync(substream); 579 594 } 580 s coped_guard(spinlock_irq, &substream->lock) {595 spin_lock_irq(&substream->lock); 581 596 substream->opened = 0; 582 597 substream->append = 0; 583 }598 spin_unlock_irq(&substream->lock); 584 599 substream->ops->close(substream); 585 600 if (substream->runtime->private_free) … … 596 611 597 612 rmidi = rfile->rmidi; 598 guard(mutex)(&rmidi->open_mutex);613 mutex_lock(&rmidi->open_mutex); 599 614 if (rfile->input) { 600 615 close_substream(rmidi, rfile->input, 1); … … 606 621 } 607 622 rfile->rmidi = NULL; 623 mutex_unlock(&rmidi->open_mutex); 608 624 wake_up(&rmidi->open_wait); 609 625 } … … 706 722 int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info) 707 723 { 708 guard(mutex)(®ister_mutex); 709 return __snd_rawmidi_info_select(card, info); 724 int ret; 725 726 mutex_lock(®ister_mutex); 727 ret = __snd_rawmidi_info_select(card, info); 728 mutex_unlock(®ister_mutex); 729 return ret; 710 730 } 711 731 EXPORT_SYMBOL(snd_rawmidi_info_select); … … 774 794 775 795 snd_rawmidi_drain_output(substream); 776 guard(mutex)(&substream->rmidi->open_mutex);796 mutex_lock(&substream->rmidi->open_mutex); 777 797 if (substream->append && substream->use_count > 1) 778 return -EBUSY; 798 err = -EBUSY; 799 else 779 800 err = resize_runtime_buffer(substream, params, false); 801 780 802 if (!err) 781 803 substream->active_sensing = !params->no_active_sensing; 804 mutex_unlock(&substream->rmidi->open_mutex); 782 805 return err; 783 806 } … … 792 815 793 816 snd_rawmidi_drain_input(substream); 794 guard(mutex)(&substream->rmidi->open_mutex);817 mutex_lock(&substream->rmidi->open_mutex); 795 818 if (framing == SNDRV_RAWMIDI_MODE_FRAMING_NONE && clock_type != SNDRV_RAWMIDI_MODE_CLOCK_NONE) 796 819 err = -EINVAL; … … 806 829 substream->clock_type = clock_type; 807 830 } 831 mutex_unlock(&substream->rmidi->open_mutex); 808 832 return 0; 809 833 } … … 818 842 memset(status, 0, sizeof(*status)); 819 843 status->stream = SNDRV_RAWMIDI_STREAM_OUTPUT; 820 guard(spinlock_irq)(&substream->lock);844 spin_lock_irq(&substream->lock); 821 845 status->avail = runtime->avail; 846 spin_unlock_irq(&substream->lock); 822 847 return 0; 823 848 } … … 830 855 memset(status, 0, sizeof(*status)); 831 856 status->stream = SNDRV_RAWMIDI_STREAM_INPUT; 832 guard(spinlock_irq)(&substream->lock);857 spin_lock_irq(&substream->lock); 833 858 status->avail = runtime->avail; 834 859 status->xruns = runtime->xruns; 835 860 runtime->xruns = 0; 861 spin_unlock_irq(&substream->lock); 836 862 return 0; 837 863 } … … 1028 1054 if (device >= SNDRV_RAWMIDI_DEVICES) /* next device is -1 */ 1029 1055 device = SNDRV_RAWMIDI_DEVICES - 1; 1030 scoped_guard(mutex, ®ister_mutex) {1056 mutex_lock(®ister_mutex); 1031 1057 device = device < 0 ? 0 : device + 1; 1032 1058 for (; device < SNDRV_RAWMIDI_DEVICES; device++) { … … 1040 1066 if (device == SNDRV_RAWMIDI_DEVICES) 1041 1067 device = -1; 1042 }1068 mutex_unlock(®ister_mutex); 1043 1069 if (put_user(device, argp)) 1044 1070 return -EFAULT; … … 1053 1079 struct snd_ump_endpoint_info __user *info = argp; 1054 1080 struct snd_rawmidi *rmidi; 1055 int device ;1081 int device, ret; 1056 1082 1057 1083 if (get_user(device, &info->device)) 1058 1084 return -EFAULT; 1059 guard(mutex)(®ister_mutex);1085 mutex_lock(®ister_mutex); 1060 1086 rmidi = snd_rawmidi_search(card, device); 1061 1087 if (rmidi && rmidi->ops && rmidi->ops->ioctl) 1062 ret urnrmidi->ops->ioctl(rmidi, cmd, argp);1088 ret = rmidi->ops->ioctl(rmidi, cmd, argp); 1063 1089 else 1064 return -ENXIO; 1090 ret = -ENXIO; 1091 mutex_unlock(®ister_mutex); 1092 return ret; 1065 1093 } 1066 1094 #endif … … 1176 1204 const unsigned char *buffer, int count) 1177 1205 { 1206 unsigned long flags; 1178 1207 struct timespec64 ts64 = get_framing_tstamp(substream); 1179 1208 int result = 0, count1; 1180 1209 struct snd_rawmidi_runtime *runtime; 1181 1210 1182 guard(spinlock_irqsave)(&substream->lock); 1183 if (!substream->opened) 1184 return -EBADFD; 1211 spin_lock_irqsave(&substream->lock, flags); 1212 if (!substream->opened) { 1213 result = -EBADFD; 1214 goto unlock; 1215 } 1185 1216 runtime = substream->runtime; 1186 1217 if (!runtime || !runtime->buffer) { 1187 1218 rmidi_dbg(substream->rmidi, 1188 1219 "snd_rawmidi_receive: input is not active!!!\n"); 1189 return -EINVAL; 1220 result = -EINVAL; 1221 goto unlock; 1190 1222 } 1191 1223 1192 1224 count = get_aligned_size(runtime, count); 1193 1225 if (!count) 1194 return result;1226 goto unlock; 1195 1227 1196 1228 if (substream->framing == SNDRV_RAWMIDI_MODE_FRAMING_TSTAMP) { … … 1215 1247 count1 = get_aligned_size(runtime, count1); 1216 1248 if (!count1) 1217 return result;1249 goto unlock; 1218 1250 memcpy(runtime->buffer + runtime->hw_ptr, buffer, count1); 1219 1251 runtime->hw_ptr += count1; … … 1243 1275 wake_up(&runtime->sleep); 1244 1276 } 1277 unlock: 1278 spin_unlock_irqrestore(&substream->lock, flags); 1245 1279 return result; 1246 1280 } … … 1365 1399 struct snd_rawmidi_runtime *runtime; 1366 1400 1367 guard(spinlock_irqsave)(&substream->lock); 1401 int result; 1402 unsigned long flags; 1403 1404 spin_lock_irqsave(&substream->lock, flags); 1368 1405 runtime = substream->runtime; 1369 1406 if (!substream->opened || !runtime || !runtime->buffer) { 1370 1407 rmidi_dbg(substream->rmidi, 1371 1408 "snd_rawmidi_transmit_empty: output is not active!!!\n"); 1372 return 1; 1373 } 1374 return (runtime->avail >= runtime->buffer_size); 1409 result = 1; 1410 } else { 1411 result = runtime->avail >= runtime->buffer_size; 1412 } 1413 spin_unlock_irqrestore(&substream->lock, flags); 1414 return result; 1375 1415 } 1376 1416 EXPORT_SYMBOL(snd_rawmidi_transmit_empty); … … 1446 1486 unsigned char *buffer, int count) 1447 1487 { 1448 guard(spinlock_irqsave)(&substream->lock); 1488 int result; 1489 unsigned long flags; 1490 1491 spin_lock_irqsave(&substream->lock, flags); 1449 1492 if (!substream->opened || !substream->runtime) 1450 return -EBADFD; 1451 return __snd_rawmidi_transmit_peek(substream, buffer, count); 1493 result = -EBADFD; 1494 else 1495 result = __snd_rawmidi_transmit_peek(substream, buffer, count); 1496 spin_unlock_irqrestore(&substream->lock, flags); 1497 return result; 1452 1498 } 1453 1499 EXPORT_SYMBOL(snd_rawmidi_transmit_peek); … … 1496 1542 int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count) 1497 1543 { 1498 guard(spinlock_irqsave)(&substream->lock); 1544 int result; 1545 unsigned long flags; 1546 1547 spin_lock_irqsave(&substream->lock, flags); 1499 1548 if (!substream->opened || !substream->runtime) 1500 return -EBADFD; 1501 return __snd_rawmidi_transmit_ack(substream, count); 1549 result = -EBADFD; 1550 else 1551 result = __snd_rawmidi_transmit_ack(substream, count); 1552 spin_unlock_irqrestore(&substream->lock, flags); 1553 return result; 1502 1554 } 1503 1555 EXPORT_SYMBOL(snd_rawmidi_transmit_ack); … … 1516 1568 unsigned char *buffer, int count) 1517 1569 { 1518 guard(spinlock_irqsave)(&substream->lock); 1570 int result; 1571 unsigned long flags; 1572 1573 spin_lock_irqsave(&substream->lock, flags); 1519 1574 if (!substream->opened) 1520 return -EBADFD; 1575 result = -EBADFD; 1576 else { 1521 1577 count = __snd_rawmidi_transmit_peek(substream, buffer, count); 1522 1578 if (count <= 0) 1523 return count; 1524 return __snd_rawmidi_transmit_ack(substream, count); 1579 result = count; 1580 else 1581 result = __snd_rawmidi_transmit_ack(substream, count); 1582 } 1583 spin_unlock_irqrestore(&substream->lock, flags); 1584 return result; 1525 1585 } 1526 1586 EXPORT_SYMBOL(snd_rawmidi_transmit); … … 1535 1595 { 1536 1596 struct snd_rawmidi_runtime *runtime; 1597 unsigned long flags; 1537 1598 int count = 0; 1538 1599 1539 guard(spinlock_irqsave)(&substream->lock);1600 spin_lock_irqsave(&substream->lock, flags); 1540 1601 runtime = substream->runtime; 1541 1602 if (substream->opened && runtime && … … 1544 1605 __snd_rawmidi_transmit_ack(substream, count); 1545 1606 } 1607 spin_unlock_irqrestore(&substream->lock, flags); 1546 1608 return count; 1547 1609 } … … 1749 1811 if (rmidi->ops && rmidi->ops->proc_read) 1750 1812 rmidi->ops->proc_read(entry, buffer); 1751 guard(mutex)(&rmidi->open_mutex);1813 mutex_lock(&rmidi->open_mutex); 1752 1814 if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) { 1753 1815 list_for_each_entry(substream, … … 1764 1826 pid_vnr(substream->pid)); 1765 1827 runtime = substream->runtime; 1766 s coped_guard(spinlock_irq, &substream->lock) {1828 spin_lock_irq(&substream->lock); 1767 1829 buffer_size = runtime->buffer_size; 1768 1830 avail = runtime->avail; 1769 }1831 spin_unlock_irq(&substream->lock); 1770 1832 snd_iprintf(buffer, 1771 1833 " Mode : %s\n" … … 1791 1853 pid_vnr(substream->pid)); 1792 1854 runtime = substream->runtime; 1793 s coped_guard(spinlock_irq, &substream->lock) {1855 spin_lock_irq(&substream->lock); 1794 1856 buffer_size = runtime->buffer_size; 1795 1857 avail = runtime->avail; 1796 1858 xruns = runtime->xruns; 1797 }1859 spin_unlock_irq(&substream->lock); 1798 1860 snd_iprintf(buffer, 1799 1861 " Buffer size : %lu\n" … … 1812 1874 } 1813 1875 } 1876 mutex_unlock(&rmidi->open_mutex); 1814 1877 } 1815 1878 … … 2001 2064 return -ENOMEM; 2002 2065 err = 0; 2003 scoped_guard(mutex, ®ister_mutex) {2066 mutex_lock(®ister_mutex); 2004 2067 if (snd_rawmidi_search(rmidi->card, rmidi->device)) 2005 2068 err = -EBUSY; 2006 2069 else 2007 2070 list_add_tail(&rmidi->list, &snd_rawmidi_devices); 2008 }2071 mutex_unlock(®ister_mutex); 2009 2072 if (err < 0) 2010 2073 return err; … … 2079 2142 snd_unregister_device(rmidi->dev); 2080 2143 error: 2081 scoped_guard(mutex, ®ister_mutex)2144 mutex_lock(®ister_mutex); 2082 2145 list_del(&rmidi->list); 2146 mutex_unlock(®ister_mutex); 2083 2147 return err; 2084 2148 } … … 2089 2153 int dir; 2090 2154 2091 guard(mutex)(®ister_mutex);2092 guard(mutex)(&rmidi->open_mutex);2155 mutex_lock(®ister_mutex); 2156 mutex_lock(&rmidi->open_mutex); 2093 2157 wake_up(&rmidi->open_wait); 2094 2158 list_del_init(&rmidi->list); … … 2116 2180 #endif /* CONFIG_SND_OSSEMUL */ 2117 2181 snd_unregister_device(rmidi->dev); 2182 mutex_unlock(&rmidi->open_mutex); 2183 mutex_unlock(®ister_mutex); 2118 2184 return 0; 2119 2185 } -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_fifo.c ¶
r766 r767 89 89 90 90 snd_use_lock_sync(&f->use_lock); 91 guard(spinlock_irq)(&f->lock);91 spin_lock_irq(&f->lock); 92 92 /* drain the fifo */ 93 93 while ((cell = fifo_cell_out(f)) != NULL) { 94 94 snd_seq_cell_free(cell); 95 95 } 96 spin_unlock_irq(&f->lock); 96 97 } 97 98 … … 102 103 { 103 104 struct snd_seq_event_cell *cell; 105 unsigned long flags; 104 106 int err; 105 107 … … 117 119 118 120 /* append new cells to fifo */ 119 s coped_guard(spinlock_irqsave, &f->lock) {121 spin_lock_irqsave(&f->lock, flags); 120 122 if (f->tail != NULL) 121 123 f->tail->next = cell; … … 125 127 cell->next = NULL; 126 128 f->cells++; 127 }129 spin_unlock_irqrestore(&f->lock, flags); 128 130 129 131 /* wakeup client */ … … 198 200 struct snd_seq_event_cell *cell) 199 201 { 202 unsigned long flags; 203 200 204 if (cell) { 201 guard(spinlock_irqsave)(&f->lock);205 spin_lock_irqsave(&f->lock, flags); 202 206 cell->next = f->head; 203 207 f->head = cell; … … 205 209 f->tail = cell; 206 210 f->cells++; 211 spin_unlock_irqrestore(&f->lock, flags); 207 212 } 208 213 } … … 235 240 } 236 241 237 s coped_guard(spinlock_irq, &f->lock) {242 spin_lock_irq(&f->lock); 238 243 /* remember old pool */ 239 244 oldpool = f->pool; … … 245 250 f->cells = 0; 246 251 /* NOTE: overflow flag is not cleared */ 247 }252 spin_unlock_irq(&f->lock); 248 253 249 254 /* close the old pool and wait until all users are gone */ … … 264 269 int snd_seq_fifo_unused_cells(struct snd_seq_fifo *f) 265 270 { 271 unsigned long flags; 266 272 int cells; 267 273 … … 270 276 271 277 snd_use_lock_use(&f->use_lock); 272 s coped_guard(spinlock_irqsave, &f->lock)278 spin_lock_irqsave(&f->lock, flags); 273 279 cells = snd_seq_unused_cells(f->pool); 280 spin_unlock_irqrestore(&f->lock, flags); 274 281 snd_use_lock_free(&f->use_lock); 275 282 return cells; -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_memory.c ¶
r766 r767 233 233 void snd_seq_cell_free(struct snd_seq_event_cell * cell) 234 234 { 235 unsigned long flags; 235 236 struct snd_seq_pool *pool; 236 237 … … 241 242 return; 242 243 243 guard(spinlock_irqsave)(&pool->lock);244 spin_lock_irqsave(&pool->lock, flags); 244 245 free_cell(pool, cell); 245 246 if (snd_seq_ev_is_variable(&cell->event)) { … … 259 260 wake_up(&pool->output_sleep); 260 261 } 262 spin_unlock_irqrestore(&pool->lock, flags); 261 263 } 262 264 … … 448 450 449 451 /* add new cells to the free cell list */ 450 guard(spinlock_irq)(&pool->lock);452 spin_lock_irq(&pool->lock); 451 453 if (pool->ptr) { 454 spin_unlock_irq(&pool->lock); 452 455 kvfree(cellptr); 453 456 return 0; … … 468 471 pool->max_used = 0; 469 472 pool->total_elements = pool->size; 473 spin_unlock_irq(&pool->lock); 470 474 return 0; 471 475 } … … 474 478 void snd_seq_pool_mark_closing(struct snd_seq_pool *pool) 475 479 { 480 unsigned long flags; 481 476 482 if (snd_BUG_ON(!pool)) 477 483 return; 478 guard(spinlock_irqsave)(&pool->lock);484 spin_lock_irqsave(&pool->lock, flags); 479 485 pool->closing = 1; 486 spin_unlock_irqrestore(&pool->lock, flags); 480 487 } 481 488 … … 498 505 499 506 /* release all resources */ 500 s coped_guard(spinlock_irq, &pool->lock) {507 spin_lock_irq(&pool->lock); 501 508 ptr = pool->ptr; 502 509 pool->ptr = NULL; 503 510 pool->free = NULL; 504 511 pool->total_elements = 0; 505 }512 spin_unlock_irq(&pool->lock); 506 513 507 514 kvfree(ptr); 508 515 509 guard(spinlock_irq)(&pool->lock);516 spin_lock_irq(&pool->lock); 510 517 pool->closing = 0; 518 spin_unlock_irq(&pool->lock); 511 519 512 520 return 0; -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_midi.c ¶
r766 r767 307 307 ports = 256 / SNDRV_RAWMIDI_DEVICES; 308 308 309 guard(mutex)(®ister_mutex);309 mutex_lock(®ister_mutex); 310 310 client = synths[card->number]; 311 311 if (client == NULL) { 312 312 newclient = 1; 313 313 client = kzalloc(sizeof(*client), GFP_KERNEL); 314 if (client == NULL) 314 if (client == NULL) { 315 mutex_unlock(®ister_mutex); 316 kfree(info); 315 317 return -ENOMEM; 318 } 316 319 client->seq_client = 317 320 snd_seq_create_kernel_client( … … 320 323 if (client->seq_client < 0) { 321 324 kfree(client); 325 mutex_unlock(®ister_mutex); 326 kfree(info); 322 327 return -ENOMEM; 323 328 } … … 400 405 if (newclient) 401 406 synths[card->number] = client; 407 mutex_unlock(®ister_mutex); 408 kfree(info); 409 kfree(port); 402 410 return 0; /* success */ 403 411 … … 412 420 kfree(client); 413 421 } 422 kfree(info); 423 kfree(port); 424 mutex_unlock(®ister_mutex); 414 425 return -ENOMEM; 415 426 } … … 425 436 int device = dev->device, p, ports; 426 437 427 guard(mutex)(®ister_mutex);438 mutex_lock(®ister_mutex); 428 439 client = synths[card->number]; 429 if (client == NULL || client->ports[device] == NULL) 440 if (client == NULL || client->ports[device] == NULL) { 441 mutex_unlock(®ister_mutex); 430 442 return -ENODEV; 443 } 431 444 ports = client->ports_per_device[device]; 432 445 client->ports_per_device[device] = 0; … … 442 455 kfree(client); 443 456 } 457 mutex_unlock(®ister_mutex); 444 458 return 0; 445 459 } -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_midi_event.c ¶
r766 r767 145 145 void snd_midi_event_reset_encode(struct snd_midi_event *dev) 146 146 { 147 guard(spinlock_irqsave)(&dev->lock); 147 unsigned long flags; 148 149 spin_lock_irqsave(&dev->lock, flags); 148 150 reset_encode(dev); 151 spin_unlock_irqrestore(&dev->lock, flags); 149 152 } 150 153 EXPORT_SYMBOL(snd_midi_event_reset_encode); … … 152 155 void snd_midi_event_reset_decode(struct snd_midi_event *dev) 153 156 { 154 guard(spinlock_irqsave)(&dev->lock); 157 unsigned long flags; 158 159 spin_lock_irqsave(&dev->lock, flags); 155 160 dev->lastcmd = 0xff; 161 spin_unlock_irqrestore(&dev->lock, flags); 156 162 } 157 163 EXPORT_SYMBOL(snd_midi_event_reset_decode); … … 172 178 { 173 179 bool rc = false; 180 unsigned long flags; 174 181 175 182 if (c >= MIDI_CMD_COMMON_CLOCK) { … … 181 188 } 182 189 183 guard(spinlock_irqsave)(&dev->lock);190 spin_lock_irqsave(&dev->lock, flags); 184 191 if ((c & 0x80) && 185 192 (c != MIDI_CMD_COMMON_SYSEX_END || dev->type != ST_SYSEX)) { … … 230 237 } 231 238 239 spin_unlock_irqrestore(&dev->lock, flags); 232 240 return rc; 233 241 } -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_ports.c ¶
r766 r767 49 49 if (client == NULL) 50 50 return NULL; 51 guard(read_lock)(&client->ports_lock);51 read_lock(&client->ports_lock); 52 52 list_for_each_entry(port, &client->ports_list_head, list, struct snd_seq_client_port) { 53 53 if (port->addr.port == num) { … … 58 58 } 59 59 } 60 read_unlock(&client->ports_lock); 60 61 return NULL; /* not found */ 61 62 } … … 72 73 num = pinfo->addr.port; 73 74 found = NULL; 74 guard(read_lock)(&client->ports_lock);75 read_lock(&client->ports_lock); 75 76 list_for_each_entry(port, &client->ports_list_head, list, struct snd_seq_client_port) { 76 77 if ((port->capability & SNDRV_SEQ_PORT_CAP_INACTIVE) && … … 92 93 snd_use_lock_use(&found->use_lock); 93 94 } 95 read_unlock(&client->ports_lock); 94 96 return found; 95 97 } … … 143 145 144 146 num = max(port, 0); 145 guard(mutex)(&client->ports_mutex);146 guard(write_lock_irq)(&client->ports_lock);147 mutex_lock(&client->ports_mutex); 148 write_lock_irq(&client->ports_lock); 147 149 list_for_each_entry(p, &client->ports_list_head, list, struct snd_seq_client_port) { 148 150 if (p->addr.port == port) { 149 151 kfree(new_port); 150 return -EBUSY; 152 num = -EBUSY; 153 goto unlock; 151 154 } 152 155 if (p->addr.port > num) … … 161 164 sprintf(new_port->name, "port-%d", num); 162 165 *port_ret = new_port; 166 unlock: 167 write_unlock_irq(&client->ports_lock); 168 mutex_unlock(&client->ports_mutex); 163 169 164 170 return num; … … 275 281 struct snd_seq_client_port *found = NULL, *p; 276 282 277 scoped_guard(mutex, &client->ports_mutex) {278 guard(write_lock_irq)(&client->ports_lock);283 mutex_lock(&client->ports_mutex); 284 write_lock_irq(&client->ports_lock); 279 285 list_for_each_entry(p, &client->ports_list_head, list, struct snd_seq_client_port) { 280 286 if (p->addr.port == port) { … … 286 292 } 287 293 } 288 } 294 write_unlock_irq(&client->ports_lock); 295 mutex_unlock(&client->ports_mutex); 289 296 if (found) 290 297 return port_delete(client, found); … … 302 309 * clear the port list in the client data. 303 310 */ 304 guard(mutex)(&client->ports_mutex);305 scoped_guard(write_lock_irq, &client->ports_lock) {311 mutex_lock(&client->ports_mutex); 312 write_lock_irq(&client->ports_lock); 306 313 if (! list_empty(&client->ports_list_head)) { 307 314 list_add(&deleted_list, &client->ports_list_head); … … 311 318 } 312 319 client->num_ports = 0; 313 }320 write_unlock_irq(&client->ports_lock); 314 321 315 322 /* remove each port in deleted_list */ … … 319 326 port_delete(client, port); 320 327 } 328 mutex_unlock(&client->ports_mutex); 321 329 return 0; 322 330 } … … 503 511 504 512 grp = is_src ? &port->c_src : &port->c_dest; 505 guard(rwsem_write)(&grp->list_mutex); 513 err = -EBUSY; 514 down_write(&grp->list_mutex); 506 515 if (exclusive) { 507 516 if (!list_empty(&grp->list_head)) 508 return -EBUSY;517 goto __error; 509 518 } else { 510 519 if (grp->exclusive) 511 return -EBUSY;520 goto __error; 512 521 /* check whether already exists */ 513 522 list_for_each(p, &grp->list_head) { 514 523 s = get_subscriber(p, is_src); 515 524 if (match_subs_info(&subs->info, &s->info)) 516 return -EBUSY;525 goto __error; 517 526 } 518 527 } … … 521 530 if (err < 0) { 522 531 grp->exclusive = 0; 523 return err;532 goto __error; 524 533 } 525 534 526 535 /* add to list */ 527 guard(write_lock_irq)(&grp->list_lock);536 write_lock_irq(&grp->list_lock); 528 537 if (is_src) 529 538 list_add_tail(&subs->src_list, &grp->list_head); … … 532 541 grp->exclusive = exclusive; 533 542 atomic_inc(&subs->ref_count); 534 535 return 0; 543 write_unlock_irq(&grp->list_lock); 544 err = 0; 545 546 __error: 547 up_write(&grp->list_mutex); 548 return err; 536 549 } 537 550 … … 548 561 grp = is_src ? &port->c_src : &port->c_dest; 549 562 list = is_src ? &subs->src_list : &subs->dest_list; 550 scoped_guard(write_lock_irq, &grp->list_lock) {563 write_lock_irq(&grp->list_lock); 551 564 empty = list_empty(list); 552 565 if (!empty) 553 566 list_del_init(list); 554 567 grp->exclusive = 0; 555 }568 write_unlock_irq(&grp->list_lock); 556 569 557 570 if (!empty) … … 567 580 568 581 grp = is_src ? &port->c_src : &port->c_dest; 569 guard(rwsem_write)(&grp->list_mutex);582 down_write(&grp->list_mutex); 570 583 __delete_and_unsubscribe_port(client, port, subs, is_src, ack); 584 up_write(&grp->list_mutex); 571 585 } 572 586 … … 630 644 * deletions 631 645 */ 632 scoped_guard(rwsem_write, &dest->list_mutex) {646 down_write(&dest->list_mutex); 633 647 /* look for the connection */ 634 648 list_for_each_entry(subs, &dest->list_head, dest_list, struct snd_seq_subscribers) { … … 639 653 err = 0; 640 654 break; 641 }642 }643 }655 } 656 } 657 up_write(&dest->list_mutex); 644 658 if (err < 0) 645 659 return err; … … 660 674 int err = -ENOENT; 661 675 662 guard(rwsem_read)(&src_grp->list_mutex);676 down_read(&src_grp->list_mutex); 663 677 list_for_each_entry(s, &src_grp->list_head, src_list, struct snd_seq_subscribers) { 664 678 if (addr_match(dest_addr, &s->info.dest)) { … … 668 682 } 669 683 } 684 up_read(&src_grp->list_mutex); 670 685 return err; 671 686 } -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_prioq.c ¶
r766 r767 133 133 { 134 134 struct snd_seq_event_cell *cur, *prev; 135 unsigned long flags; 135 136 int count; 136 137 int prior; … … 142 143 prior = (cell->event.flags & SNDRV_SEQ_PRIORITY_MASK); 143 144 144 guard(spinlock_irqsave)(&f->lock);145 spin_lock_irqsave(&f->lock, flags); 145 146 146 147 /* check if this element needs to inserted at the end (ie. ordered … … 154 155 cell->next = NULL; 155 156 f->cells++; 157 spin_unlock_irqrestore(&f->lock, flags); 156 158 return 0; 157 159 } … … 179 181 if (! --count) { 180 182 pr_err("ALSA: seq: cannot find a pointer.. infinite loop?\n"); 183 spin_unlock_irqrestore(&f->lock, flags); 181 184 return -EINVAL; 182 185 } … … 193 196 f->tail = cell; 194 197 f->cells++; 198 spin_unlock_irqrestore(&f->lock, flags); 195 199 return 0; 196 200 } … … 210 214 { 211 215 struct snd_seq_event_cell *cell; 216 unsigned long flags; 212 217 213 218 if (f == NULL) { … … 215 220 return NULL; 216 221 } 217 218 guard(spinlock_irqsave)(&f->lock); 222 spin_lock_irqsave(&f->lock, flags); 223 219 224 cell = f->head; 220 225 if (cell && current_time && !event_is_ready(&cell->event, current_time)) … … 231 236 } 232 237 238 spin_unlock_irqrestore(&f->lock, flags); 233 239 return cell; 234 240 } … … 251 257 { 252 258 register struct snd_seq_event_cell *cell, *next; 259 unsigned long flags; 253 260 struct snd_seq_event_cell *prev = NULL; 254 261 struct snd_seq_event_cell *freefirst = NULL, *freeprev = NULL, *freenext; 255 262 256 263 /* collect all removed cells */ 257 s coped_guard(spinlock_irqsave, &f->lock) {258 264 spin_lock_irqsave(&f->lock, flags); 265 for (cell = f->head; cell; cell = next) { 259 266 next = cell->next; 260 261 262 263 267 if (!match(cell, arg)) { 268 prev = cell; 269 continue; 270 } 264 271 265 272 /* remove cell from prioq */ 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 }273 if (cell == f->head) 274 f->head = cell->next; 275 else 276 prev->next = cell->next; 277 if (cell == f->tail) 278 f->tail = cell->next; 279 f->cells--; 280 281 /* add cell to free list */ 282 cell->next = NULL; 283 if (freefirst == NULL) 284 freefirst = cell; 285 else 286 freeprev->next = cell; 287 freeprev = cell; 288 } 289 spin_unlock_irqrestore(&f->lock, flags); 283 290 284 291 /* remove selected cells */ … … 321 328 void snd_seq_prioq_leave(struct snd_seq_prioq *f, int client, int timestamp) 322 329 { 323 struct prioq_match_arg arg = { client, timestamp }; 324 325 return prioq_remove_cells(f, prioq_match, &arg); 330 struct prioq_match_arg arg; 331 arg.client = client; 332 arg.timestamp = timestamp; 333 334 prioq_remove_cells(f, prioq_match, &arg); 326 335 } 327 336 … … 395 404 struct snd_seq_remove_events *info) 396 405 { 397 struct prioq_remove_match_arg arg = { client, info }; 398 399 return prioq_remove_cells(f, prioq_remove_match, &arg); 400 } 406 struct prioq_remove_match_arg arg; 407 arg.client = client; 408 arg.info = info; 409 410 prioq_remove_cells(f, prioq_remove_match, &arg); 411 } -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_queue.c ¶
r766 r767 51 51 { 52 52 int i; 53 54 guard(spinlock_irqsave)(&queue_list_lock); 53 unsigned long flags; 54 55 spin_lock_irqsave(&queue_list_lock, flags); 55 56 for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { 56 57 if (! queue_list[i]) { … … 58 59 q->queue = i; 59 60 num_queues++; 61 spin_unlock_irqrestore(&queue_list_lock, flags); 60 62 return i; 61 63 } 62 64 } 65 spin_unlock_irqrestore(&queue_list_lock, flags); 63 66 return -1; 64 67 } … … 67 70 { 68 71 struct snd_seq_queue *q; 69 70 guard(spinlock_irqsave)(&queue_list_lock); 72 unsigned long flags; 73 74 spin_lock_irqsave(&queue_list_lock, flags); 71 75 q = queue_list[id]; 72 76 if (q) { 73 guard(spinlock)(&q->owner_lock);77 spin_lock(&q->owner_lock); 74 78 if (q->owner == client) { 75 79 /* found */ 80 spin_unlock(&q->owner_lock); 76 81 q->klocked = 1; 77 82 queue_list[id] = NULL; 78 83 num_queues--; 84 spin_unlock_irqrestore(&queue_list_lock, flags); 79 85 return q; 80 86 } 81 } 87 spin_unlock(&q->owner_lock); 88 } 89 spin_unlock_irqrestore(&queue_list_lock, flags); 82 90 return NULL; 83 91 } … … 196 204 { 197 205 struct snd_seq_queue *q; 206 unsigned long flags; 198 207 199 208 if (queueid < 0 || queueid >= SNDRV_SEQ_MAX_QUEUES) 200 209 return NULL; 201 guard(spinlock_irqsave)(&queue_list_lock);210 spin_lock_irqsave(&queue_list_lock, flags); 202 211 q = queue_list[queueid]; 203 212 if (q) 204 213 snd_use_lock_use(&q->use_lock); 214 spin_unlock_irqrestore(&queue_list_lock, flags); 205 215 return q; 206 216 } … … 230 240 void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop) 231 241 { 242 unsigned long flags; 232 243 struct snd_seq_event_cell *cell; 233 244 snd_seq_tick_time_t cur_tick; … … 239 250 240 251 /* make this function non-reentrant */ 241 s coped_guard(spinlock_irqsave, &q->check_lock) {252 spin_lock_irqsave(&q->check_lock, flags); 242 253 if (q->check_blocked) { 243 254 q->check_again = 1; 255 spin_unlock_irqrestore(&q->check_lock, flags); 244 256 return; /* other thread is already checking queues */ 245 257 } 246 258 q->check_blocked = 1; 247 }259 spin_unlock_irqrestore(&q->check_lock, flags); 248 260 249 261 __again: … … 272 284 out: 273 285 /* free lock */ 274 s coped_guard(spinlock_irqsave, &q->check_lock) {286 spin_lock_irqsave(&q->check_lock, flags); 275 287 if (q->check_again) { 276 288 q->check_again = 0; 277 if (processed < MAX_CELL_PROCESSES_IN_QUEUE) 289 if (processed < MAX_CELL_PROCESSES_IN_QUEUE) { 290 spin_unlock_irqrestore(&q->check_lock, flags); 278 291 goto __again; 279 292 } 293 } 280 294 q->check_blocked = 0; 281 }295 spin_unlock_irqrestore(&q->check_lock, flags); 282 296 } 283 297 … … 348 362 static int queue_access_lock(struct snd_seq_queue *q, int client) 349 363 { 364 unsigned long flags; 350 365 int access_ok; 351 366 352 guard(spinlock_irqsave)(&q->owner_lock);367 spin_lock_irqsave(&q->owner_lock, flags); 353 368 access_ok = check_access(q, client); 354 369 if (access_ok) 355 370 q->klocked = 1; 371 spin_unlock_irqrestore(&q->owner_lock, flags); 356 372 return access_ok; 357 373 } … … 360 376 static inline void queue_access_unlock(struct snd_seq_queue *q) 361 377 { 362 guard(spinlock_irqsave)(&q->owner_lock); 378 unsigned long flags; 379 380 spin_lock_irqsave(&q->owner_lock, flags); 363 381 q->klocked = 0; 382 spin_unlock_irqrestore(&q->owner_lock, flags); 364 383 } 365 384 … … 369 388 struct snd_seq_queue *q = queueptr(queueid); 370 389 int access_ok; 390 unsigned long flags; 371 391 372 392 if (! q) 373 393 return 0; 374 s coped_guard(spinlock_irqsave, &q->owner_lock)394 spin_lock_irqsave(&q->owner_lock, flags); 375 395 access_ok = check_access(q, client); 396 spin_unlock_irqrestore(&q->owner_lock, flags); 376 397 queuefree(q); 377 398 return access_ok; … … 386 407 { 387 408 struct snd_seq_queue *q = queueptr(queueid); 409 unsigned long flags; 388 410 389 411 if (q == NULL) … … 395 417 } 396 418 397 s coped_guard(spinlock_irqsave, &q->owner_lock) {419 spin_lock_irqsave(&q->owner_lock, flags); 398 420 q->locked = locked ? 1 : 0; 399 421 q->owner = client; 400 }422 spin_unlock_irqrestore(&q->owner_lock, flags); 401 423 queue_access_unlock(q); 402 424 queuefree(q); … … 730 752 bpm = 0; 731 753 732 s coped_guard(spinlock_irq, &q->owner_lock) {754 spin_lock_irq(&q->owner_lock); 733 755 locked = q->locked; 734 756 owner = q->owner; 735 }757 spin_unlock_irq(&q->owner_lock); 736 758 737 759 snd_iprintf(buffer, "queue %d: [%s]\n", q->queue, q->name); -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_timer.c ¶
r766 r767 79 79 void snd_seq_timer_defaults(struct snd_seq_timer * tmr) 80 80 { 81 guard(spinlock_irqsave)(&tmr->lock); 81 unsigned long flags; 82 83 spin_lock_irqsave(&tmr->lock, flags); 82 84 /* setup defaults */ 83 85 tmr->ppq = 96; /* 96 PPQ */ … … 96 98 97 99 tmr->skew = tmr->skew_base = SKEW_BASE; 100 spin_unlock_irqrestore(&tmr->lock, flags); 98 101 } 99 102 … … 110 113 void snd_seq_timer_reset(struct snd_seq_timer *tmr) 111 114 { 112 guard(spinlock_irqsave)(&tmr->lock); 115 unsigned long flags; 116 117 spin_lock_irqsave(&tmr->lock, flags); 113 118 seq_timer_reset(tmr); 119 spin_unlock_irqrestore(&tmr->lock, flags); 114 120 } 115 121 … … 120 126 unsigned long ticks) 121 127 { 128 unsigned long flags; 122 129 struct snd_seq_queue *q = timeri->callback_data; 123 130 struct snd_seq_timer *tmr; … … 129 136 return; 130 137 131 scoped_guard(spinlock_irqsave, &tmr->lock) { 132 if (!tmr->running) 138 spin_lock_irqsave(&tmr->lock, flags); 139 if (!tmr->running) { 140 spin_unlock_irqrestore(&tmr->lock, flags); 133 141 return; 142 } 134 143 135 144 resolution *= ticks; … … 139 148 (((resolution & 0xffff) * tmr->skew) >> 16); 140 149 } 141 150 142 151 /* update timer */ 143 152 snd_seq_inc_time_nsec(&tmr->cur_time, resolution); … … 148 157 /* register actual time of this timer update */ 149 158 ktime_get_ts64(&tmr->last_update); 150 } 159 160 spin_unlock_irqrestore(&tmr->lock, flags); 151 161 152 162 /* check queues and dispatch events */ … … 157 167 int snd_seq_timer_set_tempo(struct snd_seq_timer * tmr, int tempo) 158 168 { 169 unsigned long flags; 170 159 171 if (snd_BUG_ON(!tmr)) 160 172 return -EINVAL; 161 173 if (tempo <= 0) 162 174 return -EINVAL; 163 guard(spinlock_irqsave)(&tmr->lock);175 spin_lock_irqsave(&tmr->lock, flags); 164 176 if ((unsigned int)tempo != tmr->tempo) { 165 177 tmr->tempo = tempo; 166 178 snd_seq_timer_set_tick_resolution(tmr); 167 179 } 180 spin_unlock_irqrestore(&tmr->lock, flags); 168 181 return 0; 169 182 } … … 174 187 { 175 188 int changed; 189 unsigned long flags; 176 190 177 191 if (snd_BUG_ON(!tmr)) … … 182 196 if (tempo_base && tempo_base != 10 && tempo_base != 1000) 183 197 return -EINVAL; 184 guard(spinlock_irqsave)(&tmr->lock);198 spin_lock_irqsave(&tmr->lock, flags); 185 199 if (tmr->running && (ppq != tmr->ppq)) { 186 200 /* refuse to change ppq on running timers */ 187 201 /* because it will upset the song position (ticks) */ 202 spin_unlock_irqrestore(&tmr->lock, flags); 188 203 pr_debug("ALSA: seq: cannot change ppq of a running timer\n"); 189 204 return -EBUSY; … … 195 210 if (changed) 196 211 snd_seq_timer_set_tick_resolution(tmr); 212 spin_unlock_irqrestore(&tmr->lock, flags); 197 213 return 0; 198 214 } … … 202 218 snd_seq_tick_time_t position) 203 219 { 204 if (snd_BUG_ON(!tmr)) 205 return -EINVAL; 206 207 guard(spinlock_irqsave)(&tmr->lock); 220 unsigned long flags; 221 222 if (snd_BUG_ON(!tmr)) 223 return -EINVAL; 224 225 spin_lock_irqsave(&tmr->lock, flags); 208 226 tmr->tick.cur_tick = position; 209 227 tmr->tick.fraction = 0; 228 spin_unlock_irqrestore(&tmr->lock, flags); 210 229 return 0; 211 230 } … … 215 234 snd_seq_real_time_t position) 216 235 { 236 unsigned long flags; 237 217 238 if (snd_BUG_ON(!tmr)) 218 239 return -EINVAL; 219 240 220 241 snd_seq_sanity_real_time(&position); 221 guard(spinlock_irqsave)(&tmr->lock);242 spin_lock_irqsave(&tmr->lock, flags); 222 243 tmr->cur_time = position; 244 spin_unlock_irqrestore(&tmr->lock, flags); 223 245 return 0; 224 246 } … … 228 250 unsigned int base) 229 251 { 252 unsigned long flags; 253 230 254 if (snd_BUG_ON(!tmr)) 231 255 return -EINVAL; … … 236 260 return -EINVAL; 237 261 } 238 guard(spinlock_irqsave)(&tmr->lock);262 spin_lock_irqsave(&tmr->lock, flags); 239 263 tmr->skew = skew; 264 spin_unlock_irqrestore(&tmr->lock, flags); 240 265 return 0; 241 266 } … … 282 307 return err; 283 308 } 284 s coped_guard(spinlock_irq, &tmr->lock) {309 spin_lock_irq(&tmr->lock); 285 310 if (tmr->timeri) 286 311 err = -EBUSY; 287 312 else 288 313 tmr->timeri = t; 289 }314 spin_unlock_irq(&tmr->lock); 290 315 if (err < 0) { 291 316 snd_timer_close(t); … … 304 329 if (snd_BUG_ON(!tmr)) 305 330 return -EINVAL; 306 s coped_guard(spinlock_irq, &tmr->lock) {331 spin_lock_irq(&tmr->lock); 307 332 t = tmr->timeri; 308 333 tmr->timeri = NULL; 309 }334 spin_unlock_irq(&tmr->lock); 310 335 if (t) { 311 336 snd_timer_close(t); … … 328 353 int snd_seq_timer_stop(struct snd_seq_timer *tmr) 329 354 { 330 guard(spinlock_irqsave)(&tmr->lock); 331 return seq_timer_stop(tmr); 355 unsigned long flags; 356 int err; 357 358 spin_lock_irqsave(&tmr->lock, flags); 359 err = seq_timer_stop(tmr); 360 spin_unlock_irqrestore(&tmr->lock, flags); 361 return err; 332 362 } 333 363 … … 379 409 int snd_seq_timer_start(struct snd_seq_timer *tmr) 380 410 { 381 guard(spinlock_irqsave)(&tmr->lock); 382 return seq_timer_start(tmr); 411 unsigned long flags; 412 int err; 413 414 spin_lock_irqsave(&tmr->lock, flags); 415 err = seq_timer_start(tmr); 416 spin_unlock_irqrestore(&tmr->lock, flags); 417 return err; 383 418 } 384 419 … … 402 437 int snd_seq_timer_continue(struct snd_seq_timer *tmr) 403 438 { 404 guard(spinlock_irqsave)(&tmr->lock); 405 return seq_timer_continue(tmr); 439 unsigned long flags; 440 int err; 441 442 spin_lock_irqsave(&tmr->lock, flags); 443 err = seq_timer_continue(tmr); 444 spin_unlock_irqrestore(&tmr->lock, flags); 445 return err; 406 446 } 407 447 … … 411 451 { 412 452 snd_seq_real_time_t cur_time; 413 414 guard(spinlock_irqsave)(&tmr->lock); 453 unsigned long flags; 454 455 spin_lock_irqsave(&tmr->lock, flags); 415 456 cur_time = tmr->cur_time; 416 457 if (adjust_ktime && tmr->running) { … … 424 465 } 425 466 467 spin_unlock_irqrestore(&tmr->lock, flags); 426 468 return cur_time; 427 469 } … … 431 473 snd_seq_tick_time_t snd_seq_timer_get_cur_tick(struct snd_seq_timer *tmr) 432 474 { 433 guard(spinlock_irqsave)(&tmr->lock); 434 return tmr->tick.cur_tick; 475 snd_seq_tick_time_t cur_tick; 476 unsigned long flags; 477 478 spin_lock_irqsave(&tmr->lock, flags); 479 cur_tick = tmr->tick.cur_tick; 480 spin_unlock_irqrestore(&tmr->lock, flags); 481 return cur_tick; 435 482 } 436 483 … … 451 498 if (q == NULL) 452 499 continue; 453 scoped_guard(mutex, &q->timer_mutex) {500 mutex_lock(&q->timer_mutex); 454 501 tmr = q->timer; 455 502 if (!tmr) 456 break;503 goto unlock; 457 504 ti = tmr->timeri; 458 505 if (!ti) 459 break;506 goto unlock; 460 507 snd_iprintf(buffer, "Timer for queue %i : %s\n", q->queue, ti->timer->name); 461 508 resolution = snd_timer_resolution(ti) * tmr->ticks; 462 509 snd_iprintf(buffer, " Period time : %lu.%09lu\n", resolution / 1000000000, resolution % 1000000000); 463 510 snd_iprintf(buffer, " Skew : %u / %u\n", tmr->skew, tmr->skew_base); 464 } 511 unlock: 512 mutex_unlock(&q->timer_mutex); 465 513 queuefree(q); 466 514 } -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/sound.c ¶
r766 r767 103 103 if (minor >= ARRAY_SIZE(snd_minors)) 104 104 return NULL; 105 guard(mutex)(&sound_mutex);105 mutex_lock(&sound_mutex); 106 106 mreg = snd_minors[minor]; 107 107 if (mreg && mreg->type == type) { … … 111 111 } else 112 112 private_data = NULL; 113 mutex_unlock(&sound_mutex); 113 114 return private_data; 114 115 } … … 149 150 if (minor >= ARRAY_SIZE(snd_minors)) 150 151 return -ENODEV; 151 scoped_guard(mutex, &sound_mutex) {152 mutex_lock(&sound_mutex); 152 153 mptr = snd_minors[minor]; 153 154 if (mptr == NULL) { 154 155 mptr = autoload_device(minor); 155 if (!mptr) 156 if (!mptr) { 157 mutex_unlock(&sound_mutex); 156 158 return -ENODEV; 157 159 } 158 160 #ifndef TARGET_OS2 //code below from 3.13 crashes, using 3.8 code for now 159 161 new_fops = fops_get(mptr->f_ops); 162 mutex_unlock(&sound_mutex); 160 163 } 161 164 if (!new_fops) … … 168 171 #else 169 172 new_fops = file->f_op; 173 mutex_unlock(&sound_mutex); 170 174 } 171 175 file->f_op = fops_get(mptr->f_ops); … … 291 295 preg->private_data = private_data; 292 296 preg->card_ptr = card; 293 guard(mutex)(&sound_mutex);297 mutex_lock(&sound_mutex); 294 298 minor = snd_find_free_minor(type, card, dev); 295 299 if (minor < 0) { … … 306 310 snd_minors[minor] = preg; 307 311 error: 312 mutex_unlock(&sound_mutex); 308 313 if (err < 0) 309 314 kfree(preg); … … 326 331 struct snd_minor *preg; 327 332 328 guard(mutex)(&sound_mutex);333 mutex_lock(&sound_mutex); 329 334 for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) { 330 335 preg = snd_minors[minor]; … … 336 341 } 337 342 } 343 mutex_unlock(&sound_mutex); 338 344 if (minor >= ARRAY_SIZE(snd_minors)) 339 345 return -ENOENT; … … 375 381 struct snd_minor *mptr; 376 382 377 guard(mutex)(&sound_mutex);383 mutex_lock(&sound_mutex); 378 384 for (minor = 0; minor < SNDRV_OS_MINORS; ++minor) { 379 385 mptr = snd_minors[minor]; … … 393 399 snd_device_type_name(mptr->type)); 394 400 } 401 mutex_unlock(&sound_mutex); 395 402 } 396 403 -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/sound_oss.c ¶
r766 r767 34 34 if (minor >= ARRAY_SIZE(snd_oss_minors)) 35 35 return NULL; 36 guard(mutex)(&sound_oss_mutex);36 mutex_lock(&sound_oss_mutex); 37 37 mreg = snd_oss_minors[minor]; 38 38 if (mreg && mreg->type == type) { … … 42 42 } else 43 43 private_data = NULL; 44 mutex_unlock(&sound_oss_mutex); 44 45 return private_data; 45 46 } … … 110 111 preg->private_data = private_data; 111 112 preg->card_ptr = card; 112 guard(mutex)(&sound_oss_mutex);113 mutex_lock(&sound_oss_mutex); 113 114 snd_oss_minors[minor] = preg; 114 115 minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); … … 136 137 } 137 138 #endif 139 mutex_unlock(&sound_oss_mutex); 138 140 return 0; 139 141 … … 145 147 unregister_sound_special(register1); 146 148 snd_oss_minors[minor] = NULL; 149 mutex_unlock(&sound_oss_mutex); 147 150 kfree(preg); 148 151 return -EBUSY; … … 162 165 if (minor < 0) 163 166 return minor; 164 guard(mutex)(&sound_oss_mutex);167 mutex_lock(&sound_oss_mutex); 165 168 mptr = snd_oss_minors[minor]; 166 if (mptr == NULL) 169 if (mptr == NULL) { 170 mutex_unlock(&sound_oss_mutex); 167 171 return -ENOENT; 172 } 168 173 switch (SNDRV_MINOR_OSS_DEVICE(minor)) { 169 174 case SNDRV_MINOR_OSS_PCM: … … 180 185 snd_oss_minors[track2] = NULL; 181 186 snd_oss_minors[minor] = NULL; 187 mutex_unlock(&sound_oss_mutex); 182 188 183 189 /* call unregister_sound_special() outside sound_oss_mutex; … … 223 229 struct snd_minor *mptr; 224 230 225 guard(mutex)(&sound_oss_mutex);231 mutex_lock(&sound_oss_mutex); 226 232 for (minor = 0; minor < SNDRV_OSS_MINORS; ++minor) { 227 233 mptr = snd_oss_minors[minor]; … … 236 242 snd_oss_device_type_name(mptr->type)); 237 243 } 244 mutex_unlock(&sound_oss_mutex); 238 245 } 239 246 -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/timer.c ¶
r766 r767 14 14 #include <linux/string.h> 15 15 #include <linux/sched/signal.h> 16 #ifndef TARGET_OS2 16 17 #include <linux/anon_inodes.h> 17 18 #include <linux/idr.h> 19 #endif 18 20 #include <sound/core.h> 19 21 #include <sound/timer.h> … … 238 240 list_move_tail(&slave->open_list, &master->slave_list_head); 239 241 master->timer->num_instances++; 240 guard(spinlock_irq)(&slave_active_lock);241 guard(spinlock)(&master->timer->lock);242 spin_lock_irq(&slave_active_lock); 243 spin_lock(&master->timer->lock); 242 244 slave->master = master; 243 245 slave->timer = master->timer; 244 246 if (slave->flags & SNDRV_TIMER_IFLG_RUNNING) 245 247 list_add_tail(&slave->active_list, &master->slave_active_head); 248 spin_unlock(&master->timer->lock); 249 spin_unlock_irq(&slave_active_lock); 246 250 return 1; 247 251 } … … 400 404 struct snd_timer_instance *slave, *tmp; 401 405 402 guard(spinlock_irq)(&slave_active_lock);403 guard(spinlock)(&timer->lock);406 spin_lock_irq(&slave_active_lock); 407 spin_lock(&timer->lock); 404 408 timeri->timer = NULL; 405 list_for_each_entry_safe(slave, tmp, &timeri->slave_list_head, open_list ) {409 list_for_each_entry_safe(slave, tmp, &timeri->slave_list_head, open_list, struct snd_timer_instance) { 406 410 list_move_tail(&slave->open_list, &snd_timer_slave_list); 407 411 timer->num_instances--; … … 411 415 list_del_init(&slave->active_list); 412 416 } 417 spin_unlock_irq(&slave_active_lock); 418 spin_unlock(&timer->lock); 413 419 } 414 420 … … 421 427 { 422 428 struct snd_timer *timer = timeri->timer; 429 struct snd_timer_instance *slave, *tmp; 423 430 424 431 if (timer) { 425 guard(spinlock_irq)(&timer->lock);432 spin_lock_irq(&timer->lock); 426 433 timeri->flags |= SNDRV_TIMER_IFLG_DEAD; 434 spin_unlock_irq(&timer->lock); 427 435 } 428 436 … … 449 457 remove_slave_links(timeri, timer); 450 458 459 /* slave doesn't need to release timer resources below */ 460 if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) 461 timer = NULL; 462 } 463 451 464 if (timer) { 452 465 if (list_empty(&timer->open_list_head) && timer->hw.close) … … 469 482 return; 470 483 471 scoped_guard(mutex, ®ister_mutex)484 mutex_lock(®ister_mutex); 472 485 snd_timer_close_locked(timeri, &card_dev_to_put); 486 mutex_unlock(®ister_mutex); 473 487 /* put_device() is called after unlock for avoiding deadlock */ 474 488 if (card_dev_to_put) … … 489 503 struct snd_timer * timer; 490 504 unsigned long ret = 0; 505 unsigned long flags; 491 506 492 507 if (timeri == NULL) … … 494 509 timer = timeri->timer; 495 510 if (timer) { 496 guard(spinlock_irqsave)(&timer->lock);511 spin_lock_irqsave(&timer->lock, flags); 497 512 ret = snd_timer_hw_resolution(timer); 513 spin_unlock_irqrestore(&timer->lock, flags); 498 514 } 499 515 return ret; … … 539 555 struct snd_timer *timer; 540 556 int result; 557 unsigned long flags; 541 558 542 559 timer = timeri->timer; 543 560 if (!timer) 544 561 return -EINVAL; 545 546 guard(spinlock_irqsave)(&timer->lock); 547 if (timeri->flags & SNDRV_TIMER_IFLG_DEAD) 548 return -EINVAL; 549 if (timer->card && timer->card->shutdown) 550 return -ENODEV; 562 spin_lock_irqsave(&timer->lock, flags); 563 if (timeri->flags & SNDRV_TIMER_IFLG_DEAD) { 564 result = -EINVAL; 565 goto unlock; 566 } 567 if (timer->card && timer->card->shutdown) { 568 result = -ENODEV; 569 goto unlock; 570 } 551 571 if (timeri->flags & (SNDRV_TIMER_IFLG_RUNNING | 552 SNDRV_TIMER_IFLG_START)) 553 return -EBUSY; 572 SNDRV_TIMER_IFLG_START)) { 573 result = -EBUSY; 574 goto unlock; 575 } 554 576 555 577 /* check the actual time for the start tick; … … 557 579 */ 558 580 if (start && !(timer->hw.flags & SNDRV_TIMER_HW_SLAVE)) { 559 if ((u64)snd_timer_hw_resolution(timer) * ticks < 100000) 560 return -EINVAL; 581 if ((u64)snd_timer_hw_resolution(timer) * ticks < 100000) { 582 result = -EINVAL; 583 goto unlock; 584 } 561 585 } 562 586 … … 585 609 snd_timer_notify1(timeri, start ? SNDRV_TIMER_EVENT_START : 586 610 SNDRV_TIMER_EVENT_CONTINUE); 611 unlock: 612 spin_unlock_irqrestore(&timer->lock, flags); 587 613 return result; 588 614 } … … 592 618 bool start) 593 619 { 594 guard(spinlock_irqsave)(&slave_active_lock); 595 if (timeri->flags & SNDRV_TIMER_IFLG_DEAD) 596 return -EINVAL; 597 if (timeri->flags & SNDRV_TIMER_IFLG_RUNNING) 598 return -EBUSY; 620 unsigned long flags; 621 int err; 622 623 spin_lock_irqsave(&slave_active_lock, flags); 624 if (timeri->flags & SNDRV_TIMER_IFLG_DEAD) { 625 err = -EINVAL; 626 goto unlock; 627 } 628 if (timeri->flags & SNDRV_TIMER_IFLG_RUNNING) { 629 err = -EBUSY; 630 goto unlock; 631 } 599 632 timeri->flags |= SNDRV_TIMER_IFLG_RUNNING; 600 633 if (timeri->master && timeri->timer) { 601 guard(spinlock)(&timeri->timer->lock);634 spin_lock(&timeri->timer->lock); 602 635 list_add_tail(&timeri->active_list, 603 636 &timeri->master->slave_active_head); 604 637 snd_timer_notify1(timeri, start ? SNDRV_TIMER_EVENT_START : 605 638 SNDRV_TIMER_EVENT_CONTINUE); 606 } 607 return 1; /* delayed start */ 639 spin_unlock(&timeri->timer->lock); 640 } 641 err = 1; /* delayed start */ 642 unlock: 643 spin_unlock_irqrestore(&slave_active_lock, flags); 644 return err; 608 645 } 609 646 … … 612 649 { 613 650 struct snd_timer *timer; 651 int result = 0; 652 unsigned long flags; 614 653 615 654 timer = timeri->timer; 616 655 if (!timer) 617 656 return -EINVAL; 618 guard(spinlock_irqsave)(&timer->lock);657 spin_lock_irqsave(&timer->lock, flags); 619 658 list_del_init(&timeri->ack_list); 620 659 list_del_init(&timeri->active_list); 621 660 if (!(timeri->flags & (SNDRV_TIMER_IFLG_RUNNING | 622 SNDRV_TIMER_IFLG_START))) 623 return -EBUSY; 661 SNDRV_TIMER_IFLG_START))) { 662 result = -EBUSY; 663 goto unlock; 664 } 624 665 if (timer->card && timer->card->shutdown) 625 return 0;666 goto unlock; 626 667 if (stop) { 627 668 timeri->cticks = timeri->ticks; … … 647 688 snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP : 648 689 SNDRV_TIMER_EVENT_PAUSE); 649 return 0; 690 unlock: 691 spin_unlock_irqrestore(&timer->lock, flags); 692 return result; 650 693 } 651 694 … … 653 696 static int snd_timer_stop_slave(struct snd_timer_instance *timeri, bool stop) 654 697 { 698 unsigned long flags; 655 699 bool running; 656 700 657 guard(spinlock_irqsave)(&slave_active_lock);701 spin_lock_irqsave(&slave_active_lock, flags); 658 702 running = timeri->flags & SNDRV_TIMER_IFLG_RUNNING; 659 703 timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING; 660 704 if (timeri->timer) { 661 guard(spinlock)(&timeri->timer->lock);705 spin_lock(&timeri->timer->lock); 662 706 list_del_init(&timeri->ack_list); 663 707 list_del_init(&timeri->active_list); … … 665 709 snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP : 666 710 SNDRV_TIMER_EVENT_PAUSE); 667 } 711 spin_unlock(&timeri->timer->lock); 712 } 713 spin_unlock_irqrestore(&slave_active_lock, flags); 668 714 return running ? 0 : -EBUSY; 669 715 } … … 790 836 struct list_head *head) 791 837 { 792 guard(spinlock_irqsave)(&timer->lock); 838 unsigned long flags; 839 840 spin_lock_irqsave(&timer->lock, flags); 793 841 while (!list_empty(head)) 794 842 list_del_init(head->next); 843 spin_unlock_irqrestore(&timer->lock, flags); 795 844 } 796 845 … … 806 855 { 807 856 struct snd_timer *timer = container_of(work, struct snd_timer, task_work); 857 unsigned long flags; 808 858 809 859 if (timer->card && timer->card->shutdown) { … … 812 862 } 813 863 814 guard(spinlock_irqsave)(&timer->lock);864 spin_lock_irqsave(&timer->lock, flags); 815 865 snd_timer_process_callbacks(timer, &timer->sack_list_head); 866 spin_unlock_irqrestore(&timer->lock, flags); 816 867 } 817 868 … … 827 878 unsigned long resolution; 828 879 struct list_head *ack_list_head; 880 unsigned long flags; 881 bool use_work = false; 829 882 830 883 if (timer == NULL) … … 836 889 } 837 890 838 guard(spinlock_irqsave)(&timer->lock);891 spin_lock_irqsave(&timer->lock, flags); 839 892 840 893 /* remember the current resolution */ … … 902 955 903 956 /* do we have any slow callbacks? */ 957 use_work = !list_empty(&timer->sack_list_head); 958 spin_unlock_irqrestore(&timer->lock, flags); 959 904 960 #ifndef TARGET_OS2 905 if ( !list_empty(&timer->sack_list_head))961 if (use_work) 906 962 queue_work(system_highpri_wq, &timer->task_work); 907 963 #endif … … 970 1026 return 0; 971 1027 972 guard(mutex)(®ister_mutex);1028 mutex_lock(®ister_mutex); 973 1029 if (! list_empty(&timer->open_list_head)) { 974 1030 struct list_head *p, *n; … … 982 1038 } 983 1039 list_del(&timer->device_list); 1040 mutex_unlock(®ister_mutex); 984 1041 985 1042 if (timer->private_free) … … 1006 1063 return -EINVAL; 1007 1064 1008 guard(mutex)(®ister_mutex);1065 mutex_lock(®ister_mutex); 1009 1066 list_for_each_entry(timer1, &snd_timer_list, device_list, struct snd_timer) { 1010 1067 if (timer1->tmr_class > timer->tmr_class) … … 1027 1084 continue; 1028 1085 /* conflicts.. */ 1086 mutex_unlock(®ister_mutex); 1029 1087 return -EBUSY; 1030 1088 } 1031 1089 list_add_tail(&timer->device_list, &timer1->device_list); 1090 mutex_unlock(®ister_mutex); 1032 1091 return 0; 1033 1092 } … … 1038 1097 struct snd_timer_instance *ti; 1039 1098 1040 guard(mutex)(®ister_mutex);1099 mutex_lock(®ister_mutex); 1041 1100 list_del_init(&timer->device_list); 1042 1101 /* wake up pending sleepers */ … … 1045 1104 ti->disconnect(ti); 1046 1105 } 1106 mutex_unlock(®ister_mutex); 1047 1107 return 0; 1048 1108 } … … 1050 1110 void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp) 1051 1111 { 1112 unsigned long flags; 1052 1113 unsigned long resolution = 0; 1053 1114 struct snd_timer_instance *ti, *ts; … … 1060 1121 event > SNDRV_TIMER_EVENT_MRESUME)) 1061 1122 return; 1062 guard(spinlock_irqsave)(&timer->lock);1123 spin_lock_irqsave(&timer->lock, flags); 1063 1124 if (event == SNDRV_TIMER_EVENT_MSTART || 1064 1125 event == SNDRV_TIMER_EVENT_MCONTINUE || … … 1072 1133 ts->ccallback(ts, event, tstamp, resolution); 1073 1134 } 1135 spin_unlock_irqrestore(&timer->lock, flags); 1074 1136 } 1075 1137 EXPORT_SYMBOL(snd_timer_notify); … … 1233 1295 unsigned long resolution; 1234 1296 1235 guard(mutex)(®ister_mutex);1297 mutex_lock(®ister_mutex); 1236 1298 list_for_each_entry(timer, &snd_timer_list, device_list, struct snd_timer) { 1237 1299 if (timer->card && timer->card->shutdown) … … 1255 1317 } 1256 1318 snd_iprintf(buffer, "%s :", timer->name); 1257 s coped_guard(spinlock_irq, &timer->lock)1319 spin_lock_irq(&timer->lock); 1258 1320 resolution = snd_timer_hw_resolution(timer); 1321 spin_unlock_irq(&timer->lock); 1259 1322 if (resolution) 1260 1323 snd_iprintf(buffer, " %lu.%03luus (%lu ticks)", … … 1272 1335 ? "running" : "stopped"); 1273 1336 } 1337 mutex_unlock(®ister_mutex); 1274 1338 } 1275 1339 … … 1312 1376 int prev; 1313 1377 1314 guard(spinlock)(&tu->qlock);1378 spin_lock(&tu->qlock); 1315 1379 if (tu->qused > 0) { 1316 1380 prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1; … … 1331 1395 } 1332 1396 __wake: 1397 spin_unlock(&tu->qlock); 1333 1398 snd_kill_fasync(tu->fasync, SIGIO, POLL_IN); 1334 1399 wake_up(&tu->qchange_sleep); … … 1354 1419 struct snd_timer_user *tu = timeri->callback_data; 1355 1420 struct snd_timer_tread64 r1; 1421 unsigned long flags; 1356 1422 1357 1423 if (event >= SNDRV_TIMER_EVENT_START && … … 1365 1431 r1.tstamp_nsec = tstamp->tv_nsec; 1366 1432 r1.val = resolution; 1367 s coped_guard(spinlock_irqsave, &tu->qlock)1433 spin_lock_irqsave(&tu->qlock, flags); 1368 1434 snd_timer_user_append_to_tqueue(tu, &r1); 1435 spin_unlock_irqrestore(&tu->qlock, flags); 1369 1436 snd_kill_fasync(tu->fasync, SIGIO, POLL_IN); 1370 1437 wake_up(&tu->qchange_sleep); … … 1390 1457 memset(&r1, 0, sizeof(r1)); 1391 1458 memset(&tstamp, 0, sizeof(tstamp)); 1392 s coped_guard(spinlock, &tu->qlock) {1459 spin_lock(&tu->qlock); 1393 1460 if ((tu->filter & ((1 << SNDRV_TIMER_EVENT_RESOLUTION) | 1394 (1 << SNDRV_TIMER_EVENT_TICK))) == 0) 1461 (1 << SNDRV_TIMER_EVENT_TICK))) == 0) { 1462 spin_unlock(&tu->qlock); 1395 1463 return; 1464 } 1396 1465 if (tu->last_resolution != resolution || ticks > 0) { 1397 1466 if (timer_tstamp_monotonic) … … 1406 1475 r1.tstamp_nsec = tstamp.tv_nsec; 1407 1476 r1.val = resolution; 1408 snd_timer_user_append_to_tqueue(tu, &r1);1477 snd_timer_user_append_to_tqueue(tu, &r1); 1409 1478 tu->last_resolution = resolution; 1410 append++;1411 }1479 append++; 1480 } 1412 1481 if ((tu->filter & (1 << SNDRV_TIMER_EVENT_TICK)) == 0) 1413 break;1482 goto __wake; 1414 1483 if (ticks == 0) 1415 break;1484 goto __wake; 1416 1485 if (tu->qused > 0) { 1417 1486 prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1; … … 1422 1491 r->val += ticks; 1423 1492 append++; 1424 break;1493 goto __wake; 1425 1494 } 1426 1495 } … … 1431 1500 snd_timer_user_append_to_tqueue(tu, &r1); 1432 1501 append++; 1433 } 1502 __wake: 1503 spin_unlock(&tu->qlock); 1434 1504 if (append == 0) 1435 1505 return; … … 1453 1523 } 1454 1524 1455 guard(spinlock_irq)(&tu->qlock);1525 spin_lock_irq(&tu->qlock); 1456 1526 kfree(tu->queue); 1457 1527 kfree(tu->tqueue); … … 1460 1530 tu->tqueue = tqueue; 1461 1531 tu->qhead = tu->qtail = tu->qused = 0; 1532 spin_unlock_irq(&tu->qlock); 1462 1533 1463 1534 return 0; … … 1495 1566 tu = file->private_data; 1496 1567 file->private_data = NULL; 1497 scoped_guard(mutex, &tu->ioctl_lock) {1568 mutex_lock(&tu->ioctl_lock); 1498 1569 if (tu->timeri) { 1499 1570 snd_timer_close(tu->timeri); 1500 1571 snd_timer_instance_free(tu->timeri); 1501 1572 } 1502 }1573 mutex_unlock(&tu->ioctl_lock); 1503 1574 snd_fasync_free(tu->fasync); 1504 1575 kfree(tu->queue); … … 1535 1606 if (copy_from_user(&id, _tid, sizeof(id))) 1536 1607 return -EFAULT; 1537 guard(mutex)(®ister_mutex);1608 mutex_lock(®ister_mutex); 1538 1609 if (id.dev_class < 0) { /* first item */ 1539 1610 if (list_empty(&snd_timer_list)) … … 1612 1683 } 1613 1684 } 1685 mutex_unlock(®ister_mutex); 1614 1686 if (copy_to_user(_tid, &id, sizeof(*_tid))) 1615 1687 return -EFAULT; … … 1624 1696 struct snd_timer *t; 1625 1697 struct list_head *p; 1698 int err = 0; 1626 1699 1627 1700 ginfo = memdup_user(_ginfo, sizeof(*ginfo)); … … 1632 1705 memset(ginfo, 0, sizeof(*ginfo)); 1633 1706 ginfo->tid = tid; 1634 guard(mutex)(®ister_mutex);1707 mutex_lock(®ister_mutex); 1635 1708 t = snd_timer_find(&tid); 1636 if (!t) 1637 return -ENODEV; 1709 if (t != NULL) { 1638 1710 ginfo->card = t->card ? t->card->number : -1; 1639 1711 if (t->hw.flags & SNDRV_TIMER_HW_SLAVE) … … 1641 1713 strscpy(ginfo->id, t->id, sizeof(ginfo->id)); 1642 1714 strscpy(ginfo->name, t->name, sizeof(ginfo->name)); 1643 scoped_guard(spinlock_irq, &t->lock)1715 spin_lock_irq(&t->lock); 1644 1716 ginfo->resolution = snd_timer_hw_resolution(t); 1717 spin_unlock_irq(&t->lock); 1645 1718 if (t->hw.resolution_min > 0) { 1646 1719 ginfo->resolution_min = t->hw.resolution_min; … … 1650 1723 ginfo->clients++; 1651 1724 } 1652 if (copy_to_user(_ginfo, ginfo, sizeof(*ginfo))) 1653 return -EFAULT; 1654 return 0; 1725 } else { 1726 err = -ENODEV; 1727 } 1728 mutex_unlock(®ister_mutex); 1729 if (err >= 0 && copy_to_user(_ginfo, ginfo, sizeof(*ginfo))) 1730 err = -EFAULT; 1731 kfree(ginfo); 1732 return err; 1655 1733 } 1656 1734 … … 1658 1736 { 1659 1737 struct snd_timer *t; 1660 1661 guard(mutex)(®ister_mutex); 1738 int err; 1739 1740 mutex_lock(®ister_mutex); 1662 1741 t = snd_timer_find(&gparams->tid); 1663 if (!t) 1664 return -ENODEV; 1665 if (!list_empty(&t->open_list_head)) 1666 return -EBUSY; 1667 if (!t->hw.set_period) 1668 return -ENOSYS; 1669 return t->hw.set_period(t, gparams->period_num, gparams->period_den); 1742 if (!t) { 1743 err = -ENODEV; 1744 goto _error; 1745 } 1746 if (!list_empty(&t->open_list_head)) { 1747 err = -EBUSY; 1748 goto _error; 1749 } 1750 if (!t->hw.set_period) { 1751 err = -ENOSYS; 1752 goto _error; 1753 } 1754 err = t->hw.set_period(t, gparams->period_num, gparams->period_den); 1755 _error: 1756 mutex_unlock(®ister_mutex); 1757 return err; 1670 1758 } 1671 1759 … … 1693 1781 memset(&gstatus, 0, sizeof(gstatus)); 1694 1782 gstatus.tid = tid; 1695 guard(mutex)(®ister_mutex);1783 mutex_lock(®ister_mutex); 1696 1784 t = snd_timer_find(&tid); 1697 1785 if (t != NULL) { 1698 guard(spinlock_irq)(&t->lock);1786 spin_lock_irq(&t->lock); 1699 1787 gstatus.resolution = snd_timer_hw_resolution(t); 1700 1788 if (t->hw.precise_resolution) { … … 1705 1793 gstatus.resolution_den = 1000000000uL; 1706 1794 } 1795 spin_unlock_irq(&t->lock); 1707 1796 } else { 1708 1797 err = -ENODEV; 1709 1798 } 1799 mutex_unlock(®ister_mutex); 1710 1800 if (err >= 0 && copy_to_user(_gstatus, &gstatus, sizeof(gstatus))) 1711 1801 err = -EFAULT; … … 1763 1853 struct snd_timer_info *info __free(kfree) = NULL; 1764 1854 struct snd_timer *t; 1855 int err = 0; 1765 1856 1766 1857 tu = file->private_data; … … 1779 1870 strscpy(info->id, t->id, sizeof(info->id)); 1780 1871 strscpy(info->name, t->name, sizeof(info->name)); 1781 s coped_guard(spinlock_irq, &t->lock)1872 spin_lock_irq(&t->lock); 1782 1873 info->resolution = snd_timer_hw_resolution(t); 1874 spin_unlock_irq(&t->lock); 1783 1875 if (copy_to_user(_info, info, sizeof(*_info))) 1784 return -EFAULT; 1785 return 0; 1876 err = -EFAULT; 1877 kfree(info); 1878 return err; 1786 1879 } 1787 1880 … … 1841 1934 } 1842 1935 snd_timer_stop(tu->timeri); 1843 s coped_guard(spinlock_irq, &t->lock) {1936 spin_lock_irq(&t->lock); 1844 1937 tu->timeri->flags &= ~(SNDRV_TIMER_IFLG_AUTO| 1845 1938 SNDRV_TIMER_IFLG_EXCLUSIVE| … … 1851 1944 if (params.flags & SNDRV_TIMER_PSFLG_EARLY_EVENT) 1852 1945 tu->timeri->flags |= SNDRV_TIMER_IFLG_EARLY_EVENT; 1853 }1946 spin_unlock_irq(&t->lock); 1854 1947 if (params.queue_size > 0 && 1855 1948 (unsigned int)tu->queue_size != params.queue_size) { … … 1858 1951 goto _end; 1859 1952 } 1860 s coped_guard(spinlock_irq, &tu->qlock) {1953 spin_lock_irq(&tu->qlock); 1861 1954 tu->qhead = tu->qtail = tu->qused = 0; 1862 1955 if (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) { 1863 1956 if (tu->tread) { 1864 1957 struct snd_timer_tread64 tread; 1865 1866 1958 memset(&tread, 0, sizeof(tread)); 1867 1959 tread.event = SNDRV_TIMER_EVENT_EARLY; … … 1872 1964 } else { 1873 1965 struct snd_timer_read *r = &tu->queue[0]; 1874 1875 1966 r->resolution = 0; 1876 1967 r->ticks = 0; … … 1881 1972 tu->filter = params.filter; 1882 1973 tu->ticks = params.ticks; 1883 }1974 spin_unlock_irq(&tu->qlock); 1884 1975 err = 0; 1885 1976 _end: … … 1904 1995 status.lost = tu->timeri->lost; 1905 1996 status.overrun = tu->overrun; 1906 s coped_guard(spinlock_irq, &tu->qlock)1997 spin_lock_irq(&tu->qlock); 1907 1998 status.queue = tu->qused; 1999 spin_unlock_irq(&tu->qlock); 1908 2000 if (copy_to_user(_status, &status, sizeof(status))) 1909 2001 return -EFAULT; … … 1926 2018 status.lost = tu->timeri->lost; 1927 2019 status.overrun = tu->overrun; 1928 s coped_guard(spinlock_irq, &tu->qlock)2020 spin_lock_irq(&tu->qlock); 1929 2021 status.queue = tu->qused; 2022 spin_unlock_irq(&tu->qlock); 1930 2023 if (copy_to_user(_status, &status, sizeof(status))) 1931 2024 return -EFAULT; … … 2298 2391 { 2299 2392 struct snd_timer_user *tu = file->private_data; 2300 2301 guard(mutex)(&tu->ioctl_lock); 2302 return __snd_timer_user_ioctl(file, cmd, arg, false); 2393 long ret; 2394 2395 mutex_lock(&tu->ioctl_lock); 2396 ret = __snd_timer_user_ioctl(file, cmd, arg, false); 2397 mutex_unlock(&tu->ioctl_lock); 2398 return ret; 2303 2399 } 2304 2400 … … 2435 2531 2436 2532 mask = 0; 2437 guard(spinlock_irq)(&tu->qlock);2533 spin_lock_irq(&tu->qlock); 2438 2534 if (tu->qused) 2439 2535 mask |= EPOLLIN | EPOLLRDNORM; 2440 2536 if (tu->disconnected) 2441 2537 mask |= EPOLLERR; 2538 spin_unlock_irq(&tu->qlock); 2442 2539 2443 2540 return mask; -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/hda/hdac_stream.c ¶
r766 r767 333 333 snd_hdac_stream_updatel(azx_dev, SD_CTL, 0, SD_INT_MASK); 334 334 335 #ifdef TARGET_OS2 336 azx_dev->fifo_size = snd_hdac_stream_readw(azx_dev, SD_FIFOSIZE) + 1; 337 #else 335 338 if (!code_loading) { 336 339 /* Once SDxFMT is set, the controller programs SDxFIFOS to non-zero value. */ … … 342 345 azx_dev->fifo_size = reg; 343 346 } 344 347 #endif 345 348 /* when LPIB delay correction gives a small negative value, 346 349 * we ignore it; currently set the threshold statically to -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/include/sound/control.h ¶
r766 r767 82 82 void *private_data; 83 83 void (*private_free)(struct snd_kcontrol *kcontrol); 84 struct snd_kcontrol_volatile vd[ ] __counted_by(count); /* volatile data */84 struct snd_kcontrol_volatile vd[1] __counted_by(count); /* volatile data */ 85 85 }; 86 86 -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/include/sound/hdaudio.h ¶
r766 r767 19 19 #include <sound/memalloc.h> 20 20 #include <sound/hda_verbs.h> 21 #ifndef TARGET_OS2 21 22 #include <drm/intel/i915_component.h> 23 #endif 22 24 23 25 /* codec node id */ -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/include/sound/pcm.h ¶
r766 r767 684 684 } while (0) 685 685 686 #ifndef TARGET_OS2 686 687 /* definitions for guard(); use like guard(pcm_stream_lock) */ 687 688 DEFINE_LOCK_GUARD_1(pcm_stream_lock, struct snd_pcm_substream, … … 695 696 snd_pcm_stream_unlock_irqrestore(_T->lock, _T->flags), 696 697 unsigned long flags) 698 #endif 697 699 698 700 /** -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/include/uapi/sound/asound.h ¶
r766 r767 363 363 unsigned short id16[8]; 364 364 unsigned int id32[4]; 365 } __attribute__((deprecated));365 } /*__attribute__((deprecated))*/; 366 366 367 367 struct snd_pcm_info { -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/pci/ac97/ac97_codec.c ¶
r762 r767 3028 3028 result = apply_quirk_str(ac97, override); 3029 3029 if (result < 0) 3030 snd_printk(KERN_ERR "applying quirk type %s failed (%d)\n", override, result); 3030 ac97_err(ac97, "applying quirk type %s failed (%d)\n", 3031 override, result); 3031 3032 return result; 3032 3033 } … … 3042 3043 if (quirk->codec_id && quirk->codec_id != ac97->id) 3043 3044 continue; 3044 snd_printdd("ac97 quirk for %s (%04x:%04x)\n", quirk->name, ac97->subsystem_vendor, ac97->subsystem_device); 3045 ac97_dbg(ac97, "ac97 quirk for %s (%04x:%04x)\n", 3046 quirk->name, ac97->subsystem_vendor, 3047 ac97->subsystem_device); 3045 3048 result = apply_quirk(ac97, quirk->type); 3046 3049 if (result < 0) 3047 snd_printk(KERN_ERR "applying quirk type %d for %s failed (%d)\n", quirk->type, quirk->name, result); 3050 ac97_err(ac97, 3051 "applying quirk type %d for %s failed (%d)\n", 3052 quirk->type, quirk->name, result); 3048 3053 return result; 3049 3054 } -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/Makefile ¶
r708 r767 12 12 # 13 13 #=================================================================== 14 FILES = hda_intel.obj hda_codec.obj hda_controller.obj hda_auto_parser.obj hda_jack.obj & 15 hda_proc.obj hda_generic.obj hda_hwdep.obj hda_sysfs.obj hda_bind.obj hda_eld.obj & 16 patch_analog.obj patch_cmedia.obj patch_conexant.obj patch_ca0110.obj patch_ca0132.obj patch_cirrus.obj & 17 patch_hdmi.obj patch_realtek.obj patch_si3054.obj patch_sigmatel.obj patch_via.obj 14 FILES = hda_intel.obj hda_codec.obj hda_controller.obj hda_auto_parser.obj & 15 hda_jack.obj hda_proc.obj hda_generic.obj hda_hwdep.obj hda_sysfs.obj & 16 hda_bind.obj hda_eld.obj hda_component.obj patch_analog.obj & 17 patch_cmedia.obj patch_conexant.obj patch_ca0110.obj patch_ca0132.obj & 18 patch_cirrus.obj patch_hdmi.obj patch_realtek.obj patch_si3054.obj & 19 patch_sigmatel.obj patch_via.obj 18 20 19 21 TARGET = hda -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/hda_component2.h ¶
r763 r767 7 7 */ 8 8 9 #ifndef __HDA_COMPONENT_H__ 10 #define __HDA_COMPONENT_H__ 11 12 #include <linux/acpi.h> 9 13 #include <linux/component.h> 14 #include <linux/mutex.h> 15 #include <sound/hda_codec.h> 10 16 11 17 #define HDA_MAX_COMPONENTS 4 … … 15 21 struct device *dev; 16 22 char name[HDA_MAX_NAME_SIZE]; 17 struct hda_codec *codec; 23 struct acpi_device *adev; 24 bool acpi_notifications_supported; 25 // void (*acpi_notify)(acpi_handle handle, u32 event, struct device *dev); 18 26 void (*pre_playback_hook)(struct device *dev, int action); 19 27 void (*playback_hook)(struct device *dev, int action); 20 28 void (*post_playback_hook)(struct device *dev, int action); 21 29 }; 30 31 struct hda_component_parent { 32 struct mutex mutex; 33 struct hda_codec *codec; 34 struct hda_component comps[HDA_MAX_COMPONENTS]; 35 }; 36 37 #ifdef CONFIG_ACPI 38 void hda_component_acpi_device_notify(struct hda_component_parent *parent, 39 acpi_handle handle, u32 event, void *data); 40 int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc, 41 struct hda_component_parent *parent, 42 acpi_notify_handler handler, void *data); 43 void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc, 44 struct hda_component_parent *parent, 45 acpi_notify_handler handler); 46 #else 47 static inline void hda_component_acpi_device_notify(struct hda_component_parent *parent, 48 acpi_handle handle, 49 u32 event, 50 void *data) 51 { 52 } 53 54 static inline int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc, 55 struct hda_component_parent *parent, 56 acpi_notify_handler handler, 57 void *data) 58 59 { 60 return 0; 61 } 62 63 static inline void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc, 64 struct hda_component_parent *parent, 65 acpi_notify_handler handler) 66 { 67 } 68 #endif /* ifdef CONFIG_ACPI */ 69 70 void hda_component_manager_playback_hook(struct hda_component_parent *parent, int action); 71 72 int hda_component_manager_init(struct hda_codec *cdc, 73 struct hda_component_parent *parent, int count, 74 const char *bus, const char *hid, 75 const char *match_str, 76 const struct component_master_ops *ops); 77 78 void hda_component_manager_free(struct hda_component_parent *parent, 79 const struct component_master_ops *ops); 80 81 int hda_component_manager_bind(struct hda_codec *cdc, struct hda_component_parent *parent); 82 83 static inline struct hda_component *hda_component_from_index(struct hda_component_parent *parent, 84 int index) 85 { 86 if (!parent) 87 return NULL; 88 89 if (index < 0 || index >= ARRAY_SIZE(parent->comps)) 90 return NULL; 91 92 return &parent->comps[index]; 93 } 94 95 static inline void hda_component_manager_unbind(struct hda_codec *cdc, 96 struct hda_component_parent *parent) 97 { 98 mutex_lock(&parent->mutex); 99 component_unbind_all(hda_codec_dev(cdc), parent); 100 mutex_unlock(&parent->mutex); 101 } 102 103 #endif /* ifndef __HDA_COMPONENT_H__ */ -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/patch_cmedia.c ¶
r766 r767 67 67 {0x43, CM9825_VERB_SET_CDALR, 0xf6}, /* Class D */ 68 68 {0x43, CM9825_VERB_SET_OTP, 0xcd}, /* OTP set */ 69 { }69 {0} 70 70 }; 71 71 … … 95 95 {0x43, CM9825_VERB_SET_HPF_1, 0x40}, /* HPF set */ 96 96 {0x43, CM9825_VERB_SET_HPF_2, 0x40}, /* HPF set */ 97 { }97 {0} 98 98 }; 99 99 … … 106 106 {0x43, CM9825_VERB_SET_DACTRL, 0x00}, /* DACTRL set */ 107 107 {0x43, CM9825_VERB_SET_VDO, 0xc4}, /* VDO set */ 108 { }108 {0} 109 109 }; 110 110 … … 117 117 {0x43, CM9825_VERB_SET_VDO, 0x80}, /* VDO set */ 118 118 {0x42, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, /* PIN on */ 119 { }119 {0} 120 120 }; 121 121 -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/patch_realtek.c ¶
r766 r767 19 19 #include <linux/dmi.h> 20 20 #include <linux/module.h> 21 #include <linux/i2c.h>21 //#include <linux/i2c.h> 22 22 #include <linux/input.h> 23 23 #include <linux/leds.h> 24 24 #include <linux/ctype.h> 25 #include <linux/spi/spi.h>25 //#include <linux/spi/spi.h> 26 26 #include <sound/core.h> 27 27 #include <sound/jack.h> … … 3110 3110 { 0x18, PIN_VREF50 }, /* rear mic */ 3111 3111 { 0x19, PIN_VREF50 }, /* front mic */ 3112 { }3112 {0} 3113 3113 } 3114 3114 }, … … 3535 3535 .v.pins = (const struct hda_pintbl[]) { 3536 3536 { 0x18, PIN_VREF100 }, /* headset mic */ 3537 { }3537 {0} 3538 3538 } 3539 3539 }, … … 5698 5698 } 5699 5699 5700 #ifdef NOT_USED 5700 5701 static void gpio2_mic_hotkey_event(struct hda_codec *codec, 5701 5702 struct hda_jack_callback *event) … … 5744 5745 return 0; 5745 5746 } 5747 #endif 5746 5748 5747 5749 /* GPIO1 = set according to SKU external amp … … 7810 7812 int i, count = 0, count_devindex = 0; 7811 7813 7814 #ifndef TARGET_OS2 7812 7815 for (i = 0; i < ARRAY_SIZE(acpi_ids); ++i) { 7813 7816 adev = acpi_dev_get_first_match_dev(acpi_ids[i].hid, NULL, -1); … … 7815 7818 break; 7816 7819 } 7820 7817 7821 if (!adev) { 7818 7822 codec_dbg(cdc, "Did not find ACPI entry for a Cirrus Amp\n"); … … 7851 7855 if (count_devindex > 0) 7852 7856 count = count_devindex; 7853 7857 #endif 7854 7858 match = devm_kasprintf(dev, GFP_KERNEL, "-%%s:00-%s.%%d", acpi_ids[i].name); 7855 7859 if (!match) … … 7885 7889 } 7886 7890 7891 #ifdef NOT_USED 7887 7892 static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const struct hda_fixup *fix, 7888 7893 int action) … … 7890 7895 comp_generic_fixup(cdc, action, "i2c", "CLSA0101", "-%s:00-cs35l41-hda.%d", 2); 7891 7896 } 7897 #endif 7892 7898 7893 7899 static void alc285_fixup_asus_ga403u(struct hda_codec *cdc, const struct hda_fixup *fix, int action) … … 8157 8163 { 0x14, 0x90170110 }, // top/treble 8158 8164 { 0x17, 0x90170111 }, // bottom/bass 8159 { 8165 {0} 8160 8166 }; 8161 8167 … … 8173 8179 8174 8180 cs35l41_fixup_i2c_two(codec, fix, action); 8181 #ifdef NOT_USED 8175 8182 alc245_fixup_hp_mute_led_coefbit(codec, fix, action); 8176 8183 alc245_fixup_hp_gpio_led(codec, fix, action); 8184 #endif 8177 8185 } 8178 8186 … … 8191 8199 { 0x14, 0x90170110 }, // top/treble 8192 8200 { 0x17, 0x90170111 }, // bottom/bass 8193 { 8201 {0} 8194 8202 }; 8195 8203 … … 8216 8224 8217 8225 cs35l41_fixup_i2c_two(codec, fix, action); 8226 #ifdef NOT_USED 8218 8227 alc245_fixup_hp_mute_led_coefbit(codec, fix, action); 8219 8228 alc245_fixup_hp_gpio_led(codec, fix, action); 8229 #endif 8220 8230 } 8221 8231 … … 8240 8250 static void alc287_s4_power_gpio3_default(struct hda_codec *codec) 8241 8251 { 8252 #ifndef TARGET_OS2 8242 8253 if (is_s4_suspend(codec)) { 8243 8254 alc_write_coefex_idx(codec, 0x5a, 0x00, 0x554f); /* write gpio3 as default value */ 8244 8255 } 8256 #endif 8245 8257 } 8246 8258 … … 10642 10654 { 0x20, AC_VERB_SET_COEF_INDEX, 0x6b }, 10643 10655 { 0x20, AC_VERB_SET_PROC_COEF, 0x5060 }, 10644 { }10656 {0} 10645 10657 }, 10646 10658 .chained = true, … … 10721 10733 { 0x1e, 0x411111f0 }, 10722 10734 { 0x21, 0x03211020 }, 10723 { }10735 {0} 10724 10736 }, 10725 10737 .chained = true, … … 10818 10830 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 10819 10831 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 10820 { }10832 {0} 10821 10833 }, 10822 10834 .chained = true, … … 10865 10877 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 10866 10878 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 10867 { }10879 {0} 10868 10880 }, 10869 10881 .chained = true, … … 10891 10903 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 10892 10904 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 10893 { }10905 {0} 10894 10906 }, 10895 10907 .chained = true, … … 11157 11169 .v.func = alc285_fixup_asus_ga403u, 11158 11170 }, 11171 #ifdef NOT_USED 11159 11172 [ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC] = { 11160 11173 .type = HDA_FIXUP_PINS, … … 11167 11180 .chain_id = ALC285_FIXUP_ASUS_GA403U_I2C_SPEAKER2_TO_DAC1 11168 11181 }, 11182 #endif 11169 11183 [ALC285_FIXUP_ASUS_GU605_SPI_SPEAKER2_TO_DAC1] = { 11170 11184 .type = HDA_FIXUP_FUNC, … … 11173 11187 .chain_id = ALC285_FIXUP_ASUS_GU605_SPI_2_HEADSET_MIC, 11174 11188 }, 11189 #ifdef NOT_USED 11175 11190 [ALC285_FIXUP_ASUS_GU605_SPI_2_HEADSET_MIC] = { 11176 11191 .type = HDA_FIXUP_PINS, … … 11181 11196 }, 11182 11197 }, 11198 #endif 11183 11199 [ALC285_FIXUP_ASUS_GA403U_I2C_SPEAKER2_TO_DAC1] = { 11184 11200 .type = HDA_FIXUP_FUNC, … … 11205 11221 .chain_id = ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE, 11206 11222 }, 11223 #ifdef NOT_USED 11207 11224 [ALC269_FIXUP_VAIO_VJFH52_MIC_NO_PRESENCE] = { 11208 11225 .type = HDA_FIXUP_PINS, … … 11222 11239 }, 11223 11240 }, 11241 #endif 11224 11242 }; 11225 11243 … … 14197 14215 { 0x20, AC_VERB_SET_COEF_INDEX, 0x15 }, 14198 14216 { 0x20, AC_VERB_SET_PROC_COEF, 0x0d60 }, 14199 { }14217 {0} 14200 14218 }, 14201 14219 }, … … 14219 14237 .v.pins = (const struct hda_pintbl[]) { 14220 14238 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ 14221 { 14239 {0} 14222 14240 }, 14223 14241 }, … … 14241 14259 .v.verbs = (const struct hda_verb[]) { 14242 14260 { 0x14, AC_VERB_SET_EAPD_BTLENABLE, 0 }, 14243 { }14261 {0} 14244 14262 }, 14245 14263 }, -
TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/pci/maestro3.c ¶
r766 r767 2590 2590 card->sync_irq = chip->irq; 2591 2591 2592 #ifndef TARGET_OS2 2592 2593 if (IS_ENABLED(CONFIG_PM_SLEEP)) { 2593 2594 chip->suspend_mem = … … 2598 2599 dev_warn(card->dev, "can't allocate apm buffer\n"); 2599 2600 } 2600 2601 #endif 2601 2602 err = snd_m3_mixer(chip); 2602 2603 if (err < 0) -
TabularUnified GPL/branches/uniaud32-exp/include/linux/compiler.h ¶
r665 r767 16 16 17 17 #define __GNUC__ 3 18 19 #define __counted_by(member) 20 #define __free(x) 21 22 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */ 23 #define ___PASTE(a,b) a##b 24 #define __PASTE(a,b) ___PASTE(a,b) 25 26 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) 18 27 19 28 #ifndef __ASSEMBLY__ -
TabularUnified GPL/branches/uniaud32-exp/include/linux/device.h ¶
r764 r767 58 58 struct device * parent; 59 59 struct device_private *p; 60 struct bus_type * bus; /* type of bus device is on */60 const struct bus_type * bus; /* type of bus device is on */ 61 61 struct kobject kobj; 62 62 const char *init_name; /* initial name of the device */ -
TabularUnified GPL/branches/uniaud32-exp/include/linux/export.h ¶
r647 r767 6 6 #define EXPORT_SYMBOL(a) 7 7 #define EXPORT_SYMBOL_GPL(a) 8 #define EXPORT_SYMBOL_NS_GPL(a) 8 9 9 10 #endif /* _LINUX_EXPORT_H */ -
TabularUnified GPL/branches/uniaud32-exp/include/linux/kernel.h ¶
r763 r767 128 128 129 129 _WCRTLINK extern int sscanf( const char *__s, const char *__format, ... ); 130 130 typedef void *acpi_handle; /* Actually a ptr to a NS Node */ 131 typedef 132 void (*acpi_notify_handler) (acpi_handle device, u32 value, void *context); 131 133 #endif -
TabularUnified GPL/branches/uniaud32-exp/include/linux/module.h ¶
r647 r767 116 116 char name[MODULE_NAME_LEN]; 117 117 }; 118 #define MODULE_IMPORT_NS(x) 118 119 #endif /* _LINUX_MODULE_H */ -
TabularUnified GPL/branches/uniaud32-exp/include/linux/pci_ids.h ¶
r763 r767 584 584 #define PCI_DEVICE_ID_AMD_1AH_M70H_DF_F3 0x12bb 585 585 #define PCI_DEVICE_ID_AMD_MI200_DF_F3 0x14d3 586 #define PCI_DEVICE_ID_AMD_MI300_DF_F3 0x152b 586 587 #define PCI_DEVICE_ID_AMD_VANGOGH_USB 0x163a 587 588 #define PCI_DEVICE_ID_AMD_CNB17H_F3 0x1703 … … 2589 2590 #define PCI_VENDOR_ID_REDHAT 0x1b36 2590 2591 2592 #define PCI_VENDOR_ID_WCHIC 0x1c00 2593 #define PCI_DEVICE_ID_WCHIC_CH382_0S1P 0x3050 2594 #define PCI_DEVICE_ID_WCHIC_CH382_2S1P 0x3250 2595 #define PCI_DEVICE_ID_WCHIC_CH382_2S 0x3253 2596 2591 2597 #define PCI_VENDOR_ID_SILICOM_DENMARK 0x1c2c 2592 2598 … … 2602 2608 #define PCI_VENDOR_ID_HYGON 0x1d94 2603 2609 2610 #define PCI_VENDOR_ID_META 0x1d9b 2611 2604 2612 #define PCI_VENDOR_ID_FUNGIBLE 0x1dad 2605 2613 … … 2608 2616 #define PCI_VENDOR_ID_TEKRAM 0x1de1 2609 2617 #define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 2618 2619 #define PCI_VENDOR_ID_ALIBABA 0x1ded 2620 2621 #define PCI_VENDOR_ID_CXL 0x1e98 2610 2622 2611 2623 #define PCI_VENDOR_ID_TEHUTI 0x1fc9 … … 2636 2648 #define PCI_VENDOR_ID_AKS 0x416c 2637 2649 #define PCI_DEVICE_ID_AKS_ALADDINCARD 0x0100 2650 2651 #define PCI_VENDOR_ID_WCHCN 0x4348 2652 #define PCI_DEVICE_ID_WCHCN_CH353_4S 0x3453 2653 #define PCI_DEVICE_ID_WCHCN_CH353_2S1PF 0x5046 2654 #define PCI_DEVICE_ID_WCHCN_CH353_1S1P 0x5053 2655 #define PCI_DEVICE_ID_WCHCN_CH353_2S1P 0x7053 2638 2656 2639 2657 #define PCI_VENDOR_ID_ACCESSIO 0x494f … … 2703 2721 #define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132 2704 2722 #define PCI_DEVICE_ID_INTEL_SST_TNG 0x119a 2723 #define PCI_DEVICE_ID_INTEL_DSA_GNRD 0x11fb 2724 #define PCI_DEVICE_ID_INTEL_DSA_DMR 0x1212 2725 #define PCI_DEVICE_ID_INTEL_IAA_DMR 0x1216 2705 2726 #define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221 2706 2727 #define PCI_DEVICE_ID_INTEL_82437 0x122d … … 3112 3133 #define PCI_DEVICE_ID_INTEL_HDA_LNL_P 0xa828 3113 3134 #define PCI_DEVICE_ID_INTEL_S21152BB 0xb152 3135 #define PCI_DEVICE_ID_INTEL_HDA_BMG 0xe2f7 3136 #define PCI_DEVICE_ID_INTEL_HDA_PTL_H 0xe328 3137 #define PCI_DEVICE_ID_INTEL_HDA_PTL 0xe428 3114 3138 #define PCI_DEVICE_ID_INTEL_HDA_CML_R 0xf0c8 3115 3139 #define PCI_DEVICE_ID_INTEL_HDA_RKL_S 0xf1c8 -
TabularUnified GPL/branches/uniaud32-exp/include/linux/pm.h ¶
r763 r767 291 291 .restore = resume_fn, 292 292 293 #define SYSTEM_SLEEP_PM_OPS SET_SYSTEM_SLEEP_PM_OPS 293 294 /* 294 295 * Use this if you want to use the same suspend and resume callbacks for suspend … … 349 350 #define PMSG_RESTORE 0 350 351 #define pm_sleep_ptr(_ptr) _ptr 352 353 #define pm_ptr(_ptr) _ptr 354 351 355 #endif /* _LINUX_PM_H */ -
TabularUnified GPL/branches/uniaud32-exp/lib32/Makefile ¶
r764 r767 31 31 instropl2.obj instropl3.obj vsprintf.obj bitmap.obj find_next_bit.obj & 32 32 regmap.obj regcache.obj regcache-flat.obj regcache-rbtree.obj & 33 regcache-maple.objcomponent.obj33 component.obj 34 34 35 35 TARGET = linuxlib -
TabularUnified GPL/branches/uniaud32-exp/lib32/regcache.c ¶
r764 r767 24 24 static const struct regcache_ops *cache_types[] = { 25 25 ®cache_rbtree_ops, 26 #if 0 // not (yet?) supported on OS/2 26 27 ®cache_maple_ops, 28 #endif 27 29 ®cache_flat_ops, 28 30 }; -
TabularUnified GPL/branches/uniaud32-exp/lib32/regmap.c ¶
r724 r767 20 20 #include <linux/log2.h> 21 21 //#include <linux/hwspinlock.h> 22 #include < asm/unaligned.h>22 #include <linux/unaligned.h> 23 23 #include <linux/module.h> 24 24 #include <linux/workqueue.h> -
TabularUnified GPL/branches/uniaud32-exp/uniaud.inc ¶
r645 r767 13 13 # ex RC3 GA FIXPACK2 beta_47 14 14 # Comment out to avoid a fixpack line in bldlevel 15 FIXPACK = SVN 15 FIXPACK = SVN r764
Note:
See TracChangeset
for help on using the changeset viewer.