diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-03-18 07:39:08 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-03-18 07:39:08 +0100 |
commit | d351cf4603edb2a5bfa9a48d06c425511c63f2a3 (patch) | |
tree | b03ea3cfd3ca3974237563cf87328386c3d49ff1 /sound/core/control.c | |
parent | 433e8327caf9f7c0432b2f2f6684a5b79cfe18e9 (diff) | |
parent | 4a122c10fbfe9020df469f0f669da129c5757671 (diff) | |
download | lwn-d351cf4603edb2a5bfa9a48d06c425511c63f2a3.tar.gz lwn-d351cf4603edb2a5bfa9a48d06c425511c63f2a3.zip |
Merge branch 'topic/misc' into for-linus
Diffstat (limited to 'sound/core/control.c')
-rw-r--r-- | sound/core/control.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/sound/core/control.c b/sound/core/control.c index db51e4e64984..a08ad57c49b6 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -279,33 +279,31 @@ void snd_ctl_free_one(struct snd_kcontrol *kcontrol) EXPORT_SYMBOL(snd_ctl_free_one); -static unsigned int snd_ctl_hole_check(struct snd_card *card, - unsigned int count) +static bool snd_ctl_remove_numid_conflict(struct snd_card *card, + unsigned int count) { struct snd_kcontrol *kctl; list_for_each_entry(kctl, &card->controls, list) { - if ((kctl->id.numid <= card->last_numid && - kctl->id.numid + kctl->count > card->last_numid) || - (kctl->id.numid <= card->last_numid + count - 1 && - kctl->id.numid + kctl->count > card->last_numid + count - 1)) - return card->last_numid = kctl->id.numid + kctl->count - 1; + if (kctl->id.numid < card->last_numid + 1 + count && + kctl->id.numid + kctl->count > card->last_numid + 1) { + card->last_numid = kctl->id.numid + kctl->count - 1; + return true; + } } - return card->last_numid; + return false; } static int snd_ctl_find_hole(struct snd_card *card, unsigned int count) { - unsigned int last_numid, iter = 100000; + unsigned int iter = 100000; - last_numid = card->last_numid; - while (last_numid != snd_ctl_hole_check(card, count)) { + while (snd_ctl_remove_numid_conflict(card, count)) { if (--iter == 0) { /* this situation is very unlikely */ snd_printk(KERN_ERR "unable to allocate new control numid\n"); return -ENOMEM; } - last_numid = card->last_numid; } return 0; } |