aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/control.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/control.c')
-rw-r--r--sound/core/control.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/sound/core/control.c b/sound/core/control.c
index d1b5ce818a4f..dc4afa6f99b1 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -279,31 +279,31 @@ void snd_ctl_free_one(struct snd_kcontrol *kcontrol)
279 279
280EXPORT_SYMBOL(snd_ctl_free_one); 280EXPORT_SYMBOL(snd_ctl_free_one);
281 281
282static unsigned int snd_ctl_hole_check(struct snd_card *card, 282static bool snd_ctl_remove_numid_conflict(struct snd_card *card,
283 unsigned int count) 283 unsigned int count)
284{ 284{
285 struct snd_kcontrol *kctl; 285 struct snd_kcontrol *kctl;
286 286
287 list_for_each_entry(kctl, &card->controls, list) { 287 list_for_each_entry(kctl, &card->controls, list) {
288 if (kctl->id.numid < card->last_numid + 1 + count && 288 if (kctl->id.numid < card->last_numid + 1 + count &&
289 kctl->id.numid + kctl->count > card->last_numid + 1) 289 kctl->id.numid + kctl->count > card->last_numid + 1) {
290 return card->last_numid = kctl->id.numid + kctl->count - 1; 290 card->last_numid = kctl->id.numid + kctl->count - 1;
291 return true;
292 }
291 } 293 }
292 return card->last_numid; 294 return false;
293} 295}
294 296
295static int snd_ctl_find_hole(struct snd_card *card, unsigned int count) 297static int snd_ctl_find_hole(struct snd_card *card, unsigned int count)
296{ 298{
297 unsigned int last_numid, iter = 100000; 299 unsigned int iter = 100000;
298 300
299 last_numid = card->last_numid; 301 while (snd_ctl_remove_numid_conflict(card, count)) {
300 while (last_numid != snd_ctl_hole_check(card, count)) {
301 if (--iter == 0) { 302 if (--iter == 0) {
302 /* this situation is very unlikely */ 303 /* this situation is very unlikely */
303 snd_printk(KERN_ERR "unable to allocate new control numid\n"); 304 snd_printk(KERN_ERR "unable to allocate new control numid\n");
304 return -ENOMEM; 305 return -ENOMEM;
305 } 306 }
306 last_numid = card->last_numid;
307 } 307 }
308 return 0; 308 return 0;
309} 309}