aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2011-03-07 07:24:30 -0500
committerTakashi Iwai <tiwai@suse.de>2011-03-08 07:00:09 -0500
commit0e82e5fa97614c9ca3efca5f8dca69dffd1c0ec0 (patch)
tree697955215071627ca3209ec51cde532b53a5973d /sound
parent7c7335877105364f7f5181e80ff34206b54be81f (diff)
ALSA: control: clean up snd_ctl_hole_check()
The return value of snd_ctl_hole_check() is used only to detect whether to continue the loop in snd_ctl_find_hole() or not, so we can simplify the code by changing this return type to a boolean. Also rename this function to better show what it actually does. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-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}