Changeset 767


Ignore:
Timestamp:
Apr 13, 2025, 3:27:12 AM (8 days ago)
Author:
Paul Smedley
Message:

Get it compiling & linking

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  
    4747static int snd_ctl_open(struct inode *inode, struct file *file)
    4848{
     49        unsigned long flags;
    4950        struct snd_card *card;
    5051        struct snd_ctl_file *ctl;
     
    8283        ctl->pid = get_pid(task_pid(current));
    8384        file->private_data = ctl;
    84         scoped_guard(write_lock_irqsave, &card->controls_rwlock)
     85        write_lock_irqsave(&card->controls_rwlock, flags);
    8586        list_add_tail(&ctl->list, &card->ctl_files);
     87        write_unlock_irqrestore(&card->controls_rwlock, flags);
    8688        snd_card_unref(card);
    8789        return 0;
     
    99101static void snd_ctl_empty_read_queue(struct snd_ctl_file * ctl)
    100102{
     103        unsigned long flags;
    101104        struct snd_kctl_event *cread;
    102105
    103         guard(spinlock_irqsave)(&ctl->read_lock);
     106        spin_lock_irqsave(&ctl->read_lock, flags);
    104107        while (!list_empty(&ctl->events)) {
    105108                cread = snd_kctl_event(ctl->events.next);
     
    107110                kfree(cread);
    108111        }
     112        spin_unlock_irqrestore(&ctl->read_lock, flags);
    109113}
    110114
    111115static int snd_ctl_release(struct inode *inode, struct file *file)
    112116{
     117        unsigned long flags;
    113118        struct snd_card *card;
    114119        struct snd_ctl_file *ctl;
     
    120125        card = ctl->card;
    121126
    122         scoped_guard(write_lock_irqsave, &card->controls_rwlock)
     127        write_lock_irqsave(&card->controls_rwlock, flags);
    123128        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);
    126131        list_for_each_entry(control, &card->controls, list, struct snd_kcontrol)
    127132                for (idx = 0; idx < control->count; idx++)
    128133                        if (control->vd[idx].owner == ctl)
    129134                                control->vd[idx].owner = NULL;
    130         }
     135        up_write(&card->controls_rwsem);
    131136
    132137        snd_fasync_free(ctl->fasync);
     
    152157                    struct snd_ctl_elem_id *id)
    153158{
     159        unsigned long flags;
    154160        struct snd_ctl_file *ctl;
    155161        struct snd_kctl_event *ev;
     
    160166                return;
    161167
    162         guard(read_lock_irqsave)(&card->controls_rwlock);
     168        read_lock_irqsave(&card->controls_rwlock, flags);
    163169//#if (IS_ENABLED(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS))
    164170#if defined(CONFIG_SND_MIXER_OSS)
     
    168174                if (!ctl->subscribed)
    169175                        continue;
    170                 scoped_guard(spinlock, &ctl->read_lock) {
     176                spin_lock(&ctl->read_lock);
    171177                list_for_each_entry(ev, &ctl->events, list, struct snd_kctl_event) {
    172178                        if (ev->id.numid == id->numid) {
     
    185191        _found:
    186192                wake_up(&ctl->change_sleep);
    187                 }
     193                spin_unlock(&ctl->read_lock);
    188194                snd_kill_fasync(ctl->fasync, SIGIO, POLL_IN);
    189195        }
     196        read_unlock_irqrestore(&card->controls_rwlock, flags);
    190197}
    191198EXPORT_SYMBOL(snd_ctl_notify);
     
    210217        id.numid += ioff;
    211218        snd_ctl_notify(card, mask, &id);
    212         guard(rwsem_read)(&snd_ctl_layer_rwsem);
     219        down_read(&snd_ctl_layer_rwsem);
    213220        for (lops = snd_ctl_layer; lops; lops = lops->next)
    214221                lops->lnotify(card, mask, kctl, ioff);
     222        up_read(&snd_ctl_layer_rwsem);
    215223}
    216224EXPORT_SYMBOL(snd_ctl_notify_one);
     
    505513                return -ENOMEM;
    506514
    507         scoped_guard(write_lock_irq, &card->controls_rwlock) {
    508515        list_add_tail(&kcontrol->list, &card->controls);
    509516        card->controls_count += kcontrol->count;
    510517        kcontrol->id.numid = card->last_numid + 1;
    511518        card->last_numid += kcontrol->count;
    512         }
    513519
    514520        add_hash_entries(card, kcontrol);
     
    531537                goto error;
    532538
    533         scoped_guard(rwsem_write, &card->controls_rwsem)
     539        down_write(&card->controls_rwsem);
    534540        err = __snd_ctl_add_replace(card, kcontrol, mode);
     541        up_write(&card->controls_rwsem);
    535542
    536543        if (err < 0)
     
    595602        if (snd_BUG_ON(!card || !kcontrol))
    596603                return -EINVAL;
     604        list_del(&kcontrol->list);
    597605
    598606        if (remove_hash)
    599607                remove_hash_entries(card, kcontrol);
    600608
    601         scoped_guard(write_lock_irq, &card->controls_rwlock) {
    602                 list_del(&kcontrol->list);
    603609        card->controls_count -= kcontrol->count;
    604         }
    605 
    606610        for (idx = 0; idx < kcontrol->count; idx++)
    607611                snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_REMOVE, kcontrol, idx);
     
    631635int snd_ctl_remove(struct snd_card *card, struct snd_kcontrol *kcontrol)
    632636{
    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;
    637643}
    638644EXPORT_SYMBOL(snd_ctl_remove);
     
    651657{
    652658        struct snd_kcontrol *kctl;
    653 
    654         guard(rwsem_write)(&card->controls_rwsem);
     659        int ret;
     660
     661        down_write(&card->controls_rwsem);
    655662        kctl = snd_ctl_find_id(card, id);
    656         if (kctl == NULL)
     663        if (kctl == NULL) {
     664                up_write(&card->controls_rwsem);
    657665                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;
    659670}
    660671EXPORT_SYMBOL(snd_ctl_remove_id);
     
    675686        struct snd_card *card = file->card;
    676687        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);
    680691        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        }
    685700        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);
     706error:
     707        up_write(&card->controls_rwsem);
     708        return ret;
    689709}
    690710
     
    763783        int saved_numid;
    764784
    765         guard(rwsem_write)(&card->controls_rwsem);
     785        down_write(&card->controls_rwsem);
    766786        kctl = snd_ctl_find_id(card, src_id);
    767         if (kctl == NULL)
     787        if (kctl == NULL) {
     788                up_write(&card->controls_rwsem);
    768789                return -ENOENT;
     790        }
    769791        saved_numid = kctl->id.numid;
    770792        remove_hash_entries(card, kctl);
     
    772794        kctl->id.numid = saved_numid;
    773795        add_hash_entries(card, kctl);
     796        up_write(&card->controls_rwsem);
    774797        return 0;
    775798}
     
    789812                    const char *name)
    790813{
    791         guard(rwsem_write)(&card->controls_rwsem);
     814        down_write(&card->controls_rwsem);
    792815        remove_hash_entries(card, kctl);
    793816
     
    797820
    798821        add_hash_entries(card, kctl);
     822        up_write(&card->controls_rwsem);
    799823}
    800824EXPORT_SYMBOL(snd_ctl_rename);
     
    806830        struct snd_kcontrol *kctl;
    807831
    808         guard(read_lock_irqsave)(&card->controls_rwlock);
    809832        list_for_each_entry(kctl, &card->controls, list, struct snd_kcontrol) {
    810833                if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid)
     
    869892#endif
    870893        /* no matching in hash table - try all as the last resort */
    871         guard(read_lock_irqsave)(&card->controls_rwlock);
    872894        list_for_each_entry(kctl, &card->controls, list, struct snd_kcontrol)
    873895                if (elem_id_matches(kctl, id))
     
    885907        if (! info)
    886908                return -ENOMEM;
    887         scoped_guard(rwsem_read, &snd_ioctl_rwsem) {
     909        down_read(&snd_ioctl_rwsem);
    888910        info->card = card->number;
    889911        strscpy(info->id, card->id, sizeof(info->id));
     
    893915        strscpy(info->mixername, card->mixername, sizeof(info->mixername));
    894916        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);
    897920                return -EFAULT;
     921        }
     922        kfree(info);
    898923        return 0;
    899924}
     
    905930        struct snd_ctl_elem_id id;
    906931        unsigned int offset, space, jidx;
     932        int err = 0;
    907933
    908934        offset = list->offset;
    909935        space = list->space;
    910936
    911         guard(rwsem_read)(&card->controls_rwsem);
     937        down_read(&card->controls_rwsem);
    912938        list->count = card->controls_count;
    913939        list->used = 0;
    914         if (!space)
    915                 return 0;
     940        if (space > 0) {
    916941                list_for_each_entry(kctl, &card->controls, list, struct snd_kcontrol) {
    917942                        if (offset >= kctl->count) {
     
    921946                        for (jidx = offset; jidx < kctl->count; jidx++) {
    922947                                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                                }
    925953                                list->used++;
    926954                                if (!--space)
    927                                 return 0;
     955                                        goto out;
    928956                        }
    929957                        offset = 0;
     958                        }
    930959                }
    931         return 0;
     960 out:
     961        up_read(&card->controls_rwsem);
     962        return err;
    932963}
    933964
     
    11751206        struct snd_kcontrol *kctl;
    11761207
    1177         guard(rwsem_read)(&card->controls_rwsem);
     1208        int result;
     1209
     1210        down_read(&card->controls_rwsem);
    11781211        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;
    11821218}
    11831219
     
    12161252        int ret;
    12171253
    1218         guard(rwsem_read)(&card->controls_rwsem);
     1254        down_read(&card->controls_rwsem);
    12191255        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        }
    12221260
    12231261        index_offset = snd_ctl_get_ioff(kctl, &control->id);
    12241262        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        }
    12271267
    12281268        snd_ctl_build_ioff(&control->id, kctl, index_offset);
     
    12341274        ret = __snd_ctl_elem_info(card, kctl, &info, NULL);
    12351275        if (ret < 0)
    1236                 return ret;
     1276                goto unlock;
    12371277#endif
    12381278
    12391279        if (!snd_ctl_skip_validation(&info))
    12401280                fill_remaining_elem_value(control, &info, pattern);
    1241                 ret = kctl->get(kctl, control);
     1281        ret = kctl->get(kctl, control);
    12421282        if (ret < 0)
    1243                 return ret;
     1283                goto unlock;
    12441284        if (!snd_ctl_skip_validation(&info) &&
    12451285            sanity_check_elem_value(card, control, &info, pattern) < 0) {
     
    12491289                        control->id.subdevice, control->id.name,
    12501290                        control->id.index);
    1251                 return -EINVAL;
    1252         }
    1253         return 0;
     1291                ret = -EINVAL;
     1292                goto unlock;
     1293        }
     1294unlock:
     1295        up_read(&card->controls_rwsem);
     1296        return ret;
    12541297}
    12551298
     
    13021345        snd_ctl_build_ioff(&control->id, kctl, index_offset);
    13031346        /* validate input values */
     1347#ifndef TARGET_OS2
    13041348        if (IS_ENABLED(CONFIG_SND_CTL_INPUT_VALIDATION)) {
    13051349                struct snd_ctl_elem_info info;
     
    13121356                                                           false);
    13131357        }
     1358#endif
    13141359        if (!result)
    13151360                result = kctl->put(kctl, control);
     
    13621407        struct snd_kcontrol *kctl;
    13631408        struct snd_kcontrol_volatile *vd;
     1409        int result;
    13641410
    13651411        if (copy_from_user(&id, _id, sizeof(id)))
    13661412                return -EFAULT;
    1367         guard(rwsem_write)(&card->controls_rwsem);
     1413        down_write(&card->controls_rwsem);
    13681414        kctl = snd_ctl_find_id(card, &id);
    1369         if (!kctl)
    1370                 return -ENOENT;
     1415        if (kctl == NULL) {
     1416                result = -ENOENT;
     1417        } else {
    13711418                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 {
    13741422                        vd->owner = file;
    1375         return 0;
     1423                        result = 0;
     1424                }
     1425        }
     1426        up_write(&card->controls_rwsem);
     1427        return result;
    13761428}
    13771429
     
    13831435        struct snd_kcontrol *kctl;
    13841436        struct snd_kcontrol_volatile *vd;
     1437        int result;
    13851438
    13861439        if (copy_from_user(&id, _id, sizeof(id)))
    13871440                return -EFAULT;
    1388         guard(rwsem_write)(&card->controls_rwsem);
     1441        down_write(&card->controls_rwsem);
    13891442        kctl = snd_ctl_find_id(card, &id);
    1390         if (!kctl)
    1391                 return -ENOENT;
     1443        if (kctl == NULL) {
     1444                result = -ENOENT;
     1445        } else {
    13921446                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 {
    13971452                        vd->owner = NULL;
    1398         return 0;
     1453                        result = 0;
     1454                }
     1455        }
     1456        up_write(&card->controls_rwsem);
     1457        return result;
    13991458}
    14001459
     
    16771736        err = snd_ctl_check_elem_info(NULL, info);
    16781737        if (err < 0)
    1679                 return err;
     1738                goto unlock;
    16801739        /* user-space control doesn't allow zero-size data */
    16811740        if (info->count < 1)
     
    16841743        alloc_size = compute_user_elem_size(private_size, count);
    16851744
    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        }
    16891750
    16901751        /*
     
    16961757        err = snd_ctl_new(&kctl, count, access, file);
    16971758        if (err < 0)
    1698                 return err;
     1759                goto unlock;
    16991760        memcpy(&kctl->id, &info->id, sizeof(kctl->id));
    17001761        ue = kzalloc(alloc_size, GFP_KERNEL);
    17011762        if (!ue) {
    17021763                kfree(kctl);
    1703                 return -ENOMEM;
     1764                err = -ENOMEM;
     1765                goto unlock;
    17041766        }
    17051767        kctl->private_data = ue;
     
    17191781                if (err < 0) {
    17201782                        snd_ctl_free_one(kctl);
    1721                         return err;
     1783                        goto unlock;
    17221784                }
    17231785        }
     
    17391801        if (err < 0) {
    17401802                snd_ctl_free_one(kctl);
    1741                 return err;
     1803                goto unlock;
    17421804        }
    17431805        offset = snd_ctl_get_ioff(kctl, &info->id);
     
    17501812         * which locks the element.
    17511813         */
    1752         return 0;
     1814 unlock:
     1815        up_write(&card->controls_rwsem);
     1816        return err;
    17531817}
    17541818
     
    19512015                if (err < 0)
    19522016                        return err;
    1953                 scoped_guard(rwsem_read, &card->controls_rwsem)
     2017                down_read(&ctl->card->controls_rwsem);
    19542018                err = snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_READ);
     2019                up_read(&ctl->card->controls_rwsem);
    19552020                snd_power_unref(card);
    19562021                return err;
     
    19592024                if (err < 0)
    19602025                        return err;
    1961                 scoped_guard(rwsem_write, &card->controls_rwsem)
     2026                down_write(&ctl->card->controls_rwsem);
    19622027                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:
    19632030                snd_power_unref(card);
    19642031                return err;
    1965         case SNDRV_CTL_IOCTL_TLV_COMMAND:
    19662032                err = snd_power_ref_and_wait(card);
    19672033                if (err < 0)
    19682034                        return err;
    1969                 scoped_guard(rwsem_write, &card->controls_rwsem)
     2035                down_write(&ctl->card->controls_rwsem);
    19702036                err = snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_CMD);
     2037                up_write(&ctl->card->controls_rwsem);
    19712038                snd_power_unref(card);
    19722039                return err;
     
    19762043                return put_user(SNDRV_CTL_POWER_D0, ip) ? -EFAULT : 0;
    19772044        }
    1978 
    1979         guard(rwsem_read)(&snd_ioctl_rwsem);
     2045        down_read(&snd_ioctl_rwsem);
     2046
    19802047        list_for_each_entry(p, &snd_control_ioctls, list, struct snd_kctl_ioctl) {
    19812048                err = p->fioctl(card, ctl, cmd, arg);
    1982                 if (err != -ENOIOCTLCMD)
     2049                if (err != -ENOIOCTLCMD) {
     2050                        up_read(&snd_ioctl_rwsem);
    19832051                        return err;
    1984         }
     2052                }
     2053        }
     2054        up_read(&snd_ioctl_rwsem);
    19852055        dev_dbg(card->dev, "unknown ioctl = 0x%x\n", cmd);
    19862056        return -ENOTTY;
     
    20742144                return -ENOMEM;
    20752145        pn->fioctl = fcn;
    2076         guard(rwsem_write)(&snd_ioctl_rwsem);
     2146        down_write(&snd_ioctl_rwsem);
    20772147        list_add_tail(&pn->list, lists);
     2148        up_write(&snd_ioctl_rwsem);
    20782149        return 0;
    20792150}
     
    21182189        if (snd_BUG_ON(!fcn))
    21192190                return -EINVAL;
    2120         guard(rwsem_write)(&snd_ioctl_rwsem);
     2191        down_write(&snd_ioctl_rwsem);
    21212192        list_for_each_entry(p, lists, list, struct snd_kctl_ioctl) {
    21222193                if (p->fioctl == fcn) {
     
    21272198                }
    21282199        }
     2200        up_write(&snd_ioctl_rwsem);
    21292201        snd_BUG();
    21302202        return -EINVAL;
     
    21732245        struct snd_ctl_file *kctl;
    21742246        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);
    21772250        list_for_each_entry(kctl, &card->ctl_files, list, struct snd_ctl_file) {
    21782251                if (kctl->pid == task_pid(current)) {
     
    21822255                }
    21832256        }
     2257        read_unlock_irqrestore(&card->controls_rwlock, flags);
    21842258        return subdevice;
    21852259}
     
    22112285        if (module_name == NULL)
    22122286                return 0;
    2213         scoped_guard(rwsem_read, &snd_ctl_layer_rwsem) {
     2287        down_read(&snd_ctl_layer_rwsem);
    22142288        for (lops = snd_ctl_layer; lops; lops = lops->next)
    22152289                if (strcmp(lops->module_name, module_name) == 0)
     2290                        break;
     2291        up_read(&snd_ctl_layer_rwsem);
     2292        if (lops)
    22162293                return 0;
    2217         }
    22182294        return request_module(module_name);
    22192295}
     
    22322308        int card_number;
    22332309
    2234         scoped_guard(rwsem_write, &snd_ctl_layer_rwsem) {
     2310        down_write(&snd_ctl_layer_rwsem);
    22352311        lops->next = snd_ctl_layer;
    22362312        snd_ctl_layer = lops;
    2237         }
     2313        up_write(&snd_ctl_layer_rwsem);
    22382314        for (card_number = 0; card_number < SNDRV_CARDS; card_number++) {
    22392315                card = snd_card_ref(card_number);
    22402316                if (card) {
    2241                         scoped_guard(rwsem_read, &card->controls_rwsem)
     2317                        down_read(&card->controls_rwsem);
    22422318                        lops->lregister(card);
     2319                        up_read(&card->controls_rwsem);
    22432320                        snd_card_unref(card);
    22442321                }
     
    22592336        struct snd_ctl_layer_ops *lops2, *prev_lops2;
    22602337
    2261         guard(rwsem_write)(&snd_ctl_layer_rwsem);
     2338        down_write(&snd_ctl_layer_rwsem);
    22622339        for (lops2 = snd_ctl_layer, prev_lops2 = NULL; lops2; lops2 = lops2->next) {
    22632340                if (lops2 == lops) {
     
    22702347                prev_lops2 = lops2;
    22712348        }
     2349        up_write(&snd_ctl_layer_rwsem);
    22722350}
    22732351EXPORT_SYMBOL_GPL(snd_ctl_disconnect_layer);
     
    22892367};
    22902368
     2369#ifndef TARGET_OS2
    22912370/* call lops under rwsems; called from snd_ctl_dev_*() below() */
    22922371#define call_snd_ctl_lops(_card, _op)                               \
     
    22982377                        lops->_op(_card);                           \
    22992378        } while (0)
     2379#endif
    23002380
    23012381/*
     
    23052385{
    23062386        struct snd_card *card = device->device_data;
     2387        struct snd_ctl_layer_ops *lops;
    23072388        int err;
    23082389
     
    23112392        if (err < 0)
    23122393                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);
    23142400        return 0;
    23152401}
     
    23222408        struct snd_card *card = device->device_data;
    23232409        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);
    23262414        list_for_each_entry(ctl, &card->ctl_files, list, struct snd_ctl_file) {
    23272415                wake_up(&ctl->change_sleep);
    23282416                snd_kill_fasync(ctl->fasync, SIGIO, POLL_ERR);
    23292417        }
    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);
    23332426        return snd_unregister_device(card->ctl_dev);
    23342427}
     
    23422435        struct snd_kcontrol *control;
    23432436
    2344         scoped_guard(rwsem_write, &card->controls_rwsem) {
     2437        down_write(&card->controls_rwsem);
    23452438        while (!list_empty(&card->controls)) {
    23462439                control = snd_kcontrol(card->controls.next);
     
    23522445        xa_destroy(&card->ctl_hash);
    23532446#endif
    2354         }
     2447        up_write(&card->controls_rwsem);
    23552448        put_device(card->ctl_dev);
    23562449        return 0;
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/hwdep.c

    r766 r767  
    150150        struct module *mod = hw->card->module;
    151151
    152         scoped_guard(mutex, &hw->open_mutex) {
     152        mutex_lock(&hw->open_mutex);
    153153        if (hw->ops.release)
    154154                err = hw->ops.release(hw, file);
    155155        if (hw->used > 0)
    156156                hw->used--;
    157         }
     157        mutex_unlock(&hw->open_mutex);
    158158        wake_up(&hw->open_wait);
    159159
     
    273273                        if (get_user(device, (int __user *)arg))
    274274                                return -EFAULT;
    275 
    276                         scoped_guard(mutex, &register_mutex) {
     275                        mutex_lock(&register_mutex);
     276
    277277                        if (device < 0)
    278278                                device = 0;
     
    289289                        if (device >= SNDRV_MINOR_HWDEPS)
    290290                                device = -1;
    291                         }
     291                        mutex_unlock(&register_mutex);
    292292                        if (put_user(device, (int __user *)arg))
    293293                                return -EFAULT;
     
    297297                {
    298298                        struct snd_hwdep_info __user *info = (struct snd_hwdep_info __user *)arg;
    299                         int device;
     299                        int device, err;
    300300                        struct snd_hwdep *hwdep;
    301301
    302302                        if (get_user(device, &info->device))
    303303                                return -EFAULT;
    304                         scoped_guard(mutex, &register_mutex) {
     304                        mutex_lock(&register_mutex);
    305305                        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(&register_mutex);
     311                        return err;
    311312                }
    312313        }
     
    422423        int err;
    423424
    424         guard(mutex)(&register_mutex);
    425         if (snd_hwdep_search(card, hwdep->device))
     425        mutex_lock(&register_mutex);
     426        if (snd_hwdep_search(card, hwdep->device)) {
     427                mutex_unlock(&register_mutex);
    426428                return -EBUSY;
     429        }
    427430        list_add_tail(&hwdep->list, &snd_hwdep_devices);
    428431        err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP,
     
    432435                dev_err(hwdep->dev, "unable to register\n");
    433436                list_del(&hwdep->list);
     437                mutex_unlock(&register_mutex);
    434438                return err;
    435439        }
     
    451455        }
    452456#endif
     457        mutex_unlock(&register_mutex);
    453458        return 0;
    454459}
     
    460465        if (snd_BUG_ON(!hwdep))
    461466                return -ENXIO;
    462         guard(mutex)(&register_mutex);
    463         if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep)
     467        mutex_lock(&register_mutex);
     468        if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) {
     469                mutex_unlock(&register_mutex);
    464470                return -EINVAL;
    465         guard(mutex)(&hwdep->open_mutex);
     471        }
     472        mutex_lock(&hwdep->open_mutex);
    466473        wake_up(&hwdep->open_wait);
    467474#ifdef CONFIG_SND_OSSEMUL
     
    471478        snd_unregister_device(hwdep->dev);
    472479        list_del_init(&hwdep->list);
     480        mutex_unlock(&hwdep->open_mutex);
     481        mutex_unlock(&register_mutex);
    473482        return 0;
    474483}
     
    484493        struct snd_hwdep *hwdep;
    485494
    486         guard(mutex)(&register_mutex);
     495        mutex_lock(&register_mutex);
    487496        list_for_each_entry(hwdep, &snd_hwdep_devices, list, struct snd_hwdep)
    488497                snd_iprintf(buffer, "%02i-%02i: %s\n",
    489498                            hwdep->card->number, hwdep->device, hwdep->name);
     499        mutex_unlock(&register_mutex);
    490500}
    491501
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/info.c

    r766 r767  
    107107        struct snd_info_private_data *data;
    108108        struct snd_info_entry *entry;
    109         loff_t size;
     109        loff_t ret = -EINVAL, size;
    110110
    111111        data = file->private_data;
    112112        entry = data->entry;
    113         guard(mutex)(&entry->access);
    114         if (entry->c.ops->llseek)
    115                 return entry->c.ops->llseek(entry,
     113        mutex_lock(&entry->access);
     114        if (entry->c.ops->llseek) {
     115                ret = entry->c.ops->llseek(entry,
    116116                                           data->file_private_data,
    117117                                           file, offset, orig);
     118                goto out;
     119        }
    118120
    119121        size = entry->size;
     
    126128        case SEEK_END:
    127129                if (!size)
    128                         return -EINVAL;
     130                        goto out;
    129131                offset += size;
    130132                break;
    131133        default:
    132                 return -EINVAL;
     134                goto out;
    133135        }
    134136        if (offset < 0)
    135                 return -EINVAL;
     137                goto out;
    136138        if (size && offset > size)
    137139                offset = size;
    138140        file->f_pos = offset;
    139         return offset;
     141        ret = offset;
     142 out:
     143        mutex_unlock(&entry->access);
     144        return ret;
    140145}
    141146
     
    235240        int mode, err;
    236241
    237         guard(mutex)(&info_mutex);
     242        mutex_lock(&info_mutex);
    238243        err = alloc_info_private(entry, &data);
    239244        if (err < 0)
    240                 return err;
     245                goto unlock;
    241246
    242247        mode = file->f_flags & O_ACCMODE;
     
    254259
    255260        file->private_data = data;
     261        mutex_unlock(&info_mutex);
    256262        return 0;
    257263
     
    259265        kfree(data);
    260266        module_put(entry->module);
     267 unlock:
     268        mutex_unlock(&info_mutex);
    261269        return err;
    262270}
     
    300308        loff_t pos;
    301309        size_t next;
     310        int err = 0;
    302311
    303312        if (!entry->c.text.write)
     
    310319        if (next > 16 * 1024)
    311320                return -EIO;
    312         guard(mutex)(&entry->access);
     321        mutex_lock(&entry->access);
    313322        buf = data->wbuffer;
    314323        if (!buf) {
    315324                data->wbuffer = buf = kzalloc(sizeof(*buf), GFP_KERNEL);
    316                 if (!buf)
    317                         return -ENOMEM;
     325                if (!buf) {
     326                        err = -ENOMEM;
     327                        goto error;
     328                }
    318329        }
    319330        if (next > buf->len) {
     
    325336                buf->len = PAGE_ALIGN(next);
    326337        }
    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        }
    329342        buf->size = next;
     343 error:
     344        mutex_unlock(&entry->access);
     345        if (err < 0)
     346                return err;
    330347        *offset = next;
    331348        return count;
     
    352369        int err;
    353370
    354         guard(mutex)(&info_mutex);
     371        mutex_lock(&info_mutex);
    355372        err = alloc_info_private(entry, &data);
    356373        if (err < 0)
    357                 return err;
     374                goto unlock;
    358375
    359376        data->rbuffer = kzalloc(sizeof(*data->rbuffer), GFP_KERNEL);
     
    369386        if (err < 0)
    370387                goto error;
     388        mutex_unlock(&info_mutex);
    371389        return 0;
    372390
     
    375393        kfree(data);
    376394        module_put(entry->module);
     395 unlock:
     396        mutex_unlock(&info_mutex);
    377397        return err;
    378398}
     
    530550void snd_info_card_id_change(struct snd_card *card)
    531551{
    532         guard(mutex)(&info_mutex);
     552        mutex_lock(&info_mutex);
    533553        if (card->proc_root_link) {
    534554                proc_remove(card->proc_root_link);
     
    539559                                                    snd_proc_root->p,
    540560                                                    card->proc_root->name);
     561        mutex_unlock(&info_mutex);
    541562}
    542563
     
    554575                proc_remove(card->proc_root->p);
    555576
    556         guard(mutex)(&info_mutex);
     577        mutex_lock(&info_mutex);
    557578        if (card->proc_root)
    558579                snd_info_clear_entries(card->proc_root);
    559580        card->proc_root_link = NULL;
    560581        card->proc_root = NULL;
     582        mutex_unlock(&info_mutex);
    561583}
    562584
     
    682704        entry->module = module;
    683705        if (parent) {
    684                 guard(mutex)(&parent->access);
     706                mutex_lock(&parent->access);
    685707                list_add_tail(&entry->list, &parent->children);
     708                mutex_unlock(&parent->access);
    686709        }
    687710        return entry;
     
    753776        if (entry->p) {
    754777                proc_remove(entry->p);
    755                 guard(mutex)(&info_mutex);
     778                mutex_lock(&info_mutex);
    756779                snd_info_clear_entries(entry);
     780                mutex_unlock(&info_mutex);
    757781        }
    758782
     
    763787        p = entry->parent;
    764788        if (p) {
    765                 guard(mutex)(&p->access);
     789                mutex_lock(&p->access);
    766790                list_del(&entry->list);
     791                mutex_unlock(&p->access);
    767792        }
    768793        kfree(entry->name);
     
    780805                return -ENXIO;
    781806        root = entry->parent == NULL ? snd_proc_root->p : entry->parent->p;
    782         guard(mutex)(&info_mutex);
     807        mutex_lock(&info_mutex);
    783808        if (entry->p || !root)
    784                 return 0;
     809                goto unlock;
    785810#ifndef TARGET_OS2
    786811        if (S_ISDIR(entry->mode)) {
     
    802827#endif
    803828        entry->p = p;
     829 unlock:
     830        mutex_unlock(&info_mutex);
    804831        return 0;
    805832}
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/info_oss.c

    r766 r767  
    3030        if (snd_BUG_ON(num < 0 || num >= SNDRV_CARDS))
    3131                return -ENXIO;
    32         guard(mutex)(&strings);
     32        mutex_lock(&strings);
    3333        if (string == NULL) {
    3434                x = snd_sndstat_strings[num][dev];
     
    3737        } else {
    3838                x = kstrdup(string, GFP_KERNEL);
    39                 if (x == NULL)
     39                if (x == NULL) {
     40                        mutex_unlock(&strings);
    4041                        return -ENOMEM;
    4142                }
     43        }
    4244        snd_sndstat_strings[num][dev] = x;
     45        mutex_unlock(&strings);
    4346        return 0;
    4447}
     
    5154
    5255        snd_iprintf(buf, "\n%s:", id);
    53         guard(mutex)(&strings);
     56        mutex_lock(&strings);
    5457        for (idx = 0; idx < SNDRV_CARDS; idx++) {
    5558                str = snd_sndstat_strings[idx][dev];
     
    6265                }
    6366        }
     67        mutex_unlock(&strings);
    6468        if (ok < 0)
    6569                snd_iprintf(buf, " NOT ENABLED IN CONFIG\n");
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/init.c

    r766 r767  
    289289                strscpy(card->id, xid, sizeof(card->id));
    290290        err = 0;
    291         scoped_guard(mutex, &snd_card_mutex) {
     291        mutex_lock(&snd_card_mutex);
    292292        if (idx < 0) /* first check the matching module-name slot */
    293293                idx = get_slot_from_bitmask(idx, module_slot_match, module);
     
    301301        } else if (idx >= SNDRV_CARDS)
    302302                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         }
    309303        if (err < 0) {
     304                mutex_unlock(&snd_card_mutex);
    310305                dev_err(parent, "cannot find the slot for index %d (range 0-%i), error: %d\n",
    311306                         idx, snd_ecards_limit - 1, err);
     
    314309                return err;
    315310        }
     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);
    316315        card->dev = parent;
    317316        card->number = idx;
     
    390389        struct snd_card *card;
    391390
    392         guard(mutex)(&snd_card_mutex);
     391        mutex_lock(&snd_card_mutex);
    393392        card = snd_cards[idx];
    394393        if (card)
    395394                get_device(&card->card_dev);
     395        mutex_unlock(&snd_card_mutex);
    396396        return card;
    397397}
     
    401401int snd_card_locked(int card)
    402402{
    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;
    405409}
    406410
     
    426430        struct snd_monitor_file *df = NULL, *_df;
    427431
    428         scoped_guard(spinlock, &shutdown_lock) {
     432        spin_lock(&shutdown_lock);
    429433        list_for_each_entry(_df, &shutdown_files, shutdown_list, struct snd_monitor_file) {
    430434                if (_df->file == file) {
     
    434438                }
    435439        }
    436         }
     440        spin_unlock(&shutdown_lock);
    437441
    438442        if (likely(df)) {
     
    503507                return;
    504508
    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);
    507512                return;
     513        }
    508514        card->shutdown = 1;
    509515
     
    514520                mfile->disconnected_f_op = mfile->file->f_op;
    515521
    516                         scoped_guard(spinlock, &shutdown_lock)
     522                spin_lock(&shutdown_lock);
    517523                list_add(&mfile->shutdown_list, &shutdown_files);
     524                spin_unlock(&shutdown_lock);
    518525
    519526                mfile->file->f_op = &snd_shutdown_f_ops;
    520527                //DAZ this does nothing. fops_get(mfile->file->f_op);
    521528        }
    522         }
     529        spin_unlock(&card->files_lock);
    523530
    524531#ifdef CONFIG_PM
     
    556563
    557564        /* disable fops (user space) operations for ALSA API */
    558         scoped_guard(mutex, &snd_card_mutex) {
     565        mutex_lock(&snd_card_mutex);
    559566        snd_cards[card->number] = NULL;
    560567        clear_bit(card->number, snd_cards_lock);
    561         }
     568        mutex_unlock(&snd_card_mutex);
    562569
    563570        snd_power_sync_ref(card);
     
    578585        snd_card_disconnect(card);
    579586
    580         guard(spinlock_irq)(&card->files_lock);
     587        spin_lock_irq(&card->files_lock);
    581588        wait_event_lock_irq(card->remove_sleep,
    582589                            list_empty(&card->files_list),
    583590                            card->files_lock);
     591        spin_unlock_irq(&card->files_lock);
    584592}
    585593EXPORT_SYMBOL_GPL(snd_card_disconnect_sync);
     
    777785        if (card->id[0] != '\0')
    778786                return;
    779         guard(mutex)(&snd_card_mutex);
     787        mutex_lock(&snd_card_mutex);
    780788        snd_card_set_id_no_lock(card, nid, nid);
     789        mutex_unlock(&snd_card_mutex);
    781790}
    782791EXPORT_SYMBOL(snd_card_set_id);
     
    807816        memcpy(buf1, buf, copy);
    808817        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);
    811821                return -EEXIST;
     822        }
    812823        strcpy(card->id, buf1);
    813824        snd_info_card_id_change(card);
     825        mutex_unlock(&snd_card_mutex);
    814826
    815827        return count;
     
    905917        if (err < 0)
    906918                return err;
    907         scoped_guard(mutex, &snd_card_mutex) {
     919        mutex_lock(&snd_card_mutex);
    908920        if (snd_cards[card->number]) {
    909921                /* already registered */
     922                mutex_unlock(&snd_card_mutex);
    910923                return snd_info_card_register(card); /* register pending info */
    911924        }
     
    913926                /* make a unique id name from the given string */
    914927                char tmpid[sizeof(card->id)];
    915 
    916928                memcpy(tmpid, card->id, sizeof(card->id));
    917929                snd_card_set_id_no_lock(card, tmpid, tmpid);
     
    919931                /* create an id from either shortname or longname */
    920932                const char *src;
    921 
    922933                src = *card->shortname ? card->shortname : card->longname;
    923934                snd_card_set_id_no_lock(card, src,
     
    925936        }
    926937        snd_cards[card->number] = card;
    927         }
     938        mutex_unlock(&snd_card_mutex);
    928939        err = snd_info_card_register(card);
    929940        if (err < 0)
     
    946957
    947958        for (idx = count = 0; idx < SNDRV_CARDS; idx++) {
    948                 guard(mutex)(&snd_card_mutex);
     959                mutex_lock(&snd_card_mutex);
    949960                card = snd_cards[idx];
    950961                if (card) {
     
    958969                                        card->longname);
    959970                }
     971                mutex_unlock(&snd_card_mutex);
    960972        }
    961973        if (!count)
     
    970982
    971983        for (idx = count = 0; idx < SNDRV_CARDS; idx++) {
    972                 guard(mutex)(&snd_card_mutex);
     984                mutex_lock(&snd_card_mutex);
    973985                card = snd_cards[idx];
    974986                if (card) {
     
    976988                        snd_iprintf(buffer, "%s\n", card->longname);
    977989                }
     990                mutex_unlock(&snd_card_mutex);
    978991        }
    979992        if (!count) {
     
    9921005
    9931006        for (idx = 0; idx < SNDRV_CARDS; idx++) {
    994                 guard(mutex)(&snd_card_mutex);
     1007                mutex_lock(&snd_card_mutex);
    9951008                card = snd_cards[idx];
    9961009                if (card)
    9971010                        snd_iprintf(buffer, "%2i %s\n",
    9981011                                    idx, card->module->name);
     1012                mutex_unlock(&snd_card_mutex);
    9991013        }
    10001014}
     
    10781092        mfile->disconnected_f_op = NULL;
    10791093        INIT_LIST_HEAD(&mfile->shutdown_list);
    1080         guard(spinlock)(&card->files_lock);
     1094        spin_lock(&card->files_lock);
    10811095        if (card->shutdown) {
     1096        spin_unlock(&card->files_lock);
    10821097                kfree(mfile);
    10831098                return -ENODEV;
     
    11061121        struct snd_monitor_file *mfile, *found = NULL;
    11071122
    1108         scoped_guard(spinlock, &card->files_lock) {
     1123        spin_lock(&card->files_lock);
    11091124        list_for_each_entry(mfile, &card->files_list, list, struct snd_monitor_file) {
    11101125                if (mfile->file == file) {
    11111126                        list_del(&mfile->list);
    1112                                 scoped_guard(spinlock, &shutdown_lock)
     1127                        spin_lock(&shutdown_lock);
    11131128                        list_del(&mfile->shutdown_list);
     1129                        spin_unlock(&shutdown_lock);
    11141130                        if (mfile->disconnected_f_op)
    11151131                                fops_put(mfile->disconnected_f_op);
    11161132                        found = mfile;
    11171133                        break;
    1118                 }
     1134                }
    11191135        }
    11201136        if (list_empty(&card->files_list))
    11211137                wake_up_all(&card->remove_sleep);
    1122         }
     1138        spin_unlock(&card->files_lock);
    11231139        if (!found) {
    11241140                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  
    16371637                result = 0;
    16381638                set_current_state(TASK_INTERRUPTIBLE);
    1639                 scoped_guard(pcm_stream_lock_irq, substream)
     1639                snd_pcm_stream_lock_irq(substream);
    16401640                state = runtime->state;
     1641                snd_pcm_stream_unlock_irq(substream);
    16411642                if (state != SNDRV_PCM_STATE_RUNNING) {
    16421643                        set_current_state(TASK_RUNNING);
     
    23472348        struct snd_pcm_oss_setup *setup;
    23482349
    2349         guard(mutex)(&pcm->streams[stream].oss.setup_mutex);
     2350        mutex_lock(&pcm->streams[stream].oss.setup_mutex);
    23502351        do {
    23512352                for (setup = pcm->streams[stream].oss.setup_list; setup;
     
    23582359        if (setup)
    23592360                *rsetup = *setup;
     2361        mutex_unlock(&pcm->streams[stream].oss.setup_mutex);
    23602362}
    23612363
     
    28522854                struct snd_pcm_runtime *runtime = psubstream->runtime;
    28532855                poll_wait(file, &runtime->sleep, wait);
    2854                 scoped_guard(pcm_stream_lock_irq, psubstream) {
     2856                snd_pcm_stream_lock_irq(psubstream);
    28552857                if (runtime->state != SNDRV_PCM_STATE_DRAINING &&
    28562858                    (runtime->state != SNDRV_PCM_STATE_RUNNING ||
    28572859                     snd_pcm_oss_playback_ready(psubstream)))
    28582860                        mask |= EPOLLOUT | EPOLLWRNORM;
    2859                 }
     2861                snd_pcm_stream_unlock_irq(psubstream);
    28602862        }
    28612863        if (csubstream != NULL) {
     
    28632865                snd_pcm_state_t ostate;
    28642866                poll_wait(file, &runtime->sleep, wait);
    2865                 scoped_guard(pcm_stream_lock_irq, csubstream) {
     2867                snd_pcm_stream_lock_irq(csubstream);
    28662868                ostate = runtime->state;
    28672869                if (ostate != SNDRV_PCM_STATE_RUNNING ||
    28682870                    snd_pcm_oss_capture_ready(csubstream))
    28692871                        mask |= EPOLLIN | EPOLLRDNORM;
    2870                 }
     2872                snd_pcm_stream_unlock_irq(csubstream);
    28712873                if (ostate != SNDRV_PCM_STATE_RUNNING && runtime->oss.trigger) {
    28722874                        struct snd_pcm_oss_file ofile;
     
    29652967        struct snd_pcm_str *pstr = entry->private_data;
    29662968        struct snd_pcm_oss_setup *setup = pstr->oss.setup_list;
    2967         guard(mutex)(&pstr->oss.setup_mutex);
     2969        mutex_lock(&pstr->oss.setup_mutex);
    29682970        while (setup) {
    29692971                snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n",
     
    29792981                setup = setup->next;
    29802982        }
     2983        mutex_unlock(&pstr->oss.setup_mutex);
    29812984}
    29822985
     
    30043007
    30053008        while (!snd_info_get_line(buffer, line, sizeof(line))) {
    3006                 guard(mutex)(&pstr->oss.setup_mutex);
     3009                mutex_lock(&pstr->oss.setup_mutex);
    30073010                memset(&template, 0, sizeof(template));
    30083011                ptr = snd_info_get_str(task_name, line, sizeof(task_name));
    30093012                if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) {
    30103013                        snd_pcm_oss_proc_free_setup_list(pstr);
     3014                        mutex_unlock(&pstr->oss.setup_mutex);
    30113015                        continue;
    30123016                }
     
    30483052                        if (! setup) {
    30493053                                buffer->error = -ENOMEM;
     3054                                mutex_unlock(&pstr->oss.setup_mutex);
    30503055                                return;
    30513056                        }
     
    30653070                }
    30663071                *setup = template;
     3072                mutex_unlock(&pstr->oss.setup_mutex);
    30673073        }
    30683074}
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/pcm.c

    r766 r767  
    9595                        if (get_user(device, (int __user *)arg))
    9696                                return -EFAULT;
    97                         scoped_guard(mutex, &register_mutex)
     97                        mutex_lock(&register_mutex);
    9898                        device = snd_pcm_next(card, device);
     99                        mutex_unlock(&register_mutex);
    99100                        if (put_user(device, (int __user *)arg))
    100101                                return -EFAULT;
     
    109110                        struct snd_pcm_str *pstr;
    110111                        struct snd_pcm_substream *substream;
     112                        int err;
    111113
    112114                        info = (struct snd_pcm_info __user *)arg;
     
    120122                        if (get_user(subdevice, &info->subdevice))
    121123                                return -EFAULT;
    122                         guard(mutex)(&register_mutex);
     124                        mutex_lock(&register_mutex);
    123125                        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                        }
    131138                        for (substream = pstr->substream; substream;
    132139                             substream = substream->next)
    133140                                if (substream->number == (int)subdevice)
    134141                                        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(&register_mutex);
     151                        return err;
    139152                }
    140153        case SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE:
     
    379392        struct snd_pcm_runtime *runtime;
    380393
    381         guard(mutex)(&substream->pcm->open_mutex);
     394        mutex_lock(&substream->pcm->open_mutex);
    382395        runtime = substream->runtime;
    383396        if (!runtime) {
    384397                snd_iprintf(buffer, "closed\n");
    385                 return;
     398                goto unlock;
    386399        }
    387400        if (runtime->state == SNDRV_PCM_STATE_OPEN) {
    388401                snd_iprintf(buffer, "no setup\n");
    389                 return;
     402                goto unlock;
    390403        }
    391404        snd_iprintf(buffer, "access: %s\n", snd_pcm_access_name(runtime->access));
     
    406419        }
    407420#endif
     421 unlock:
     422        mutex_unlock(&substream->pcm->open_mutex);
    408423}
    409424
     
    414429        struct snd_pcm_runtime *runtime;
    415430
    416         guard(mutex)(&substream->pcm->open_mutex);
     431        mutex_lock(&substream->pcm->open_mutex);
    417432        runtime = substream->runtime;
    418433        if (!runtime) {
    419434                snd_iprintf(buffer, "closed\n");
    420                 return;
     435                goto unlock;
    421436        }
    422437        if (runtime->state == SNDRV_PCM_STATE_OPEN) {
    423438                snd_iprintf(buffer, "no setup\n");
    424                 return;
     439                goto unlock;
    425440        }
    426441        snd_iprintf(buffer, "tstamp_mode: %s\n", snd_pcm_tstamp_mode_name(runtime->tstamp_mode));
     
    432447        snd_iprintf(buffer, "silence_size: %lu\n", runtime->silence_size);
    433448        snd_iprintf(buffer, "boundary: %lu\n", runtime->boundary);
     449 unlock:
     450        mutex_unlock(&substream->pcm->open_mutex);
    434451}
    435452
     
    442459        int err;
    443460
    444         guard(mutex)(&substream->pcm->open_mutex);
     461        mutex_lock(&substream->pcm->open_mutex);
    445462        runtime = substream->runtime;
    446463        if (!runtime) {
    447464                snd_iprintf(buffer, "closed\n");
    448                 return;
     465                goto unlock;
    449466        }
    450467        memset(&status, 0, sizeof(status));
     
    452469        if (err < 0) {
    453470                snd_iprintf(buffer, "error %d\n", err);
    454                 return;
     471                goto unlock;
    455472        }
    456473        snd_iprintf(buffer, "state: %s\n", snd_pcm_state_name(status.state));
     
    469486        snd_iprintf(buffer, "xrun_counter: %d\n", substream->xrun_counter);
    470487#endif
     488 unlock:
     489        mutex_unlock(&substream->pcm->open_mutex);
    471490}
    472491
     
    10031022        /* Avoid concurrent access to runtime via PCM timer interface */
    10041023        if (substream->timer) {
    1005                 scoped_guard(spinlock_irq, &substream->timer->lock)
     1024                spin_lock_irq(&substream->timer->lock);
    10061025                substream->runtime = NULL;
     1026                spin_unlock_irq(&substream->timer->lock);
    10071027        } else {
    10081028                substream->runtime = NULL;
     
    10631083        pcm = device->device_data;
    10641084
    1065         guard(mutex)(&register_mutex);
     1085        mutex_lock(&register_mutex);
    10661086        err = snd_pcm_add(pcm);
    10671087        if (err)
    1068                 return err;
     1088                goto unlock;
    10691089        for (cidx = 0; cidx < 2; cidx++) {
    10701090                int devtype = -1;
     
    10851105                if (err < 0) {
    10861106                        list_del_init(&pcm->list);
    1087                         return err;
     1107                        goto unlock;
    10881108                }
    10891109
     
    10931113
    10941114        pcm_call_notify(pcm, n_register);
     1115
     1116 unlock:
     1117        mutex_unlock(&register_mutex);
    10951118        return err;
    10961119}
     
    11021125        int cidx;
    11031126
    1104         guard(mutex)(&register_mutex);
    1105         guard(mutex)(&pcm->open_mutex);
     1127        mutex_lock(&register_mutex);
     1128        mutex_lock(&pcm->open_mutex);
    11061129        wake_up(&pcm->open_wait);
    11071130        list_del_init(&pcm->list);
     
    11301153                free_chmap(&pcm->streams[cidx]);
    11311154        }
     1155        mutex_unlock(&pcm->open_mutex);
     1156        mutex_unlock(&register_mutex);
    11321157        return 0;
    11331158}
     
    11541179                       !notify->n_disconnect))
    11551180                return -EINVAL;
    1156         guard(mutex)(&register_mutex);
     1181        mutex_lock(&register_mutex);
    11571182        if (nfree) {
    11581183                list_del(&notify->list);
     
    11641189                        notify->n_register(pcm);
    11651190        }
     1191        mutex_unlock(&register_mutex);
    11661192        return 0;
    11671193}
     
    11791205        struct snd_pcm *pcm;
    11801206
    1181         guard(mutex)(&register_mutex);
     1207        mutex_lock(&register_mutex);
    11821208        list_for_each_entry(pcm, &snd_pcm_devices, list, struct snd_pcm) {
    11831209                snd_iprintf(buffer, "%02i-%02i: %s : %s",
     
    11911217                snd_iprintf(buffer, "\n");
    11921218        }
     1219        mutex_unlock(&register_mutex);
    11931220}
    11941221
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/pcm_lib.c

    r766 r767  
    18011801{
    18021802        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);
    18051805        if (snd_pcm_running(substream) &&
    18061806            snd_pcm_update_hw_ptr(substream) >= 0)
     
    18101810                runtime->hw_ptr_wrap = 0;
    18111811        }
     1812        snd_pcm_stream_unlock_irqrestore(substream, flags);
    18121813        return 0;
    18131814}
     
    19701971void snd_pcm_period_elapsed(struct snd_pcm_substream *substream)
    19711972{
     1973        unsigned long flags;
     1974
    19721975        if (snd_BUG_ON(!substream))
    19731976                return;
    19741977
    1975         guard(pcm_stream_lock_irqsave)(substream);
     1978        snd_pcm_stream_lock_irqsave(substream, flags);
    19761979        snd_pcm_period_elapsed_under_stream_lock(substream);
     1980        snd_pcm_stream_unlock_irqrestore(substream, flags);
    19771981}
    19781982EXPORT_SYMBOL(snd_pcm_period_elapsed);
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/pcm_memory.c

    r766 r767  
    3838static void update_allocated_size(struct snd_card *card, ssize_t bytes)
    3939{
    40         guard(mutex)(&card->memory_mutex);
     40        mutex_lock(&card->memory_mutex);
    4141        __update_allocated_size(card, bytes);
     42        mutex_unlock(&card->memory_mutex);
    4243}
    4344
    4445static void decrease_allocated_size(struct snd_card *card, size_t bytes)
    4546{
    46         guard(mutex)(&card->memory_mutex);
     47        mutex_lock(&card->memory_mutex);
    4748        WARN_ON(card->total_pcm_alloc_bytes < bytes);
    4849        __update_allocated_size(card, -(ssize_t)bytes);
     50        mutex_unlock(&card->memory_mutex);
    4951}
    5052
     
    5658
    5759        /* check and reserve the requested size */
    58         scoped_guard(mutex, &card->memory_mutex) {
     60        mutex_lock(&card->memory_mutex);
    5961        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);
    6164                return -ENOMEM;
     65        }
    6266        __update_allocated_size(card, size);
    63         }
     67        mutex_unlock(&card->memory_mutex);
    6468
    6569        if (str == SNDRV_PCM_STREAM_PLAYBACK)
     
    188192        struct snd_card *card = substream->pcm->card;
    189193        char line[64], str[64];
    190         unsigned long size;
     194        size_t size;
    191195        struct snd_dma_buffer new_dmab;
    192196
    193         guard(mutex)(&substream->pcm->open_mutex);
     197        mutex_lock(&substream->pcm->open_mutex);
    194198        if (substream->runtime) {
    195199                buffer->error = -EBUSY;
     
    198202        if (!snd_info_get_line(buffer, line, sizeof(line))) {
    199203                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;
    204205                if ((size != 0 && size < 8192) || size > substream->dma_max) {
    205206                        buffer->error = -EINVAL;
    206                         return;
     207                        goto unlock;
    207208                }
    208209                if (substream->dma_buffer.bytes == size)
    209                         return;
     210                        goto unlock;
    210211                memset(&new_dmab, 0, sizeof(new_dmab));
    211212                new_dmab.dev = substream->dma_buffer.dev;
     
    221222                                         substream->stream ? 'c' : 'p', substream->number,
    222223                                         substream->pcm->name, size);
    223                                 return;
     224                                goto unlock;
    224225                        }
    225226                        substream->buffer_bytes_max = size;
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/pcm_native.c

    r766 r767  
    620620                              snd_pcm_state_t state)
    621621{
    622         guard(pcm_stream_lock_irq)(substream);
     622        snd_pcm_stream_lock_irq(substream);
    623623        if (substream->runtime->state != SNDRV_PCM_STATE_DISCONNECTED)
    624624                __snd_pcm_set_state(substream->runtime, state);
     625        snd_pcm_stream_unlock_irq(substream);
    625626}
    626627
     
    750751        if (err < 0)
    751752                return err;
    752         scoped_guard(pcm_stream_lock_irq, substream) {
     753        snd_pcm_stream_lock_irq(substream);
    753754        switch (runtime->state) {
    754755        case SNDRV_PCM_STATE_OPEN:
     
    757758                if (!is_oss_stream(substream) &&
    758759                    atomic_read(&substream->mmap_count))
    759                         err = -EBADFD;
     760                err = -EBADFD;
    760761                break;
    761762        default:
     
    763764                break;
    764765        }
    765         }
     766        snd_pcm_stream_unlock_irq(substream);
    766767        if (err)
    767768                goto unlock;
     
    913914        if (result < 0)
    914915                return result;
    915         scoped_guard(pcm_stream_lock_irq, substream) {
     916        snd_pcm_stream_lock_irq(substream);
    916917        switch (runtime->state) {
    917918        case SNDRV_PCM_STATE_SETUP:
    918919        case SNDRV_PCM_STATE_PREPARED:
    919920                if (atomic_read(&substream->mmap_count))
    920                         result = -EBADFD;
     921                result = -EBADFD;
    921922                break;
    922923        default:
     
    924925                break;
    925926        }
    926         }
     927        snd_pcm_stream_unlock_irq(substream);
    927928        if (result)
    928929                goto unlock;
     
    944945                return -ENXIO;
    945946        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);
    948950                return -EBADFD;
    949951        }
     952        snd_pcm_stream_unlock_irq(substream);
    950953
    951954        if (params->tstamp_mode < 0 ||
     
    967970        }
    968971        err = 0;
    969         scoped_guard(pcm_stream_lock_irq, substream) {
     972        snd_pcm_stream_lock_irq(substream);
    970973        runtime->tstamp_mode = params->tstamp_mode;
    971974        if (params->proto >= SNDRV_PROTOCOL_VERSION(2, 0, 12))
     
    984987                err = snd_pcm_update_state(substream, runtime);
    985988        }
    986         }
     989        snd_pcm_stream_unlock_irq(substream);
    987990        return err;
    988991}
     
    10181021        struct snd_pcm_runtime *runtime = substream->runtime;
    10191022
    1020         guard(pcm_stream_lock_irq)(substream);
     1023        snd_pcm_stream_lock_irq(substream);
    10211024
    10221025        snd_pcm_unpack_audio_tstamp_config(status->audio_tstamp_data,
     
    10391042        status->suspended_state = runtime->suspended_state;
    10401043        if (status->state == SNDRV_PCM_STATE_OPEN)
    1041                 return 0;
     1044                goto _end;
    10421045        status->trigger_tstamp_sec = runtime->trigger_tstamp.tv_sec;
    10431046        status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec;
     
    10841087        runtime->avail_max = 0;
    10851088        runtime->overrange = 0;
     1089 _end:
     1090        snd_pcm_stream_unlock_irq(substream);
    10861091        return 0;
    10871092}
     
    11891194        channel = info->channel;
    11901195        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);
    11931199                return -EBADFD;
    11941200        }
     1201        snd_pcm_stream_unlock_irq(substream);
    11951202        if (channel >= runtime->channels)
    11961203                return -EINVAL;
     
    14131420                                   snd_pcm_state_t state)
    14141421{
    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;
    14171428}
    14181429
     
    14261437
    14271438        /* 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);
    14291440        res = snd_pcm_buffer_access_lock(substream->runtime);
    14301441        if (res < 0)
    1431                 return res;
     1442                goto unlock;
    14321443        if (snd_pcm_stream_linked(substream))
    14331444                res = snd_pcm_action_group(ops, substream, state, false);
     
    14351446                res = snd_pcm_action_single(ops, substream, state);
    14361447        snd_pcm_buffer_access_unlock(substream->runtime);
     1448 unlock:
     1449        up_read(&snd_pcm_link_rwsem);
    14371450        return res;
    14381451}
     
    16041617int snd_pcm_stop_xrun(struct snd_pcm_substream *substream)
    16051618{
    1606         guard(pcm_stream_lock_irqsave)(substream);
     1619        unsigned long flags;
     1620
     1621        snd_pcm_stream_lock_irqsave(substream, flags);
    16071622        if (substream->runtime && snd_pcm_running(substream))
    16081623                __snd_pcm_xrun(substream);
     1624        snd_pcm_stream_unlock_irqrestore(substream, flags);
    16091625        return 0;
    16101626}
     
    17581774static int snd_pcm_suspend(struct snd_pcm_substream *substream)
    17591775{
    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,
    17621781                             ACTION_ARG_IGNORE);
     1782        snd_pcm_stream_unlock_irqrestore(substream, flags);
     1783        return err;
    17631784}
    17641785
     
    18781899{
    18791900        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);
    18821904        switch (runtime->state) {
    18831905        case SNDRV_PCM_STATE_XRUN:
    1884                 return 0;       /* already there */
     1906                result = 0;     /* already there */
     1907                break;
    18851908        case SNDRV_PCM_STATE_RUNNING:
    18861909                __snd_pcm_xrun(substream);
    1887                 return 0;
     1910                result = 0;     /* already there */
     1911                break;
    18881912        default:
    1889                 return -EBADFD;
    1890         }
     1913                result -EBADFD;
     1914        }
     1915        snd_pcm_stream_unlock_irq(substream);
     1916        return result;
    18911917}
    18921918
     
    19171943        if (err < 0)
    19181944                return err;
    1919         guard(pcm_stream_lock_irq)(substream);
     1945        snd_pcm_stream_lock_irq(substream);
    19201946        runtime->hw_ptr_base = 0;
    19211947        runtime->hw_ptr_interrupt = runtime->status->hw_ptr -
     
    19231949        runtime->silence_start = runtime->status->hw_ptr;
    19241950        runtime->silence_filled = 0;
     1951        snd_pcm_stream_unlock_irq(substream);
    19251952        return 0;
    19261953}
     
    19301957{
    19311958        struct snd_pcm_runtime *runtime = substream->runtime;
    1932         guard(pcm_stream_lock_irq)(substream);
     1959        snd_pcm_stream_lock_irq(substream);
    19331960        runtime->control->appl_ptr = runtime->status->hw_ptr;
    19341961        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
    19351962            runtime->silence_size > 0)
    19361963                snd_pcm_playback_silence(substream, ULONG_MAX);
     1964        snd_pcm_stream_unlock_irq(substream);
    19371965}
    19381966
     
    20102038                f_flags = substream->f_flags;
    20112039
    2012         scoped_guard(pcm_stream_lock_irq, substream) {
     2040        snd_pcm_stream_lock_irq(substream);
    20132041        switch (substream->runtime->state) {
    20142042        case SNDRV_PCM_STATE_PAUSED:
     
    20192047                break;
    20202048        }
    2021         }
     2049        snd_pcm_stream_unlock_irq(substream);
    20222050
    20232051        return snd_pcm_action_nonatomic(&snd_pcm_action_prepare,
     
    22362264                return -EBADFD;
    22372265
    2238         guard(pcm_stream_lock_irq)(substream);
     2266        snd_pcm_stream_lock_irq(substream);
    22392267        /* resume pause */
    22402268        if (runtime->state == SNDRV_PCM_STATE_PAUSED)
     
    22432271        snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
    22442272        /* runtime->control->appl_ptr = runtime->status->hw_ptr; */
     2273        snd_pcm_stream_unlock_irq(substream);
    22452274
    22462275        return result;
     
    22712300static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
    22722301{
     2302        int res = 0;
    22732303        struct snd_pcm_file *pcm_file;
    22742304        struct snd_pcm_substream *substream1;
     
    22832313#endif
    22842314
    2285         if (!fd_file(f))
     2315        if (!f.file)
    22862316                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;
    22912322        substream1 = pcm_file->substream;
    22922323
     
    22952326
    22962327        group = kzalloc(sizeof(*group), GFP_KERNEL);
    2297         if (!group)
    2298                 return -ENOMEM;
     2328        if (!group) {
     2329                res = -ENOMEM;
     2330                goto _nolock;
     2331        }
    22992332        snd_pcm_group_init(group);
    23002333
    2301         guard(rwsem_write)(&snd_pcm_link_rwsem);
     2334        down_write(&snd_pcm_link_rwsem);
    23022335        if (substream->runtime->state == SNDRV_PCM_STATE_OPEN ||
    23032336            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);
    23102347        if (!snd_pcm_stream_linked(substream)) {
    23112348                snd_pcm_group_assign(substream, group);
     
    23132350        }
    23142351        target_group = substream->group;
    2315         }
     2352        snd_pcm_stream_unlock_irq(substream);
    23162353
    23172354        snd_pcm_group_lock_irq(target_group, nonatomic);
     
    23212358        snd_pcm_stream_unlock(substream1);
    23222359        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;
    23242369}
    23252370
     
    23362381        bool nonatomic = substream->pcm->nonatomic;
    23372382        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        }
    23432391
    23442392        group = substream->group;
     
    23592407        if (do_free)
    23602408                kfree(group);
    2361         return 0;
     2409
     2410       _end:
     2411        up_write(&snd_pcm_link_rwsem);
     2412        return res;
    23622413}
    23632414
     
    29392990        snd_power_wait(pcm->card);
    29402991
    2941         scoped_guard(mutex, &pcm->open_mutex) {
     2992        mutex_lock(&pcm->open_mutex);
    29422993        snd_pcm_release_substream(substream);
    29432994        kfree(pcm_file);
    2944         }
     2995        mutex_unlock(&pcm->open_mutex);
    29452996        wake_up(&pcm->open_wait);
    29462997        module_put(pcm->card->module);
     
    30263077                return 0;
    30273078
    3028         scoped_guard(pcm_stream_lock_irq, substream) {
     3079        snd_pcm_stream_lock_irq(substream);
    30293080        ret = do_pcm_hwsync(substream);
    30303081        if (!ret)
    30313082                ret = rewind_appl_ptr(substream, frames,
    30323083                                      snd_pcm_hw_avail(substream));
    3033         }
     3084        snd_pcm_stream_unlock_irq(substream);
    30343085#ifndef TARGET_OS2
    30353086        if (ret >= 0)
     
    30473098                return 0;
    30483099
    3049         scoped_guard(pcm_stream_lock_irq, substream) {
     3100        snd_pcm_stream_lock_irq(substream);
    30503101        ret = do_pcm_hwsync(substream);
    30513102        if (!ret)
    30523103                ret = forward_appl_ptr(substream, frames,
    30533104                                       snd_pcm_avail(substream));
    3054         }
     3105        snd_pcm_stream_unlock_irq(substream);
    30553106#ifndef TARGET_OS2
    30563107        if (ret >= 0)
     
    30653116        int err;
    30663117
    3067         scoped_guard(pcm_stream_lock_irq, substream) {
     3118        snd_pcm_stream_lock_irq(substream);
    30683119        err = do_pcm_hwsync(substream);
    30693120        if (delay && !err)
    30703121                *delay = snd_pcm_calc_delay(substream);
    3071         }
     3122        snd_pcm_stream_unlock_irq(substream);
    30723123#ifndef TARGET_OS2
    30733124        snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_CPU);
     
    31023153                        return err;
    31033154        }
    3104         scoped_guard(pcm_stream_lock_irq, substream) {
     3155        snd_pcm_stream_lock_irq(substream);
    31053156        if (!(sync_ptr.flags & SNDRV_PCM_SYNC_PTR_APPL)) {
    31063157                err = pcm_lib_apply_appl_ptr(substream,
    31073158                                             sync_ptr.c.control.appl_ptr);
    3108                         if (err < 0)
     3159                if (err < 0) {
     3160                        snd_pcm_stream_unlock_irq(substream);
    31093161                        return err;
     3162        }
    31103163        } else {
    31113164                sync_ptr.c.control.appl_ptr = control->appl_ptr;
     
    31203173        sync_ptr.s.status.suspended_state = status->suspended_state;
    31213174        sync_ptr.s.status.audio_tstamp = status->audio_tstamp;
    3122         }
     3175        snd_pcm_stream_unlock_irq(substream);
    31233176#ifndef TARGET_OS2
    31243177        if (!(sync_ptr.flags & SNDRV_PCM_SYNC_PTR_APPL))
     
    32083261        if (! boundary)
    32093262                boundary = 0x7fffffff;
    3210         scoped_guard(pcm_stream_lock_irq, substream) {
     3263        snd_pcm_stream_lock_irq(substream);
    32113264        /* FIXME: we should consider the boundary for the sync from app */
    32123265        if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL)) {
    32133266                err = pcm_lib_apply_appl_ptr(substream,
    32143267                                scontrol.appl_ptr);
    3215                         if (err < 0)
     3268                if (err < 0) {
     3269                        snd_pcm_stream_unlock_irq(substream);
    32163270                        return err;
     3271                }
    32173272        } else
    32183273                scontrol.appl_ptr = control->appl_ptr % boundary;
     
    32263281        sstatus.suspended_state = status->suspended_state;
    32273282        sstatus.audio_tstamp = status->audio_tstamp;
    3228         }
     3283        snd_pcm_stream_unlock_irq(substream);
    32293284#ifndef TARGET_OS2
    32303285        if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL))
     
    35843639            runtime->state == SNDRV_PCM_STATE_DISCONNECTED)
    35853640                return -EBADFD;
    3586         if (!user_backed_iter(to))
     3641        if (!to->user_backed)
    35873642                return -EINVAL;
    35883643        if (to->nr_segs > 1024 || to->nr_segs != runtime->channels)
     
    36233678            runtime->state == SNDRV_PCM_STATE_DISCONNECTED)
    36243679                return -EBADFD;
    3625         if (!user_backed_iter(from))
     3680        if (!from->user_backed)
    36263681                return -EINVAL;
    36273682        if (from->nr_segs > 128 || from->nr_segs != runtime->channels ||
     
    36673722
    36683723        mask = 0;
    3669         guard(pcm_stream_lock_irq)(substream);
     3724        snd_pcm_stream_lock_irq(substream);
    36703725        avail = snd_pcm_avail(substream);
    36713726        switch (runtime->state) {
     
    36873742                break;
    36883743        }
     3744        snd_pcm_stream_unlock_irq(substream);
    36893745        return mask;
    36903746}
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/rawmidi.c

    r766 r767  
    124124static bool snd_rawmidi_ready(struct snd_rawmidi_substream *substream)
    125125{
    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;
    128133}
    129134
     
    254259                               bool is_input)
    255260{
    256         guard(spinlock_irqsave)(&substream->lock);
     261        unsigned long flags;
     262
     263        spin_lock_irqsave(&substream->lock, flags);
    257264        if (substream->opened && substream->runtime)
    258265                __reset_runtime_ptrs(substream->runtime, is_input);
     266        spin_unlock_irqrestore(&substream->lock, flags);
    259267}
    260268
     
    273281        struct snd_rawmidi_runtime *runtime;
    274282
    275         scoped_guard(spinlock_irq, &substream->lock) {
     283        spin_lock_irq(&substream->lock);
    276284        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 {
    279288                snd_rawmidi_buffer_ref(runtime);
    280289                runtime->drain = 1;
    281290        }
     291        spin_unlock_irq(&substream->lock);
     292        if (err < 0)
     293                return err;
    282294
    283295#ifndef TARGET_OS2
     
    289301#endif
    290302
    291         scoped_guard(spinlock_irq, &substream->lock) {
     303        spin_lock_irq(&substream->lock);
    292304        if (signal_pending(current))
    293305                err = -ERESTARTSYS;
     
    299311        }
    300312        runtime->drain = 0;
    301         }
     313        spin_unlock_irq(&substream->lock);
    302314
    303315        if (err != -ERESTARTSYS) {
     
    310322        }
    311323
    312         scoped_guard(spinlock_irq, &substream->lock)
     324        spin_lock_irq(&substream->lock);
    313325        snd_rawmidi_buffer_unref(runtime);
     326        spin_unlock_irq(&substream->lock);
    314327
    315328        return err;
     
    375388                        return err;
    376389                }
    377                 guard(spinlock_irq)(&substream->lock);
     390                spin_lock_irq(&substream->lock);
    378391                substream->opened = 1;
    379392                substream->active_sensing = 0;
     
    382395                substream->pid = get_pid(task_pid(current));
    383396                rmidi->streams[substream->stream].substream_opened++;
     397                spin_unlock_irq(&substream->lock);
    384398        }
    385399        substream->use_count++;
     
    444458                return -ENXIO;
    445459
    446         guard(mutex)(&rmidi->open_mutex);
     460        mutex_lock(&rmidi->open_mutex);
    447461        err = rawmidi_open_priv(rmidi, subdevice, mode, rfile);
     462        mutex_unlock(&rmidi->open_mutex);
    448463        if (err < 0)
    449464                module_put(rmidi->card->module);
     
    578593                snd_rawmidi_buffer_ref_sync(substream);
    579594        }
    580         scoped_guard(spinlock_irq, &substream->lock) {
     595        spin_lock_irq(&substream->lock);
    581596        substream->opened = 0;
    582597        substream->append = 0;
    583         }
     598        spin_unlock_irq(&substream->lock);
    584599        substream->ops->close(substream);
    585600        if (substream->runtime->private_free)
     
    596611
    597612        rmidi = rfile->rmidi;
    598         guard(mutex)(&rmidi->open_mutex);
     613        mutex_lock(&rmidi->open_mutex);
    599614        if (rfile->input) {
    600615                close_substream(rmidi, rfile->input, 1);
     
    606621        }
    607622        rfile->rmidi = NULL;
     623        mutex_unlock(&rmidi->open_mutex);
    608624        wake_up(&rmidi->open_wait);
    609625}
     
    706722int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info)
    707723{
    708         guard(mutex)(&register_mutex);
    709         return __snd_rawmidi_info_select(card, info);
     724        int ret;
     725
     726        mutex_lock(&register_mutex);
     727        ret = __snd_rawmidi_info_select(card, info);
     728        mutex_unlock(&register_mutex);
     729        return ret;
    710730}
    711731EXPORT_SYMBOL(snd_rawmidi_info_select);
     
    774794
    775795        snd_rawmidi_drain_output(substream);
    776         guard(mutex)(&substream->rmidi->open_mutex);
     796        mutex_lock(&substream->rmidi->open_mutex);
    777797        if (substream->append && substream->use_count > 1)
    778                 return -EBUSY;
     798                err = -EBUSY;
     799        else
    779800                err = resize_runtime_buffer(substream, params, false);
     801
    780802        if (!err)
    781803                substream->active_sensing = !params->no_active_sensing;
     804        mutex_unlock(&substream->rmidi->open_mutex);
    782805        return err;
    783806}
     
    792815
    793816        snd_rawmidi_drain_input(substream);
    794         guard(mutex)(&substream->rmidi->open_mutex);
     817        mutex_lock(&substream->rmidi->open_mutex);
    795818        if (framing == SNDRV_RAWMIDI_MODE_FRAMING_NONE && clock_type != SNDRV_RAWMIDI_MODE_CLOCK_NONE)
    796819                err = -EINVAL;
     
    806829                substream->clock_type = clock_type;
    807830        }
     831        mutex_unlock(&substream->rmidi->open_mutex);
    808832        return 0;
    809833}
     
    818842        memset(status, 0, sizeof(*status));
    819843        status->stream = SNDRV_RAWMIDI_STREAM_OUTPUT;
    820         guard(spinlock_irq)(&substream->lock);
     844        spin_lock_irq(&substream->lock);
    821845        status->avail = runtime->avail;
     846        spin_unlock_irq(&substream->lock);
    822847        return 0;
    823848}
     
    830855        memset(status, 0, sizeof(*status));
    831856        status->stream = SNDRV_RAWMIDI_STREAM_INPUT;
    832         guard(spinlock_irq)(&substream->lock);
     857        spin_lock_irq(&substream->lock);
    833858        status->avail = runtime->avail;
    834859        status->xruns = runtime->xruns;
    835860        runtime->xruns = 0;
     861        spin_unlock_irq(&substream->lock);
    836862        return 0;
    837863}
     
    10281054        if (device >= SNDRV_RAWMIDI_DEVICES) /* next device is -1 */
    10291055                device = SNDRV_RAWMIDI_DEVICES - 1;
    1030         scoped_guard(mutex, &register_mutex) {
     1056        mutex_lock(&register_mutex);
    10311057        device = device < 0 ? 0 : device + 1;
    10321058        for (; device < SNDRV_RAWMIDI_DEVICES; device++) {
     
    10401066        if (device == SNDRV_RAWMIDI_DEVICES)
    10411067                device = -1;
    1042         }
     1068        mutex_unlock(&register_mutex);
    10431069        if (put_user(device, argp))
    10441070                return -EFAULT;
     
    10531079        struct snd_ump_endpoint_info __user *info = argp;
    10541080        struct snd_rawmidi *rmidi;
    1055         int device;
     1081        int device, ret;
    10561082
    10571083        if (get_user(device, &info->device))
    10581084                return -EFAULT;
    1059         guard(mutex)(&register_mutex);
     1085        mutex_lock(&register_mutex);
    10601086        rmidi = snd_rawmidi_search(card, device);
    10611087        if (rmidi && rmidi->ops && rmidi->ops->ioctl)
    1062                 return rmidi->ops->ioctl(rmidi, cmd, argp);
     1088                ret = rmidi->ops->ioctl(rmidi, cmd, argp);
    10631089        else
    1064                 return -ENXIO;
     1090                ret = -ENXIO;
     1091        mutex_unlock(&register_mutex);
     1092        return ret;
    10651093}
    10661094#endif
     
    11761204                        const unsigned char *buffer, int count)
    11771205{
     1206        unsigned long flags;
    11781207        struct timespec64 ts64 = get_framing_tstamp(substream);
    11791208        int result = 0, count1;
    11801209        struct snd_rawmidi_runtime *runtime;
    11811210
    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        }
    11851216        runtime = substream->runtime;
    11861217        if (!runtime || !runtime->buffer) {
    11871218                rmidi_dbg(substream->rmidi,
    11881219                          "snd_rawmidi_receive: input is not active!!!\n");
    1189                 return -EINVAL;
     1220                result = -EINVAL;
     1221                goto unlock;
    11901222        }
    11911223
    11921224        count = get_aligned_size(runtime, count);
    11931225        if (!count)
    1194                 return result;
     1226                goto unlock;
    11951227
    11961228        if (substream->framing == SNDRV_RAWMIDI_MODE_FRAMING_TSTAMP) {
     
    12151247                count1 = get_aligned_size(runtime, count1);
    12161248                if (!count1)
    1217                         return result;
     1249                        goto unlock;
    12181250                memcpy(runtime->buffer + runtime->hw_ptr, buffer, count1);
    12191251                runtime->hw_ptr += count1;
     
    12431275                        wake_up(&runtime->sleep);
    12441276        }
     1277 unlock:
     1278        spin_unlock_irqrestore(&substream->lock, flags);
    12451279        return result;
    12461280}
     
    13651399        struct snd_rawmidi_runtime *runtime;
    13661400
    1367         guard(spinlock_irqsave)(&substream->lock);
     1401        int result;
     1402        unsigned long flags;
     1403 
     1404        spin_lock_irqsave(&substream->lock, flags);
    13681405        runtime = substream->runtime;
    13691406        if (!substream->opened || !runtime || !runtime->buffer) {
    13701407                rmidi_dbg(substream->rmidi,
    13711408                          "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;
    13751415}
    13761416EXPORT_SYMBOL(snd_rawmidi_transmit_empty);
     
    14461486                              unsigned char *buffer, int count)
    14471487{
    1448         guard(spinlock_irqsave)(&substream->lock);
     1488        int result;
     1489        unsigned long flags;
     1490
     1491        spin_lock_irqsave(&substream->lock, flags);
    14491492        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;
    14521498}
    14531499EXPORT_SYMBOL(snd_rawmidi_transmit_peek);
     
    14961542int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count)
    14971543{
    1498         guard(spinlock_irqsave)(&substream->lock);
     1544        int result;
     1545        unsigned long flags;
     1546
     1547        spin_lock_irqsave(&substream->lock, flags);
    14991548        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;
    15021554}
    15031555EXPORT_SYMBOL(snd_rawmidi_transmit_ack);
     
    15161568                         unsigned char *buffer, int count)
    15171569{
    1518         guard(spinlock_irqsave)(&substream->lock);
     1570        int result;
     1571        unsigned long flags;
     1572
     1573        spin_lock_irqsave(&substream->lock, flags);
    15191574        if (!substream->opened)
    1520                 return -EBADFD;
     1575                result = -EBADFD;
     1576        else {
    15211577                count = __snd_rawmidi_transmit_peek(substream, buffer, count);
    15221578                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;
    15251585}
    15261586EXPORT_SYMBOL(snd_rawmidi_transmit);
     
    15351595{
    15361596        struct snd_rawmidi_runtime *runtime;
     1597        unsigned long flags;
    15371598        int count = 0;
    15381599
    1539         guard(spinlock_irqsave)(&substream->lock);
     1600        spin_lock_irqsave(&substream->lock, flags);
    15401601        runtime = substream->runtime;
    15411602        if (substream->opened && runtime &&
     
    15441605                __snd_rawmidi_transmit_ack(substream, count);
    15451606        }
     1607        spin_unlock_irqrestore(&substream->lock, flags);
    15461608        return count;
    15471609}
     
    17491811        if (rmidi->ops && rmidi->ops->proc_read)
    17501812                rmidi->ops->proc_read(entry, buffer);
    1751         guard(mutex)(&rmidi->open_mutex);
     1813        mutex_lock(&rmidi->open_mutex);
    17521814        if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) {
    17531815                list_for_each_entry(substream,
     
    17641826                                    pid_vnr(substream->pid));
    17651827                                runtime = substream->runtime;
    1766                                 scoped_guard(spinlock_irq, &substream->lock) {
     1828                                spin_lock_irq(&substream->lock);
    17671829                                buffer_size = runtime->buffer_size;
    17681830                                avail = runtime->avail;
    1769                                 }
     1831                                spin_unlock_irq(&substream->lock);
    17701832                                snd_iprintf(buffer,
    17711833                                    "  Mode         : %s\n"
     
    17911853                                            pid_vnr(substream->pid));
    17921854                                runtime = substream->runtime;
    1793                                 scoped_guard(spinlock_irq, &substream->lock) {
     1855                                spin_lock_irq(&substream->lock);
    17941856                                buffer_size = runtime->buffer_size;
    17951857                                avail = runtime->avail;
    17961858                                xruns = runtime->xruns;
    1797                                 }
     1859                                spin_unlock_irq(&substream->lock);
    17981860                                snd_iprintf(buffer,
    17991861                                            "  Buffer size  : %lu\n"
     
    18121874                }
    18131875        }
     1876        mutex_unlock(&rmidi->open_mutex);
    18141877}
    18151878
     
    20012064                return -ENOMEM;
    20022065        err = 0;
    2003         scoped_guard(mutex, &register_mutex) {
     2066        mutex_lock(&register_mutex);
    20042067        if (snd_rawmidi_search(rmidi->card, rmidi->device))
    20052068                err = -EBUSY;
    20062069        else
    20072070                list_add_tail(&rmidi->list, &snd_rawmidi_devices);
    2008         }
     2071        mutex_unlock(&register_mutex);
    20092072        if (err < 0)
    20102073                return err;
     
    20792142        snd_unregister_device(rmidi->dev);
    20802143 error:
    2081         scoped_guard(mutex, &register_mutex)
     2144        mutex_lock(&register_mutex);
    20822145        list_del(&rmidi->list);
     2146        mutex_unlock(&register_mutex);
    20832147        return err;
    20842148}
     
    20892153        int dir;
    20902154
    2091         guard(mutex)(&register_mutex);
    2092         guard(mutex)(&rmidi->open_mutex);
     2155        mutex_lock(&register_mutex);
     2156        mutex_lock(&rmidi->open_mutex);
    20932157        wake_up(&rmidi->open_wait);
    20942158        list_del_init(&rmidi->list);
     
    21162180#endif /* CONFIG_SND_OSSEMUL */
    21172181        snd_unregister_device(rmidi->dev);
     2182        mutex_unlock(&rmidi->open_mutex);
     2183        mutex_unlock(&register_mutex);
    21182184        return 0;
    21192185}
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_fifo.c

    r766 r767  
    8989
    9090        snd_use_lock_sync(&f->use_lock);
    91         guard(spinlock_irq)(&f->lock);
     91        spin_lock_irq(&f->lock);
    9292        /* drain the fifo */
    9393        while ((cell = fifo_cell_out(f)) != NULL) {
    9494                snd_seq_cell_free(cell);
    9595        }
     96        spin_unlock_irq(&f->lock);
    9697}
    9798
     
    102103{
    103104        struct snd_seq_event_cell *cell;
     105        unsigned long flags;
    104106        int err;
    105107
     
    117119               
    118120        /* append new cells to fifo */
    119         scoped_guard(spinlock_irqsave, &f->lock) {
     121        spin_lock_irqsave(&f->lock, flags);
    120122        if (f->tail != NULL)
    121123                f->tail->next = cell;
     
    125127        cell->next = NULL;
    126128        f->cells++;
    127         }
     129        spin_unlock_irqrestore(&f->lock, flags);
    128130
    129131        /* wakeup client */
     
    198200                               struct snd_seq_event_cell *cell)
    199201{
     202        unsigned long flags;
     203
    200204        if (cell) {
    201                 guard(spinlock_irqsave)(&f->lock);
     205                spin_lock_irqsave(&f->lock, flags);
    202206                cell->next = f->head;
    203207                f->head = cell;
     
    205209                        f->tail = cell;
    206210                f->cells++;
     211                spin_unlock_irqrestore(&f->lock, flags);
    207212        }
    208213}
     
    235240        }
    236241
    237         scoped_guard(spinlock_irq, &f->lock) {
     242        spin_lock_irq(&f->lock);
    238243        /* remember old pool */
    239244        oldpool = f->pool;
     
    245250        f->cells = 0;
    246251        /* NOTE: overflow flag is not cleared */
    247         }
     252        spin_unlock_irq(&f->lock);
    248253
    249254        /* close the old pool and wait until all users are gone */
     
    264269int snd_seq_fifo_unused_cells(struct snd_seq_fifo *f)
    265270{
     271        unsigned long flags;
    266272        int cells;
    267273
     
    270276
    271277        snd_use_lock_use(&f->use_lock);
    272         scoped_guard(spinlock_irqsave, &f->lock)
     278        spin_lock_irqsave(&f->lock, flags);
    273279        cells = snd_seq_unused_cells(f->pool);
     280        spin_unlock_irqrestore(&f->lock, flags);
    274281        snd_use_lock_free(&f->use_lock);
    275282        return cells;
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_memory.c

    r766 r767  
    233233void snd_seq_cell_free(struct snd_seq_event_cell * cell)
    234234{
     235        unsigned long flags;
    235236        struct snd_seq_pool *pool;
    236237
     
    241242                return;
    242243
    243         guard(spinlock_irqsave)(&pool->lock);
     244        spin_lock_irqsave(&pool->lock, flags);
    244245        free_cell(pool, cell);
    245246        if (snd_seq_ev_is_variable(&cell->event)) {
     
    259260                        wake_up(&pool->output_sleep);
    260261        }
     262        spin_unlock_irqrestore(&pool->lock, flags);
    261263}
    262264
     
    448450
    449451        /* add new cells to the free cell list */
    450         guard(spinlock_irq)(&pool->lock);
     452        spin_lock_irq(&pool->lock);
    451453        if (pool->ptr) {
     454                spin_unlock_irq(&pool->lock);
    452455                kvfree(cellptr);
    453456                return 0;
     
    468471        pool->max_used = 0;
    469472        pool->total_elements = pool->size;
     473        spin_unlock_irq(&pool->lock);
    470474        return 0;
    471475}
     
    474478void snd_seq_pool_mark_closing(struct snd_seq_pool *pool)
    475479{
     480        unsigned long flags;
     481
    476482        if (snd_BUG_ON(!pool))
    477483                return;
    478         guard(spinlock_irqsave)(&pool->lock);
     484        spin_lock_irqsave(&pool->lock, flags);
    479485        pool->closing = 1;
     486        spin_unlock_irqrestore(&pool->lock, flags);
    480487}
    481488
     
    498505       
    499506        /* release all resources */
    500         scoped_guard(spinlock_irq, &pool->lock) {
     507        spin_lock_irq(&pool->lock);
    501508        ptr = pool->ptr;
    502509        pool->ptr = NULL;
    503510        pool->free = NULL;
    504511        pool->total_elements = 0;
    505         }
     512        spin_unlock_irq(&pool->lock);
    506513
    507514        kvfree(ptr);
    508515
    509         guard(spinlock_irq)(&pool->lock);
     516        spin_lock_irq(&pool->lock);
    510517        pool->closing = 0;
     518        spin_unlock_irq(&pool->lock);
    511519
    512520        return 0;
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_midi.c

    r766 r767  
    307307                ports = 256 / SNDRV_RAWMIDI_DEVICES;
    308308
    309         guard(mutex)(&register_mutex);
     309        mutex_lock(&register_mutex);
    310310        client = synths[card->number];
    311311        if (client == NULL) {
    312312                newclient = 1;
    313313                client = kzalloc(sizeof(*client), GFP_KERNEL);
    314                 if (client == NULL)
     314                if (client == NULL) {
     315                        mutex_unlock(&register_mutex);
     316                        kfree(info);
    315317                        return -ENOMEM;
     318                }
    316319                client->seq_client =
    317320                        snd_seq_create_kernel_client(
     
    320323                if (client->seq_client < 0) {
    321324                        kfree(client);
     325                        mutex_unlock(&register_mutex);
     326                        kfree(info);
    322327                        return -ENOMEM;
    323328                }
     
    400405        if (newclient)
    401406                synths[card->number] = client;
     407        mutex_unlock(&register_mutex);
     408        kfree(info);
     409        kfree(port);
    402410        return 0;       /* success */
    403411
     
    412420                kfree(client);
    413421        }
     422        kfree(info);
     423        kfree(port);
     424        mutex_unlock(&register_mutex);
    414425        return -ENOMEM;
    415426}
     
    425436        int device = dev->device, p, ports;
    426437       
    427         guard(mutex)(&register_mutex);
     438        mutex_lock(&register_mutex);
    428439        client = synths[card->number];
    429         if (client == NULL || client->ports[device] == NULL)
     440        if (client == NULL || client->ports[device] == NULL) {
     441                mutex_unlock(&register_mutex);
    430442                return -ENODEV;
     443        }
    431444        ports = client->ports_per_device[device];
    432445        client->ports_per_device[device] = 0;
     
    442455                kfree(client);
    443456        }
     457        mutex_unlock(&register_mutex);
    444458        return 0;
    445459}
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_midi_event.c

    r766 r767  
    145145void snd_midi_event_reset_encode(struct snd_midi_event *dev)
    146146{
    147         guard(spinlock_irqsave)(&dev->lock);
     147        unsigned long flags;
     148
     149        spin_lock_irqsave(&dev->lock, flags);
    148150        reset_encode(dev);
     151        spin_unlock_irqrestore(&dev->lock, flags);
    149152}
    150153EXPORT_SYMBOL(snd_midi_event_reset_encode);
     
    152155void snd_midi_event_reset_decode(struct snd_midi_event *dev)
    153156{
    154         guard(spinlock_irqsave)(&dev->lock);
     157        unsigned long flags;
     158
     159        spin_lock_irqsave(&dev->lock, flags);
    155160        dev->lastcmd = 0xff;
     161        spin_unlock_irqrestore(&dev->lock, flags);
    156162}
    157163EXPORT_SYMBOL(snd_midi_event_reset_decode);
     
    172178{
    173179        bool rc = false;
     180        unsigned long flags;
    174181
    175182        if (c >= MIDI_CMD_COMMON_CLOCK) {
     
    181188        }
    182189
    183         guard(spinlock_irqsave)(&dev->lock);
     190        spin_lock_irqsave(&dev->lock, flags);
    184191        if ((c & 0x80) &&
    185192            (c != MIDI_CMD_COMMON_SYSEX_END || dev->type != ST_SYSEX)) {
     
    230237        }
    231238
     239        spin_unlock_irqrestore(&dev->lock, flags);
    232240        return rc;
    233241}
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_ports.c

    r766 r767  
    4949        if (client == NULL)
    5050                return NULL;
    51         guard(read_lock)(&client->ports_lock);
     51        read_lock(&client->ports_lock);
    5252        list_for_each_entry(port, &client->ports_list_head, list, struct snd_seq_client_port) {
    5353                if (port->addr.port == num) {
     
    5858                }
    5959        }
     60        read_unlock(&client->ports_lock);
    6061        return NULL;            /* not found */
    6162}
     
    7273        num = pinfo->addr.port;
    7374        found = NULL;
    74         guard(read_lock)(&client->ports_lock);
     75        read_lock(&client->ports_lock);
    7576        list_for_each_entry(port, &client->ports_list_head, list, struct snd_seq_client_port) {
    7677                if ((port->capability & SNDRV_SEQ_PORT_CAP_INACTIVE) &&
     
    9293                        snd_use_lock_use(&found->use_lock);
    9394        }
     95        read_unlock(&client->ports_lock);
    9496        return found;
    9597}
     
    143145
    144146        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);
    147149        list_for_each_entry(p, &client->ports_list_head, list, struct snd_seq_client_port) {
    148150                if (p->addr.port == port) {
    149151                        kfree(new_port);
    150                         return -EBUSY;
     152                        num = -EBUSY;
     153                        goto unlock;
    151154                }
    152155                if (p->addr.port > num)
     
    161164        sprintf(new_port->name, "port-%d", num);
    162165        *port_ret = new_port;
     166 unlock:
     167        write_unlock_irq(&client->ports_lock);
     168        mutex_unlock(&client->ports_mutex);
    163169
    164170        return num;
     
    275281        struct snd_seq_client_port *found = NULL, *p;
    276282
    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);
    279285        list_for_each_entry(p, &client->ports_list_head, list, struct snd_seq_client_port) {
    280286                if (p->addr.port == port) {
     
    286292                }
    287293        }
    288         }
     294        write_unlock_irq(&client->ports_lock);
     295        mutex_unlock(&client->ports_mutex);
    289296        if (found)
    290297                return port_delete(client, found);
     
    302309         * clear the port list in the client data.
    303310         */
    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);
    306313        if (! list_empty(&client->ports_list_head)) {
    307314                list_add(&deleted_list, &client->ports_list_head);
     
    311318        }
    312319        client->num_ports = 0;
    313         }
     320        write_unlock_irq(&client->ports_lock);
    314321
    315322        /* remove each port in deleted_list */
     
    319326                port_delete(client, port);
    320327        }
     328        mutex_unlock(&client->ports_mutex);
    321329        return 0;
    322330}
     
    503511
    504512        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);
    506515        if (exclusive) {
    507516                if (!list_empty(&grp->list_head))
    508                         return -EBUSY;
     517                        goto __error;
    509518        } else {
    510519                if (grp->exclusive)
    511                         return -EBUSY;
     520                        goto __error;
    512521                /* check whether already exists */
    513522                list_for_each(p, &grp->list_head) {
    514523                        s = get_subscriber(p, is_src);
    515524                        if (match_subs_info(&subs->info, &s->info))
    516                                 return -EBUSY;
     525                                goto __error;
    517526                }
    518527        }
     
    521530        if (err < 0) {
    522531                grp->exclusive = 0;
    523                 return err;
     532                goto __error;
    524533        }
    525534
    526535        /* add to list */
    527         guard(write_lock_irq)(&grp->list_lock);
     536        write_lock_irq(&grp->list_lock);
    528537        if (is_src)
    529538                list_add_tail(&subs->src_list, &grp->list_head);
     
    532541        grp->exclusive = exclusive;
    533542        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;
    536549}
    537550
     
    548561        grp = is_src ? &port->c_src : &port->c_dest;
    549562        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);
    551564        empty = list_empty(list);
    552565        if (!empty)
    553566                list_del_init(list);
    554567        grp->exclusive = 0;
    555         }
     568        write_unlock_irq(&grp->list_lock);
    556569
    557570        if (!empty)
     
    567580
    568581        grp = is_src ? &port->c_src : &port->c_dest;
    569         guard(rwsem_write)(&grp->list_mutex);
     582        down_write(&grp->list_mutex);
    570583        __delete_and_unsubscribe_port(client, port, subs, is_src, ack);
     584        up_write(&grp->list_mutex);
    571585}
    572586
     
    630644         * deletions
    631645         */
    632         scoped_guard(rwsem_write, &dest->list_mutex) {
     646        down_write(&dest->list_mutex);
    633647        /* look for the connection */
    634648        list_for_each_entry(subs, &dest->list_head, dest_list, struct snd_seq_subscribers) {
     
    639653                        err = 0;
    640654                        break;
    641                 }
    642         }
    643         }
     655                }
     656        }
     657        up_write(&dest->list_mutex);
    644658        if (err < 0)
    645659                return err;
     
    660674        int err = -ENOENT;
    661675
    662         guard(rwsem_read)(&src_grp->list_mutex);
     676        down_read(&src_grp->list_mutex);
    663677        list_for_each_entry(s, &src_grp->list_head, src_list, struct snd_seq_subscribers) {
    664678                if (addr_match(dest_addr, &s->info.dest)) {
     
    668682                }
    669683        }
     684        up_read(&src_grp->list_mutex);
    670685        return err;
    671686}
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/seq/seq_prioq.c

    r766 r767  
    133133{
    134134        struct snd_seq_event_cell *cur, *prev;
     135        unsigned long flags;
    135136        int count;
    136137        int prior;
     
    142143        prior = (cell->event.flags & SNDRV_SEQ_PRIORITY_MASK);
    143144
    144         guard(spinlock_irqsave)(&f->lock);
     145        spin_lock_irqsave(&f->lock, flags);
    145146
    146147        /* check if this element needs to inserted at the end (ie. ordered
     
    154155                        cell->next = NULL;
    155156                        f->cells++;
     157                        spin_unlock_irqrestore(&f->lock, flags);
    156158                        return 0;
    157159                }
     
    179181                if (! --count) {
    180182                        pr_err("ALSA: seq: cannot find a pointer.. infinite loop?\n");
     183                        spin_unlock_irqrestore(&f->lock, flags);
    181184                        return -EINVAL;
    182185                }
     
    193196                f->tail = cell;
    194197        f->cells++;
     198        spin_unlock_irqrestore(&f->lock, flags);
    195199        return 0;
    196200}
     
    210214{
    211215        struct snd_seq_event_cell *cell;
     216        unsigned long flags;
    212217
    213218        if (f == NULL) {
     
    215220                return NULL;
    216221        }
    217 
    218         guard(spinlock_irqsave)(&f->lock);
     222        spin_lock_irqsave(&f->lock, flags);
     223
    219224        cell = f->head;
    220225        if (cell && current_time && !event_is_ready(&cell->event, current_time))
     
    231236        }
    232237
     238        spin_unlock_irqrestore(&f->lock, flags);
    233239        return cell;
    234240}
     
    251257{
    252258        register struct snd_seq_event_cell *cell, *next;
     259        unsigned long flags;
    253260        struct snd_seq_event_cell *prev = NULL;
    254261        struct snd_seq_event_cell *freefirst = NULL, *freeprev = NULL, *freenext;
    255262
    256263        /* collect all removed cells */
    257         scoped_guard(spinlock_irqsave, &f->lock) {
    258                 for (cell = f->head; cell; cell = next) {
     264        spin_lock_irqsave(&f->lock, flags);
     265        for (cell = f->head; cell; cell = next) {
    259266                next = cell->next;
    260                         if (!match(cell, arg)) {
    261                                 prev = cell;
    262                                 continue;
    263                         }
     267                if (!match(cell, arg)) {
     268                        prev = cell;
     269                        continue;
     270                }
    264271
    265272                        /* remove cell from prioq */
    266                         if (cell == f->head)
    267                                 f->head = cell->next;
    268                         else
    269                                 prev->next = cell->next;
    270                         if (cell == f->tail)
    271                                 f->tail = cell->next;
    272                         f->cells--;
    273 
    274                         /* add cell to free list */
    275                         cell->next = NULL;
    276                         if (freefirst == NULL)
    277                                 freefirst = cell;
    278                         else
    279                                 freeprev->next = cell;
    280                         freeprev = cell;
    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);
    283290
    284291        /* remove selected cells */
     
    321328void snd_seq_prioq_leave(struct snd_seq_prioq *f, int client, int timestamp)
    322329{
    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);
    326335}
    327336
     
    395404                                 struct snd_seq_remove_events *info)
    396405{
    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  
    5151{
    5252        int i;
    53 
    54         guard(spinlock_irqsave)(&queue_list_lock);
     53        unsigned long flags;
     54 
     55        spin_lock_irqsave(&queue_list_lock, flags);
    5556        for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) {
    5657                if (! queue_list[i]) {
     
    5859                        q->queue = i;
    5960                        num_queues++;
     61                        spin_unlock_irqrestore(&queue_list_lock, flags);
    6062                        return i;
    6163                }
    6264        }
     65        spin_unlock_irqrestore(&queue_list_lock, flags);
    6366        return -1;
    6467}
     
    6770{
    6871        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);
    7175        q = queue_list[id];
    7276        if (q) {
    73                 guard(spinlock)(&q->owner_lock);
     77                spin_lock(&q->owner_lock);
    7478                if (q->owner == client) {
    7579                        /* found */
     80                        spin_unlock(&q->owner_lock);
    7681                        q->klocked = 1;
    7782                        queue_list[id] = NULL;
    7883                        num_queues--;
     84                        spin_unlock_irqrestore(&queue_list_lock, flags);
    7985                        return q;
    8086                }
    81         }
     87                spin_unlock(&q->owner_lock);
     88        }
     89        spin_unlock_irqrestore(&queue_list_lock, flags);
    8290        return NULL;
    8391}
     
    196204{
    197205        struct snd_seq_queue *q;
     206        unsigned long flags;
    198207
    199208        if (queueid < 0 || queueid >= SNDRV_SEQ_MAX_QUEUES)
    200209                return NULL;
    201         guard(spinlock_irqsave)(&queue_list_lock);
     210        spin_lock_irqsave(&queue_list_lock, flags);
    202211        q = queue_list[queueid];
    203212        if (q)
    204213                snd_use_lock_use(&q->use_lock);
     214        spin_unlock_irqrestore(&queue_list_lock, flags);
    205215        return q;
    206216}
     
    230240void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop)
    231241{
     242        unsigned long flags;
    232243        struct snd_seq_event_cell *cell;
    233244        snd_seq_tick_time_t cur_tick;
     
    239250
    240251        /* make this function non-reentrant */
    241         scoped_guard(spinlock_irqsave, &q->check_lock) {
     252        spin_lock_irqsave(&q->check_lock, flags);
    242253        if (q->check_blocked) {
    243254                q->check_again = 1;
     255                spin_unlock_irqrestore(&q->check_lock, flags);
    244256                return;         /* other thread is already checking queues */
    245257        }
    246258        q->check_blocked = 1;
    247         }
     259        spin_unlock_irqrestore(&q->check_lock, flags);
    248260
    249261      __again:
     
    272284 out:
    273285        /* free lock */
    274         scoped_guard(spinlock_irqsave, &q->check_lock) {
     286        spin_lock_irqsave(&q->check_lock, flags);
    275287        if (q->check_again) {
    276288                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);
    278291                        goto __again;
    279292                }
     293        }
    280294        q->check_blocked = 0;
    281         }
     295        spin_unlock_irqrestore(&q->check_lock, flags);
    282296}
    283297
     
    348362static int queue_access_lock(struct snd_seq_queue *q, int client)
    349363{
     364        unsigned long flags;
    350365        int access_ok;
    351366       
    352         guard(spinlock_irqsave)(&q->owner_lock);
     367        spin_lock_irqsave(&q->owner_lock, flags);
    353368        access_ok = check_access(q, client);
    354369        if (access_ok)
    355370                q->klocked = 1;
     371        spin_unlock_irqrestore(&q->owner_lock, flags);
    356372        return access_ok;
    357373}
     
    360376static inline void queue_access_unlock(struct snd_seq_queue *q)
    361377{
    362         guard(spinlock_irqsave)(&q->owner_lock);
     378        unsigned long flags;
     379
     380        spin_lock_irqsave(&q->owner_lock, flags);
    363381        q->klocked = 0;
     382        spin_unlock_irqrestore(&q->owner_lock, flags);
    364383}
    365384
     
    369388        struct snd_seq_queue *q = queueptr(queueid);
    370389        int access_ok;
     390        unsigned long flags;
    371391
    372392        if (! q)
    373393                return 0;
    374         scoped_guard(spinlock_irqsave, &q->owner_lock)
     394        spin_lock_irqsave(&q->owner_lock, flags);
    375395        access_ok = check_access(q, client);
     396        spin_unlock_irqrestore(&q->owner_lock, flags);
    376397        queuefree(q);
    377398        return access_ok;
     
    386407{
    387408        struct snd_seq_queue *q = queueptr(queueid);
     409        unsigned long flags;
    388410
    389411        if (q == NULL)
     
    395417        }
    396418
    397         scoped_guard(spinlock_irqsave, &q->owner_lock) {
     419        spin_lock_irqsave(&q->owner_lock, flags);
    398420        q->locked = locked ? 1 : 0;
    399421        q->owner = client;
    400         }
     422        spin_unlock_irqrestore(&q->owner_lock, flags);
    401423        queue_access_unlock(q);
    402424        queuefree(q);
     
    730752                        bpm = 0;
    731753
    732                 scoped_guard(spinlock_irq, &q->owner_lock) {
     754                spin_lock_irq(&q->owner_lock);
    733755                locked = q->locked;
    734756                owner = q->owner;
    735                 }
     757                spin_unlock_irq(&q->owner_lock);
    736758
    737759                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  
    7979void snd_seq_timer_defaults(struct snd_seq_timer * tmr)
    8080{
    81         guard(spinlock_irqsave)(&tmr->lock);
     81        unsigned long flags;
     82
     83        spin_lock_irqsave(&tmr->lock, flags);
    8284        /* setup defaults */
    8385        tmr->ppq = 96;          /* 96 PPQ */
     
    9698
    9799        tmr->skew = tmr->skew_base = SKEW_BASE;
     100        spin_unlock_irqrestore(&tmr->lock, flags);
    98101}
    99102
     
    110113void snd_seq_timer_reset(struct snd_seq_timer *tmr)
    111114{
    112         guard(spinlock_irqsave)(&tmr->lock);
     115        unsigned long flags;
     116
     117        spin_lock_irqsave(&tmr->lock, flags);
    113118        seq_timer_reset(tmr);
     119        spin_unlock_irqrestore(&tmr->lock, flags);
    114120}
    115121
     
    120126                                    unsigned long ticks)
    121127{
     128        unsigned long flags;
    122129        struct snd_seq_queue *q = timeri->callback_data;
    123130        struct snd_seq_timer *tmr;
     
    129136                return;
    130137
    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);
    133141                return;
     142        }
    134143
    135144        resolution *= ticks;
     
    139148                        (((resolution & 0xffff) * tmr->skew) >> 16);
    140149        }
    141 
     150 
    142151        /* update timer */
    143152        snd_seq_inc_time_nsec(&tmr->cur_time, resolution);
     
    148157        /* register actual time of this timer update */
    149158        ktime_get_ts64(&tmr->last_update);
    150         }
     159
     160        spin_unlock_irqrestore(&tmr->lock, flags);
    151161
    152162        /* check queues and dispatch events */
     
    157167int snd_seq_timer_set_tempo(struct snd_seq_timer * tmr, int tempo)
    158168{
     169        unsigned long flags;
     170
    159171        if (snd_BUG_ON(!tmr))
    160172                return -EINVAL;
    161173        if (tempo <= 0)
    162174                return -EINVAL;
    163         guard(spinlock_irqsave)(&tmr->lock);
     175        spin_lock_irqsave(&tmr->lock, flags);
    164176        if ((unsigned int)tempo != tmr->tempo) {
    165177                tmr->tempo = tempo;
    166178                snd_seq_timer_set_tick_resolution(tmr);
    167179        }
     180        spin_unlock_irqrestore(&tmr->lock, flags);
    168181        return 0;
    169182}
     
    174187{
    175188        int changed;
     189        unsigned long flags;
    176190
    177191        if (snd_BUG_ON(!tmr))
     
    182196        if (tempo_base && tempo_base != 10 && tempo_base != 1000)
    183197                return -EINVAL;
    184         guard(spinlock_irqsave)(&tmr->lock);
     198        spin_lock_irqsave(&tmr->lock, flags);
    185199        if (tmr->running && (ppq != tmr->ppq)) {
    186200                /* refuse to change ppq on running timers */
    187201                /* because it will upset the song position (ticks) */
     202                spin_unlock_irqrestore(&tmr->lock, flags);
    188203                pr_debug("ALSA: seq: cannot change ppq of a running timer\n");
    189204                return -EBUSY;
     
    195210        if (changed)
    196211                snd_seq_timer_set_tick_resolution(tmr);
     212        spin_unlock_irqrestore(&tmr->lock, flags);
    197213        return 0;
    198214}
     
    202218                                    snd_seq_tick_time_t position)
    203219{
    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);
    208226        tmr->tick.cur_tick = position;
    209227        tmr->tick.fraction = 0;
     228        spin_unlock_irqrestore(&tmr->lock, flags);
    210229        return 0;
    211230}
     
    215234                                    snd_seq_real_time_t position)
    216235{
     236        unsigned long flags;
     237
    217238        if (snd_BUG_ON(!tmr))
    218239                return -EINVAL;
    219240
    220241        snd_seq_sanity_real_time(&position);
    221         guard(spinlock_irqsave)(&tmr->lock);
     242        spin_lock_irqsave(&tmr->lock, flags);
    222243        tmr->cur_time = position;
     244        spin_unlock_irqrestore(&tmr->lock, flags);
    223245        return 0;
    224246}
     
    228250                           unsigned int base)
    229251{
     252        unsigned long flags;
     253
    230254        if (snd_BUG_ON(!tmr))
    231255                return -EINVAL;
     
    236260                return -EINVAL;
    237261        }
    238         guard(spinlock_irqsave)(&tmr->lock);
     262        spin_lock_irqsave(&tmr->lock, flags);
    239263        tmr->skew = skew;
     264        spin_unlock_irqrestore(&tmr->lock, flags);
    240265        return 0;
    241266}
     
    282307                return err;
    283308        }
    284         scoped_guard(spinlock_irq, &tmr->lock) {
     309        spin_lock_irq(&tmr->lock);
    285310        if (tmr->timeri)
    286311                err = -EBUSY;
    287312        else
    288313                tmr->timeri = t;
    289         }
     314        spin_unlock_irq(&tmr->lock);
    290315        if (err < 0) {
    291316                snd_timer_close(t);
     
    304329        if (snd_BUG_ON(!tmr))
    305330                return -EINVAL;
    306         scoped_guard(spinlock_irq, &tmr->lock) {
     331        spin_lock_irq(&tmr->lock);
    307332        t = tmr->timeri;
    308333        tmr->timeri = NULL;
    309         }
     334        spin_unlock_irq(&tmr->lock);
    310335        if (t) {
    311336                snd_timer_close(t);
     
    328353int snd_seq_timer_stop(struct snd_seq_timer *tmr)
    329354{
    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;
    332362}
    333363
     
    379409int snd_seq_timer_start(struct snd_seq_timer *tmr)
    380410{
    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;
    383418}
    384419
     
    402437int snd_seq_timer_continue(struct snd_seq_timer *tmr)
    403438{
    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;
    406446}
    407447
     
    411451{
    412452        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);
    415456        cur_time = tmr->cur_time;
    416457        if (adjust_ktime && tmr->running) {
     
    424465        }
    425466
     467        spin_unlock_irqrestore(&tmr->lock, flags);
    426468        return cur_time;       
    427469}
     
    431473snd_seq_tick_time_t snd_seq_timer_get_cur_tick(struct snd_seq_timer *tmr)
    432474{
    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;
    435482}
    436483
     
    451498                if (q == NULL)
    452499                        continue;
    453                 scoped_guard(mutex, &q->timer_mutex) {
     500                mutex_lock(&q->timer_mutex);
    454501                tmr = q->timer;
    455502                if (!tmr)
    456                                 break;
     503                        goto unlock;
    457504                ti = tmr->timeri;
    458505                if (!ti)
    459                                 break;
     506                        goto unlock;
    460507                snd_iprintf(buffer, "Timer for queue %i : %s\n", q->queue, ti->timer->name);
    461508                resolution = snd_timer_resolution(ti) * tmr->ticks;
    462509                snd_iprintf(buffer, "  Period time : %lu.%09lu\n", resolution / 1000000000, resolution % 1000000000);
    463510                snd_iprintf(buffer, "  Skew : %u / %u\n", tmr->skew, tmr->skew_base);
    464                 }
     511unlock:
     512                mutex_unlock(&q->timer_mutex);
    465513                queuefree(q);
    466514        }
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/sound.c

    r766 r767  
    103103        if (minor >= ARRAY_SIZE(snd_minors))
    104104                return NULL;
    105         guard(mutex)(&sound_mutex);
     105        mutex_lock(&sound_mutex);
    106106        mreg = snd_minors[minor];
    107107        if (mreg && mreg->type == type) {
     
    111111        } else
    112112                private_data = NULL;
     113        mutex_unlock(&sound_mutex);
    113114        return private_data;
    114115}
     
    149150        if (minor >= ARRAY_SIZE(snd_minors))
    150151                return -ENODEV;
    151         scoped_guard(mutex, &sound_mutex) {
     152        mutex_lock(&sound_mutex);
    152153        mptr = snd_minors[minor];
    153154        if (mptr == NULL) {
    154155                mptr = autoload_device(minor);
    155                         if (!mptr)
     156                if (!mptr) {
     157                        mutex_unlock(&sound_mutex);
    156158                        return -ENODEV;
    157159                }
    158160#ifndef TARGET_OS2 //code below from 3.13 crashes, using 3.8 code for now
    159161        new_fops = fops_get(mptr->f_ops);
     162        mutex_unlock(&sound_mutex);
    160163        }
    161164        if (!new_fops)
     
    168171#else
    169172        new_fops = file->f_op;
     173        mutex_unlock(&sound_mutex);
    170174        }
    171175        file->f_op = fops_get(mptr->f_ops);
     
    291295        preg->private_data = private_data;
    292296        preg->card_ptr = card;
    293         guard(mutex)(&sound_mutex);
     297        mutex_lock(&sound_mutex);
    294298        minor = snd_find_free_minor(type, card, dev);
    295299        if (minor < 0) {
     
    306310        snd_minors[minor] = preg;
    307311 error:
     312        mutex_unlock(&sound_mutex);
    308313        if (err < 0)
    309314                kfree(preg);
     
    326331        struct snd_minor *preg;
    327332
    328         guard(mutex)(&sound_mutex);
     333        mutex_lock(&sound_mutex);
    329334        for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) {
    330335                preg = snd_minors[minor];
     
    336341                }
    337342        }
     343        mutex_unlock(&sound_mutex);
    338344        if (minor >= ARRAY_SIZE(snd_minors))
    339345                return -ENOENT;
     
    375381        struct snd_minor *mptr;
    376382
    377         guard(mutex)(&sound_mutex);
     383        mutex_lock(&sound_mutex);
    378384        for (minor = 0; minor < SNDRV_OS_MINORS; ++minor) {
    379385                mptr = snd_minors[minor];
     
    393399                                    snd_device_type_name(mptr->type));
    394400        }
     401        mutex_unlock(&sound_mutex);
    395402}
    396403
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/sound_oss.c

    r766 r767  
    3434        if (minor >= ARRAY_SIZE(snd_oss_minors))
    3535                return NULL;
    36         guard(mutex)(&sound_oss_mutex);
     36        mutex_lock(&sound_oss_mutex);
    3737        mreg = snd_oss_minors[minor];
    3838        if (mreg && mreg->type == type) {
     
    4242        } else
    4343                private_data = NULL;
     44        mutex_unlock(&sound_oss_mutex);
    4445        return private_data;
    4546}
     
    110111        preg->private_data = private_data;
    111112        preg->card_ptr = card;
    112         guard(mutex)(&sound_oss_mutex);
     113        mutex_lock(&sound_oss_mutex);
    113114        snd_oss_minors[minor] = preg;
    114115        minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
     
    136137        }
    137138#endif
     139        mutex_unlock(&sound_oss_mutex);
    138140        return 0;
    139141
     
    145147                unregister_sound_special(register1);
    146148        snd_oss_minors[minor] = NULL;
     149        mutex_unlock(&sound_oss_mutex);
    147150        kfree(preg);
    148151        return -EBUSY;
     
    162165        if (minor < 0)
    163166                return minor;
    164         guard(mutex)(&sound_oss_mutex);
     167        mutex_lock(&sound_oss_mutex);
    165168        mptr = snd_oss_minors[minor];
    166         if (mptr == NULL)
     169        if (mptr == NULL) {
     170                mutex_unlock(&sound_oss_mutex);
    167171                return -ENOENT;
     172        }
    168173        switch (SNDRV_MINOR_OSS_DEVICE(minor)) {
    169174        case SNDRV_MINOR_OSS_PCM:
     
    180185                snd_oss_minors[track2] = NULL;
    181186        snd_oss_minors[minor] = NULL;
     187        mutex_unlock(&sound_oss_mutex);
    182188
    183189        /* call unregister_sound_special() outside sound_oss_mutex;
     
    223229        struct snd_minor *mptr;
    224230
    225         guard(mutex)(&sound_oss_mutex);
     231        mutex_lock(&sound_oss_mutex);
    226232        for (minor = 0; minor < SNDRV_OSS_MINORS; ++minor) {
    227233                mptr = snd_oss_minors[minor];
     
    236242                                    snd_oss_device_type_name(mptr->type));
    237243        }
     244        mutex_unlock(&sound_oss_mutex);
    238245}
    239246
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/core/timer.c

    r766 r767  
    1414#include <linux/string.h>
    1515#include <linux/sched/signal.h>
     16#ifndef TARGET_OS2
    1617#include <linux/anon_inodes.h>
    1718#include <linux/idr.h>
     19#endif
    1820#include <sound/core.h>
    1921#include <sound/timer.h>
     
    238240        list_move_tail(&slave->open_list, &master->slave_list_head);
    239241        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);
    242244        slave->master = master;
    243245        slave->timer = master->timer;
    244246        if (slave->flags & SNDRV_TIMER_IFLG_RUNNING)
    245247                list_add_tail(&slave->active_list, &master->slave_active_head);
     248        spin_unlock(&master->timer->lock);
     249        spin_unlock_irq(&slave_active_lock);
    246250        return 1;
    247251}
     
    400404        struct snd_timer_instance *slave, *tmp;
    401405
    402         guard(spinlock_irq)(&slave_active_lock);
    403         guard(spinlock)(&timer->lock);
     406        spin_lock_irq(&slave_active_lock);
     407        spin_lock(&timer->lock);
    404408        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) {
    406410                list_move_tail(&slave->open_list, &snd_timer_slave_list);
    407411                timer->num_instances--;
     
    411415                list_del_init(&slave->active_list);
    412416        }
     417        spin_unlock_irq(&slave_active_lock);
     418        spin_unlock(&timer->lock);
    413419}
    414420
     
    421427{
    422428        struct snd_timer *timer = timeri->timer;
     429        struct snd_timer_instance *slave, *tmp;
    423430
    424431        if (timer) {
    425                 guard(spinlock_irq)(&timer->lock);
     432                spin_lock_irq(&timer->lock);
    426433                timeri->flags |= SNDRV_TIMER_IFLG_DEAD;
     434                spin_unlock_irq(&timer->lock);
    427435        }
    428436
     
    449457                remove_slave_links(timeri, timer);
    450458
     459                /* slave doesn't need to release timer resources below */
     460                if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE)
     461                        timer = NULL;
     462        }
     463
    451464        if (timer) {
    452465                if (list_empty(&timer->open_list_head) && timer->hw.close)
     
    469482                return;
    470483
    471         scoped_guard(mutex, &register_mutex)
     484        mutex_lock(&register_mutex);
    472485        snd_timer_close_locked(timeri, &card_dev_to_put);
     486        mutex_unlock(&register_mutex);
    473487        /* put_device() is called after unlock for avoiding deadlock */
    474488        if (card_dev_to_put)
     
    489503        struct snd_timer * timer;
    490504        unsigned long ret = 0;
     505        unsigned long flags;
    491506
    492507        if (timeri == NULL)
     
    494509        timer = timeri->timer;
    495510        if (timer) {
    496                 guard(spinlock_irqsave)(&timer->lock);
     511                spin_lock_irqsave(&timer->lock, flags);
    497512                ret = snd_timer_hw_resolution(timer);
     513                spin_unlock_irqrestore(&timer->lock, flags);
    498514        }
    499515        return ret;
     
    539555        struct snd_timer *timer;
    540556        int result;
     557        unsigned long flags;
    541558
    542559        timer = timeri->timer;
    543560        if (!timer)
    544561                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        }
    551571        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        }
    554576
    555577        /* check the actual time for the start tick;
     
    557579         */
    558580        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                }
    561585        }
    562586
     
    585609        snd_timer_notify1(timeri, start ? SNDRV_TIMER_EVENT_START :
    586610                          SNDRV_TIMER_EVENT_CONTINUE);
     611 unlock:
     612        spin_unlock_irqrestore(&timer->lock, flags);
    587613        return result;
    588614}
     
    592618                                 bool start)
    593619{
    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        }
    599632        timeri->flags |= SNDRV_TIMER_IFLG_RUNNING;
    600633        if (timeri->master && timeri->timer) {
    601                 guard(spinlock)(&timeri->timer->lock);
     634                spin_lock(&timeri->timer->lock);
    602635                list_add_tail(&timeri->active_list,
    603636                              &timeri->master->slave_active_head);
    604637                snd_timer_notify1(timeri, start ? SNDRV_TIMER_EVENT_START :
    605638                                  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;
    608645}
    609646
     
    612649{
    613650        struct snd_timer *timer;
     651        int result = 0;
     652        unsigned long flags;
    614653
    615654        timer = timeri->timer;
    616655        if (!timer)
    617656                return -EINVAL;
    618         guard(spinlock_irqsave)(&timer->lock);
     657        spin_lock_irqsave(&timer->lock, flags);
    619658        list_del_init(&timeri->ack_list);
    620659        list_del_init(&timeri->active_list);
    621660        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        }
    624665        if (timer->card && timer->card->shutdown)
    625                 return 0;
     666                goto unlock;
    626667        if (stop) {
    627668                timeri->cticks = timeri->ticks;
     
    647688        snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP :
    648689                          SNDRV_TIMER_EVENT_PAUSE);
    649         return 0;
     690 unlock:
     691        spin_unlock_irqrestore(&timer->lock, flags);
     692        return result;
    650693}
    651694
     
    653696static int snd_timer_stop_slave(struct snd_timer_instance *timeri, bool stop)
    654697{
     698        unsigned long flags;
    655699        bool running;
    656700
    657         guard(spinlock_irqsave)(&slave_active_lock);
     701        spin_lock_irqsave(&slave_active_lock, flags);
    658702        running = timeri->flags & SNDRV_TIMER_IFLG_RUNNING;
    659703        timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
    660704        if (timeri->timer) {
    661                 guard(spinlock)(&timeri->timer->lock);
     705                spin_lock(&timeri->timer->lock);
    662706                list_del_init(&timeri->ack_list);
    663707                list_del_init(&timeri->active_list);
     
    665709                        snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP :
    666710                                          SNDRV_TIMER_EVENT_PAUSE);
    667         }
     711                spin_unlock(&timeri->timer->lock);
     712        }
     713        spin_unlock_irqrestore(&slave_active_lock, flags);
    668714        return running ? 0 : -EBUSY;
    669715}
     
    790836                                      struct list_head *head)
    791837{
    792         guard(spinlock_irqsave)(&timer->lock);
     838        unsigned long flags;
     839
     840        spin_lock_irqsave(&timer->lock, flags);
    793841        while (!list_empty(head))
    794842                list_del_init(head->next);
     843        spin_unlock_irqrestore(&timer->lock, flags);
    795844}
    796845
     
    806855{
    807856        struct snd_timer *timer = container_of(work, struct snd_timer, task_work);
     857        unsigned long flags;
    808858
    809859        if (timer->card && timer->card->shutdown) {
     
    812862        }
    813863
    814         guard(spinlock_irqsave)(&timer->lock);
     864        spin_lock_irqsave(&timer->lock, flags);
    815865        snd_timer_process_callbacks(timer, &timer->sack_list_head);
     866        spin_unlock_irqrestore(&timer->lock, flags);
    816867}
    817868
     
    827878        unsigned long resolution;
    828879        struct list_head *ack_list_head;
     880        unsigned long flags;
     881        bool use_work = false;
    829882
    830883        if (timer == NULL)
     
    836889        }
    837890
    838         guard(spinlock_irqsave)(&timer->lock);
     891        spin_lock_irqsave(&timer->lock, flags);
    839892
    840893        /* remember the current resolution */
     
    902955
    903956        /* do we have any slow callbacks? */
     957        use_work = !list_empty(&timer->sack_list_head);
     958        spin_unlock_irqrestore(&timer->lock, flags);
     959
    904960#ifndef TARGET_OS2
    905         if (!list_empty(&timer->sack_list_head))
     961        if (use_work)
    906962                queue_work(system_highpri_wq, &timer->task_work);
    907963#endif
     
    9701026                return 0;
    9711027
    972         guard(mutex)(&register_mutex);
     1028        mutex_lock(&register_mutex);
    9731029        if (! list_empty(&timer->open_list_head)) {
    9741030                struct list_head *p, *n;
     
    9821038        }
    9831039        list_del(&timer->device_list);
     1040        mutex_unlock(&register_mutex);
    9841041
    9851042        if (timer->private_free)
     
    10061063                return -EINVAL;
    10071064
    1008         guard(mutex)(&register_mutex);
     1065        mutex_lock(&register_mutex);
    10091066        list_for_each_entry(timer1, &snd_timer_list, device_list, struct snd_timer) {
    10101067                if (timer1->tmr_class > timer->tmr_class)
     
    10271084                        continue;
    10281085                /* conflicts.. */
     1086                mutex_unlock(&register_mutex);
    10291087                return -EBUSY;
    10301088        }
    10311089        list_add_tail(&timer->device_list, &timer1->device_list);
     1090        mutex_unlock(&register_mutex);
    10321091        return 0;
    10331092}
     
    10381097        struct snd_timer_instance *ti;
    10391098
    1040         guard(mutex)(&register_mutex);
     1099        mutex_lock(&register_mutex);
    10411100        list_del_init(&timer->device_list);
    10421101        /* wake up pending sleepers */
     
    10451104                        ti->disconnect(ti);
    10461105        }
     1106        mutex_unlock(&register_mutex);
    10471107        return 0;
    10481108}
     
    10501110void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp)
    10511111{
     1112        unsigned long flags;
    10521113        unsigned long resolution = 0;
    10531114        struct snd_timer_instance *ti, *ts;
     
    10601121                       event > SNDRV_TIMER_EVENT_MRESUME))
    10611122                return;
    1062         guard(spinlock_irqsave)(&timer->lock);
     1123        spin_lock_irqsave(&timer->lock, flags);
    10631124        if (event == SNDRV_TIMER_EVENT_MSTART ||
    10641125            event == SNDRV_TIMER_EVENT_MCONTINUE ||
     
    10721133                                ts->ccallback(ts, event, tstamp, resolution);
    10731134        }
     1135        spin_unlock_irqrestore(&timer->lock, flags);
    10741136}
    10751137EXPORT_SYMBOL(snd_timer_notify);
     
    12331295        unsigned long resolution;
    12341296
    1235         guard(mutex)(&register_mutex);
     1297        mutex_lock(&register_mutex);
    12361298        list_for_each_entry(timer, &snd_timer_list, device_list, struct snd_timer) {
    12371299                if (timer->card && timer->card->shutdown)
     
    12551317                }
    12561318                snd_iprintf(buffer, "%s :", timer->name);
    1257                 scoped_guard(spinlock_irq, &timer->lock)
     1319                spin_lock_irq(&timer->lock);
    12581320                resolution = snd_timer_hw_resolution(timer);
     1321                spin_unlock_irq(&timer->lock);
    12591322                if (resolution)
    12601323                        snd_iprintf(buffer, " %lu.%03luus (%lu ticks)",
     
    12721335                                    ? "running" : "stopped");
    12731336        }
     1337        mutex_unlock(&register_mutex);
    12741338}
    12751339
     
    13121376        int prev;
    13131377
    1314         guard(spinlock)(&tu->qlock);
     1378        spin_lock(&tu->qlock);
    13151379        if (tu->qused > 0) {
    13161380                prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1;
     
    13311395        }
    13321396      __wake:
     1397        spin_unlock(&tu->qlock);
    13331398        snd_kill_fasync(tu->fasync, SIGIO, POLL_IN);
    13341399        wake_up(&tu->qchange_sleep);
     
    13541419        struct snd_timer_user *tu = timeri->callback_data;
    13551420        struct snd_timer_tread64 r1;
     1421        unsigned long flags;
    13561422
    13571423        if (event >= SNDRV_TIMER_EVENT_START &&
     
    13651431        r1.tstamp_nsec = tstamp->tv_nsec;
    13661432        r1.val = resolution;
    1367         scoped_guard(spinlock_irqsave, &tu->qlock)
     1433        spin_lock_irqsave(&tu->qlock, flags);
    13681434        snd_timer_user_append_to_tqueue(tu, &r1);
     1435        spin_unlock_irqrestore(&tu->qlock, flags);
    13691436        snd_kill_fasync(tu->fasync, SIGIO, POLL_IN);
    13701437        wake_up(&tu->qchange_sleep);
     
    13901457        memset(&r1, 0, sizeof(r1));
    13911458        memset(&tstamp, 0, sizeof(tstamp));
    1392         scoped_guard(spinlock, &tu->qlock) {
     1459        spin_lock(&tu->qlock);
    13931460        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);
    13951463                return;
     1464        }
    13961465        if (tu->last_resolution != resolution || ticks > 0) {
    13971466                if (timer_tstamp_monotonic)
     
    14061475                r1.tstamp_nsec = tstamp.tv_nsec;
    14071476                r1.val = resolution;
    1408                 snd_timer_user_append_to_tqueue(tu, &r1);
     1477                snd_timer_user_append_to_tqueue(tu, &r1);
    14091478                tu->last_resolution = resolution;
    1410                 append++;
    1411         }
     1479                append++;
     1480        }
    14121481        if ((tu->filter & (1 << SNDRV_TIMER_EVENT_TICK)) == 0)
    1413                         break;
     1482                goto __wake;
    14141483        if (ticks == 0)
    1415                         break;
     1484                goto __wake;
    14161485        if (tu->qused > 0) {
    14171486                prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1;
     
    14221491                        r->val += ticks;
    14231492                        append++;
    1424                                 break;
     1493                        goto __wake;
    14251494                }
    14261495        }
     
    14311500        snd_timer_user_append_to_tqueue(tu, &r1);
    14321501        append++;
    1433         }
     1502      __wake:
     1503        spin_unlock(&tu->qlock);
    14341504        if (append == 0)
    14351505                return;
     
    14531523        }
    14541524
    1455         guard(spinlock_irq)(&tu->qlock);
     1525        spin_lock_irq(&tu->qlock);
    14561526        kfree(tu->queue);
    14571527        kfree(tu->tqueue);
     
    14601530        tu->tqueue = tqueue;
    14611531        tu->qhead = tu->qtail = tu->qused = 0;
     1532        spin_unlock_irq(&tu->qlock);
    14621533
    14631534        return 0;
     
    14951566                tu = file->private_data;
    14961567                file->private_data = NULL;
    1497                 scoped_guard(mutex, &tu->ioctl_lock) {
     1568                mutex_lock(&tu->ioctl_lock);
    14981569                if (tu->timeri) {
    14991570                        snd_timer_close(tu->timeri);
    15001571                        snd_timer_instance_free(tu->timeri);
    15011572                }
    1502                 }
     1573                mutex_unlock(&tu->ioctl_lock);
    15031574                snd_fasync_free(tu->fasync);
    15041575                kfree(tu->queue);
     
    15351606        if (copy_from_user(&id, _tid, sizeof(id)))
    15361607                return -EFAULT;
    1537         guard(mutex)(&register_mutex);
     1608        mutex_lock(&register_mutex);
    15381609        if (id.dev_class < 0) {         /* first item */
    15391610                if (list_empty(&snd_timer_list))
     
    16121683                }
    16131684        }
     1685        mutex_unlock(&register_mutex);
    16141686        if (copy_to_user(_tid, &id, sizeof(*_tid)))
    16151687                return -EFAULT;
     
    16241696        struct snd_timer *t;
    16251697        struct list_head *p;
     1698        int err = 0;
    16261699
    16271700        ginfo = memdup_user(_ginfo, sizeof(*ginfo));
     
    16321705        memset(ginfo, 0, sizeof(*ginfo));
    16331706        ginfo->tid = tid;
    1634         guard(mutex)(&register_mutex);
     1707        mutex_lock(&register_mutex);
    16351708        t = snd_timer_find(&tid);
    1636         if (!t)
    1637                 return -ENODEV;
     1709        if (t != NULL) {
    16381710                ginfo->card = t->card ? t->card->number : -1;
    16391711                if (t->hw.flags & SNDRV_TIMER_HW_SLAVE)
     
    16411713                strscpy(ginfo->id, t->id, sizeof(ginfo->id));
    16421714                strscpy(ginfo->name, t->name, sizeof(ginfo->name));
    1643         scoped_guard(spinlock_irq, &t->lock)
     1715                spin_lock_irq(&t->lock);
    16441716                ginfo->resolution = snd_timer_hw_resolution(t);
     1717                spin_unlock_irq(&t->lock);
    16451718                if (t->hw.resolution_min > 0) {
    16461719                        ginfo->resolution_min = t->hw.resolution_min;
     
    16501723                        ginfo->clients++;
    16511724                }
    1652         if (copy_to_user(_ginfo, ginfo, sizeof(*ginfo)))
    1653                 return -EFAULT;
    1654         return 0;
     1725        } else {
     1726                err = -ENODEV;
     1727                }
     1728        mutex_unlock(&register_mutex);
     1729        if (err >= 0 && copy_to_user(_ginfo, ginfo, sizeof(*ginfo)))
     1730                err = -EFAULT;
     1731        kfree(ginfo);
     1732        return err;
    16551733}
    16561734
     
    16581736{
    16591737        struct snd_timer *t;
    1660 
    1661         guard(mutex)(&register_mutex);
     1738        int err;
     1739
     1740        mutex_lock(&register_mutex);
    16621741        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(&register_mutex);
     1757        return err;
    16701758}
    16711759
     
    16931781        memset(&gstatus, 0, sizeof(gstatus));
    16941782        gstatus.tid = tid;
    1695         guard(mutex)(&register_mutex);
     1783        mutex_lock(&register_mutex);
    16961784        t = snd_timer_find(&tid);
    16971785        if (t != NULL) {
    1698                 guard(spinlock_irq)(&t->lock);
     1786                spin_lock_irq(&t->lock);
    16991787                gstatus.resolution = snd_timer_hw_resolution(t);
    17001788                if (t->hw.precise_resolution) {
     
    17051793                        gstatus.resolution_den = 1000000000uL;
    17061794                }
     1795                spin_unlock_irq(&t->lock);
    17071796        } else {
    17081797                err = -ENODEV;
    17091798        }
     1799        mutex_unlock(&register_mutex);
    17101800        if (err >= 0 && copy_to_user(_gstatus, &gstatus, sizeof(gstatus)))
    17111801                err = -EFAULT;
     
    17631853        struct snd_timer_info *info __free(kfree) = NULL;
    17641854        struct snd_timer *t;
     1855        int err = 0;
    17651856
    17661857        tu = file->private_data;
     
    17791870        strscpy(info->id, t->id, sizeof(info->id));
    17801871        strscpy(info->name, t->name, sizeof(info->name));
    1781         scoped_guard(spinlock_irq, &t->lock)
     1872        spin_lock_irq(&t->lock);
    17821873        info->resolution = snd_timer_hw_resolution(t);
     1874        spin_unlock_irq(&t->lock);
    17831875        if (copy_to_user(_info, info, sizeof(*_info)))
    1784                 return -EFAULT;
    1785         return 0;
     1876                err = -EFAULT;
     1877        kfree(info);
     1878        return err;
    17861879}
    17871880
     
    18411934        }
    18421935        snd_timer_stop(tu->timeri);
    1843         scoped_guard(spinlock_irq, &t->lock) {
     1936        spin_lock_irq(&t->lock);
    18441937        tu->timeri->flags &= ~(SNDRV_TIMER_IFLG_AUTO|
    18451938                               SNDRV_TIMER_IFLG_EXCLUSIVE|
     
    18511944        if (params.flags & SNDRV_TIMER_PSFLG_EARLY_EVENT)
    18521945                tu->timeri->flags |= SNDRV_TIMER_IFLG_EARLY_EVENT;
    1853         }
     1946        spin_unlock_irq(&t->lock);
    18541947        if (params.queue_size > 0 &&
    18551948            (unsigned int)tu->queue_size != params.queue_size) {
     
    18581951                        goto _end;
    18591952        }
    1860         scoped_guard(spinlock_irq, &tu->qlock) {
     1953        spin_lock_irq(&tu->qlock);
    18611954        tu->qhead = tu->qtail = tu->qused = 0;
    18621955        if (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) {
    18631956                if (tu->tread) {
    18641957                        struct snd_timer_tread64 tread;
    1865 
    18661958                        memset(&tread, 0, sizeof(tread));
    18671959                        tread.event = SNDRV_TIMER_EVENT_EARLY;
     
    18721964                } else {
    18731965                        struct snd_timer_read *r = &tu->queue[0];
    1874 
    18751966                        r->resolution = 0;
    18761967                        r->ticks = 0;
     
    18811972        tu->filter = params.filter;
    18821973        tu->ticks = params.ticks;
    1883         }
     1974        spin_unlock_irq(&tu->qlock);
    18841975        err = 0;
    18851976 _end:
     
    19041995        status.lost = tu->timeri->lost;
    19051996        status.overrun = tu->overrun;
    1906         scoped_guard(spinlock_irq, &tu->qlock)
     1997        spin_lock_irq(&tu->qlock);
    19071998        status.queue = tu->qused;
     1999        spin_unlock_irq(&tu->qlock);
    19082000        if (copy_to_user(_status, &status, sizeof(status)))
    19092001                return -EFAULT;
     
    19262018        status.lost = tu->timeri->lost;
    19272019        status.overrun = tu->overrun;
    1928         scoped_guard(spinlock_irq, &tu->qlock)
     2020        spin_lock_irq(&tu->qlock);
    19292021        status.queue = tu->qused;
     2022        spin_unlock_irq(&tu->qlock);
    19302023        if (copy_to_user(_status, &status, sizeof(status)))
    19312024                return -EFAULT;
     
    22982391{
    22992392        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;
    23032399}
    23042400
     
    24352531
    24362532        mask = 0;
    2437         guard(spinlock_irq)(&tu->qlock);
     2533        spin_lock_irq(&tu->qlock);
    24382534        if (tu->qused)
    24392535                mask |= EPOLLIN | EPOLLRDNORM;
    24402536        if (tu->disconnected)
    24412537                mask |= EPOLLERR;
     2538        spin_unlock_irq(&tu->qlock);
    24422539
    24432540        return mask;
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/hda/hdac_stream.c

    r766 r767  
    333333        snd_hdac_stream_updatel(azx_dev, SD_CTL, 0, SD_INT_MASK);
    334334
     335#ifdef TARGET_OS2
     336        azx_dev->fifo_size = snd_hdac_stream_readw(azx_dev, SD_FIFOSIZE) + 1;
     337#else
    335338        if (!code_loading) {
    336339                /* Once SDxFMT is set, the controller programs SDxFIFOS to non-zero value. */
     
    342345                azx_dev->fifo_size = reg;
    343346        }
    344 
     347#endif
    345348        /* when LPIB delay correction gives a small negative value,
    346349         * we ignore it; currently set the threshold statically to
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/include/sound/control.h

    r766 r767  
    8282        void *private_data;
    8383        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 */
    8585};
    8686
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/include/sound/hdaudio.h

    r766 r767  
    1919#include <sound/memalloc.h>
    2020#include <sound/hda_verbs.h>
     21#ifndef TARGET_OS2
    2122#include <drm/intel/i915_component.h>
     23#endif
    2224
    2325/* codec node id */
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/include/sound/pcm.h

    r766 r767  
    684684        } while (0)
    685685
     686#ifndef TARGET_OS2
    686687/* definitions for guard(); use like guard(pcm_stream_lock) */
    687688DEFINE_LOCK_GUARD_1(pcm_stream_lock, struct snd_pcm_substream,
     
    695696                    snd_pcm_stream_unlock_irqrestore(_T->lock, _T->flags),
    696697                    unsigned long flags)
     698#endif
    697699
    698700/**
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/include/uapi/sound/asound.h

    r766 r767  
    363363        unsigned short id16[8];
    364364        unsigned int id32[4];
    365 } __attribute__((deprecated));
     365} /*__attribute__((deprecated))*/;
    366366
    367367struct snd_pcm_info {
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/pci/ac97/ac97_codec.c

    r762 r767  
    30283028                result = apply_quirk_str(ac97, override);
    30293029                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);
    30313032                return result;
    30323033        }
     
    30423043                        if (quirk->codec_id && quirk->codec_id != ac97->id)
    30433044                                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);
    30453048                        result = apply_quirk(ac97, quirk->type);
    30463049                        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);
    30483053                        return result;
    30493054                }
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/Makefile

    r708 r767  
    1212#
    1313#===================================================================
    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
     14FILES = 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
    1820
    1921TARGET = hda
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/hda_component2.h

    r763 r767  
    77 */
    88
     9#ifndef __HDA_COMPONENT_H__
     10#define __HDA_COMPONENT_H__
     11
     12#include <linux/acpi.h>
    913#include <linux/component.h>
     14#include <linux/mutex.h>
     15#include <sound/hda_codec.h>
    1016
    1117#define HDA_MAX_COMPONENTS      4
     
    1521        struct device *dev;
    1622        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);
    1826        void (*pre_playback_hook)(struct device *dev, int action);
    1927        void (*playback_hook)(struct device *dev, int action);
    2028        void (*post_playback_hook)(struct device *dev, int action);
    2129};
     30
     31struct 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
     38void hda_component_acpi_device_notify(struct hda_component_parent *parent,
     39                                      acpi_handle handle, u32 event, void *data);
     40int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc,
     41                                                  struct hda_component_parent *parent,
     42                                                  acpi_notify_handler handler, void *data);
     43void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc,
     44                                                     struct hda_component_parent *parent,
     45                                                     acpi_notify_handler handler);
     46#else
     47static 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
     54static 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
     63static 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
     70void hda_component_manager_playback_hook(struct hda_component_parent *parent, int action);
     71
     72int 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
     78void hda_component_manager_free(struct hda_component_parent *parent,
     79                                const struct component_master_ops *ops);
     80
     81int hda_component_manager_bind(struct hda_codec *cdc, struct hda_component_parent *parent);
     82
     83static 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
     95static 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  
    6767        {0x43, CM9825_VERB_SET_CDALR, 0xf6},    /* Class D */
    6868        {0x43, CM9825_VERB_SET_OTP, 0xcd},      /* OTP set */
    69         {}
     69        {0}
    7070};
    7171
     
    9595        {0x43, CM9825_VERB_SET_HPF_1, 0x40},    /* HPF set */
    9696        {0x43, CM9825_VERB_SET_HPF_2, 0x40},    /* HPF set */
    97         {}
     97        {0}
    9898};
    9999
     
    106106        {0x43, CM9825_VERB_SET_DACTRL, 0x00},   /* DACTRL set */
    107107        {0x43, CM9825_VERB_SET_VDO, 0xc4},      /* VDO set */
    108         {}
     108        {0}
    109109};
    110110
     
    117117        {0x43, CM9825_VERB_SET_VDO, 0x80},      /* VDO set */
    118118        {0x42, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},   /* PIN on */
    119         {}
     119        {0}
    120120};
    121121
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/patch_realtek.c

    r766 r767  
    1919#include <linux/dmi.h>
    2020#include <linux/module.h>
    21 #include <linux/i2c.h>
     21//#include <linux/i2c.h>
    2222#include <linux/input.h>
    2323#include <linux/leds.h>
    2424#include <linux/ctype.h>
    25 #include <linux/spi/spi.h>
     25//#include <linux/spi/spi.h>
    2626#include <sound/core.h>
    2727#include <sound/jack.h>
     
    31103110                        { 0x18, PIN_VREF50 }, /* rear mic */
    31113111                        { 0x19, PIN_VREF50 }, /* front mic */
    3112                         {}
     3112                        {0}
    31133113                }
    31143114        },
     
    35353535                .v.pins = (const struct hda_pintbl[]) {
    35363536                        { 0x18, PIN_VREF100 }, /* headset mic */
    3537                         {}
     3537                        {0}
    35383538                }
    35393539        },
     
    56985698}
    56995699
     5700#ifdef NOT_USED
    57005701static void gpio2_mic_hotkey_event(struct hda_codec *codec,
    57015702                                   struct hda_jack_callback *event)
     
    57445745        return 0;
    57455746}
     5747#endif
    57465748
    57475749/* GPIO1 = set according to SKU external amp
     
    78107812        int i, count = 0, count_devindex = 0;
    78117813
     7814#ifndef TARGET_OS2
    78127815        for (i = 0; i < ARRAY_SIZE(acpi_ids); ++i) {
    78137816                adev = acpi_dev_get_first_match_dev(acpi_ids[i].hid, NULL, -1);
     
    78157818                break;
    78167819        }
     7820
    78177821        if (!adev) {
    78187822                codec_dbg(cdc, "Did not find ACPI entry for a Cirrus Amp\n");
     
    78517855        if (count_devindex > 0)
    78527856                count = count_devindex;
    7853 
     7857#endif
    78547858        match = devm_kasprintf(dev, GFP_KERNEL, "-%%s:00-%s.%%d", acpi_ids[i].name);
    78557859        if (!match)
     
    78857889}
    78867890
     7891#ifdef NOT_USED
    78877892static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const struct hda_fixup *fix,
    78887893                                                 int action)
     
    78907895        comp_generic_fixup(cdc, action, "i2c", "CLSA0101", "-%s:00-cs35l41-hda.%d", 2);
    78917896}
     7897#endif
    78927898
    78937899static void alc285_fixup_asus_ga403u(struct hda_codec *cdc, const struct hda_fixup *fix, int action)
     
    81578163                { 0x14, 0x90170110 }, // top/treble
    81588164                { 0x17, 0x90170111 }, // bottom/bass
    8159                 { }
     8165                {0}
    81608166        };
    81618167
     
    81738179
    81748180        cs35l41_fixup_i2c_two(codec, fix, action);
     8181#ifdef NOT_USED
    81758182        alc245_fixup_hp_mute_led_coefbit(codec, fix, action);
    81768183        alc245_fixup_hp_gpio_led(codec, fix, action);
     8184#endif
    81778185}
    81788186
     
    81918199                { 0x14, 0x90170110 }, // top/treble
    81928200                { 0x17, 0x90170111 }, // bottom/bass
    8193                 { }
     8201                {0}
    81948202        };
    81958203
     
    82168224
    82178225        cs35l41_fixup_i2c_two(codec, fix, action);
     8226#ifdef NOT_USED
    82188227        alc245_fixup_hp_mute_led_coefbit(codec, fix, action);
    82198228        alc245_fixup_hp_gpio_led(codec, fix, action);
     8229#endif
    82208230}
    82218231
     
    82408250static void alc287_s4_power_gpio3_default(struct hda_codec *codec)
    82418251{
     8252#ifndef TARGET_OS2
    82428253        if (is_s4_suspend(codec)) {
    82438254                alc_write_coefex_idx(codec, 0x5a, 0x00, 0x554f); /* write gpio3 as default value */
    82448255        }
     8256#endif
    82458257}
    82468258
     
    1064210654                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x6b },
    1064310655                        { 0x20, AC_VERB_SET_PROC_COEF, 0x5060 },
    10644                         {}
     10656                        {0}
    1064510657                },
    1064610658                .chained = true,
     
    1072110733                        { 0x1e, 0x411111f0 },
    1072210734                        { 0x21, 0x03211020 },
    10723                         {}
     10735                        {0}
    1072410736                },
    1072510737                .chained = true,
     
    1081810830                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
    1081910831                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
    10820                          {}
     10832                         {0}
    1082110833                },
    1082210834                .chained = true,
     
    1086510877                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
    1086610878                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
    10867                          {}
     10879                         {0}
    1086810880                },
    1086910881                .chained = true,
     
    1089110903                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
    1089210904                        { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
    10893                         {}
     10905                        {0}
    1089410906                },
    1089510907                .chained = true,
     
    1115711169                .v.func = alc285_fixup_asus_ga403u,
    1115811170        },
     11171#ifdef NOT_USED
    1115911172        [ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC] = {
    1116011173                .type = HDA_FIXUP_PINS,
     
    1116711180                .chain_id = ALC285_FIXUP_ASUS_GA403U_I2C_SPEAKER2_TO_DAC1
    1116811181        },
     11182#endif
    1116911183        [ALC285_FIXUP_ASUS_GU605_SPI_SPEAKER2_TO_DAC1] = {
    1117011184                .type = HDA_FIXUP_FUNC,
     
    1117311187                .chain_id = ALC285_FIXUP_ASUS_GU605_SPI_2_HEADSET_MIC,
    1117411188        },
     11189#ifdef NOT_USED
    1117511190        [ALC285_FIXUP_ASUS_GU605_SPI_2_HEADSET_MIC] = {
    1117611191                .type = HDA_FIXUP_PINS,
     
    1118111196                },
    1118211197        },
     11198#endif
    1118311199        [ALC285_FIXUP_ASUS_GA403U_I2C_SPEAKER2_TO_DAC1] = {
    1118411200                .type = HDA_FIXUP_FUNC,
     
    1120511221                .chain_id = ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
    1120611222        },
     11223#ifdef NOT_USED
    1120711224        [ALC269_FIXUP_VAIO_VJFH52_MIC_NO_PRESENCE] = {
    1120811225                .type = HDA_FIXUP_PINS,
     
    1122211239                },
    1122311240        },
     11241#endif
    1122411242};
    1122511243
     
    1419714215                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x15 },
    1419814216                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0d60 },
    14199                         {}
     14217                        {0}
    1420014218                },
    1420114219        },
     
    1421914237                .v.pins = (const struct hda_pintbl[]) {
    1422014238                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
    14221                         { }
     14239                        {0}
    1422214240                },
    1422314241        },
     
    1424114259                .v.verbs = (const struct hda_verb[]) {
    1424214260                        { 0x14, AC_VERB_SET_EAPD_BTLENABLE, 0 },
    14243                         {}
     14261                        {0}
    1424414262                },
    1424514263        },
  • TabularUnified GPL/branches/uniaud32-exp/alsa-kernel/pci/maestro3.c

    r766 r767  
    25902590        card->sync_irq = chip->irq;
    25912591
     2592#ifndef TARGET_OS2
    25922593        if (IS_ENABLED(CONFIG_PM_SLEEP)) {
    25932594        chip->suspend_mem =
     
    25982599                dev_warn(card->dev, "can't allocate apm buffer\n");
    25992600        }
    2600 
     2601#endif
    26012602        err = snd_m3_mixer(chip);
    26022603        if (err < 0)
  • TabularUnified GPL/branches/uniaud32-exp/include/linux/compiler.h

    r665 r767  
    1616
    1717#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__)
    1827
    1928#ifndef __ASSEMBLY__
  • TabularUnified GPL/branches/uniaud32-exp/include/linux/device.h

    r764 r767  
    5858  struct device   * parent;
    5959  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 */
    6161  struct kobject kobj;
    6262  const char            *init_name; /* initial name of the device */
  • TabularUnified GPL/branches/uniaud32-exp/include/linux/export.h

    r647 r767  
    66#define EXPORT_SYMBOL(a)
    77#define EXPORT_SYMBOL_GPL(a)
     8#define EXPORT_SYMBOL_NS_GPL(a)
    89
    910#endif /* _LINUX_EXPORT_H */
  • TabularUnified GPL/branches/uniaud32-exp/include/linux/kernel.h

    r763 r767  
    128128
    129129_WCRTLINK extern int    sscanf( const char *__s, const char *__format, ... );
    130 
     130typedef void *acpi_handle;      /* Actually a ptr to a NS Node */
     131typedef
     132void (*acpi_notify_handler) (acpi_handle device, u32 value, void *context);
    131133#endif
  • TabularUnified GPL/branches/uniaud32-exp/include/linux/module.h

    r647 r767  
    116116        char name[MODULE_NAME_LEN];
    117117};
     118#define MODULE_IMPORT_NS(x)
    118119#endif /* _LINUX_MODULE_H */
  • TabularUnified GPL/branches/uniaud32-exp/include/linux/pci_ids.h

    r763 r767  
    584584#define PCI_DEVICE_ID_AMD_1AH_M70H_DF_F3 0x12bb
    585585#define PCI_DEVICE_ID_AMD_MI200_DF_F3   0x14d3
     586#define PCI_DEVICE_ID_AMD_MI300_DF_F3   0x152b
    586587#define PCI_DEVICE_ID_AMD_VANGOGH_USB   0x163a
    587588#define PCI_DEVICE_ID_AMD_CNB17H_F3     0x1703
     
    25892590#define PCI_VENDOR_ID_REDHAT            0x1b36
    25902591
     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
    25912597#define PCI_VENDOR_ID_SILICOM_DENMARK   0x1c2c
    25922598
     
    26022608#define PCI_VENDOR_ID_HYGON             0x1d94
    26032609
     2610#define PCI_VENDOR_ID_META              0x1d9b
     2611
    26042612#define PCI_VENDOR_ID_FUNGIBLE          0x1dad
    26052613
     
    26082616#define PCI_VENDOR_ID_TEKRAM            0x1de1
    26092617#define PCI_DEVICE_ID_TEKRAM_DC290      0xdc29
     2618
     2619#define PCI_VENDOR_ID_ALIBABA           0x1ded
     2620
     2621#define PCI_VENDOR_ID_CXL               0x1e98
    26102622
    26112623#define PCI_VENDOR_ID_TEHUTI            0x1fc9
     
    26362648#define PCI_VENDOR_ID_AKS               0x416c
    26372649#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
    26382656
    26392657#define PCI_VENDOR_ID_ACCESSIO          0x494f
     
    27032721#define PCI_DEVICE_ID_INTEL_82815_CGC   0x1132
    27042722#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
    27052726#define PCI_DEVICE_ID_INTEL_82092AA_0   0x1221
    27062727#define PCI_DEVICE_ID_INTEL_82437       0x122d
     
    31123133#define PCI_DEVICE_ID_INTEL_HDA_LNL_P   0xa828
    31133134#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
    31143138#define PCI_DEVICE_ID_INTEL_HDA_CML_R   0xf0c8
    31153139#define PCI_DEVICE_ID_INTEL_HDA_RKL_S   0xf1c8
  • TabularUnified GPL/branches/uniaud32-exp/include/linux/pm.h

    r763 r767  
    291291        .restore = resume_fn,
    292292
     293#define SYSTEM_SLEEP_PM_OPS SET_SYSTEM_SLEEP_PM_OPS
    293294/*
    294295 * Use this if you want to use the same suspend and resume callbacks for suspend
     
    349350#define PMSG_RESTORE    0
    350351#define pm_sleep_ptr(_ptr) _ptr
     352
     353#define pm_ptr(_ptr) _ptr
     354
    351355#endif /* _LINUX_PM_H */
  • TabularUnified GPL/branches/uniaud32-exp/lib32/Makefile

    r764 r767  
    3131  instropl2.obj instropl3.obj vsprintf.obj bitmap.obj find_next_bit.obj &
    3232  regmap.obj regcache.obj regcache-flat.obj regcache-rbtree.obj &
    33   regcache-maple.obj component.obj
     33  component.obj
    3434
    3535TARGET = linuxlib
  • TabularUnified GPL/branches/uniaud32-exp/lib32/regcache.c

    r764 r767  
    2424static const struct regcache_ops *cache_types[] = {
    2525        &regcache_rbtree_ops,
     26#if 0 // not (yet?) supported on OS/2
    2627        &regcache_maple_ops,
     28#endif
    2729        &regcache_flat_ops,
    2830};
  • TabularUnified GPL/branches/uniaud32-exp/lib32/regmap.c

    r724 r767  
    2020#include <linux/log2.h>
    2121//#include <linux/hwspinlock.h>
    22 #include <asm/unaligned.h>
     22#include <linux/unaligned.h>
    2323#include <linux/module.h>
    2424#include <linux/workqueue.h>
  • TabularUnified GPL/branches/uniaud32-exp/uniaud.inc

    r645 r767  
    1313# ex RC3  GA  FIXPACK2 beta_47
    1414# Comment out to avoid a fixpack line in bldlevel
    15 FIXPACK = SVN
     15FIXPACK = SVN r764
Note: See TracChangeset for help on using the changeset viewer.