aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/control.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2006-10-05 10:02:22 -0400
committerJaroslav Kysela <perex@suse.cz>2007-02-09 03:00:10 -0500
commit9244b2c3079faac79b3b961116bd548c45087e2c (patch)
tree1a9e2ead054ed58efcad3fd43fb2aedeb6731baa /sound/core/control.c
parentd595ee7e0162ae66faa8c4c7d8c2069b40d64fed (diff)
[ALSA] alsa core: convert to list_for_each_entry*
This patch converts most uses of list_for_each to list_for_each_entry all across alsa. In some place apparently an item can be on a list with different pointers so of course that isn't compatible with list_for_each, I therefore didn't touch those places. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/core/control.c')
-rw-r--r--sound/core/control.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/sound/core/control.c b/sound/core/control.c
index 0c7bcd62e5b2..67f09b8f85e4 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -108,7 +108,6 @@ static void snd_ctl_empty_read_queue(struct snd_ctl_file * ctl)
108static int snd_ctl_release(struct inode *inode, struct file *file) 108static int snd_ctl_release(struct inode *inode, struct file *file)
109{ 109{
110 unsigned long flags; 110 unsigned long flags;
111 struct list_head *list;
112 struct snd_card *card; 111 struct snd_card *card;
113 struct snd_ctl_file *ctl; 112 struct snd_ctl_file *ctl;
114 struct snd_kcontrol *control; 113 struct snd_kcontrol *control;
@@ -122,12 +121,10 @@ static int snd_ctl_release(struct inode *inode, struct file *file)
122 list_del(&ctl->list); 121 list_del(&ctl->list);
123 write_unlock_irqrestore(&card->ctl_files_rwlock, flags); 122 write_unlock_irqrestore(&card->ctl_files_rwlock, flags);
124 down_write(&card->controls_rwsem); 123 down_write(&card->controls_rwsem);
125 list_for_each(list, &card->controls) { 124 list_for_each_entry(control, &card->controls, list)
126 control = snd_kcontrol(list);
127 for (idx = 0; idx < control->count; idx++) 125 for (idx = 0; idx < control->count; idx++)
128 if (control->vd[idx].owner == ctl) 126 if (control->vd[idx].owner == ctl)
129 control->vd[idx].owner = NULL; 127 control->vd[idx].owner = NULL;
130 }
131 up_write(&card->controls_rwsem); 128 up_write(&card->controls_rwsem);
132 snd_ctl_empty_read_queue(ctl); 129 snd_ctl_empty_read_queue(ctl);
133 kfree(ctl); 130 kfree(ctl);
@@ -140,7 +137,6 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask,
140 struct snd_ctl_elem_id *id) 137 struct snd_ctl_elem_id *id)
141{ 138{
142 unsigned long flags; 139 unsigned long flags;
143 struct list_head *flist;
144 struct snd_ctl_file *ctl; 140 struct snd_ctl_file *ctl;
145 struct snd_kctl_event *ev; 141 struct snd_kctl_event *ev;
146 142
@@ -149,14 +145,11 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask,
149#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) 145#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
150 card->mixer_oss_change_count++; 146 card->mixer_oss_change_count++;
151#endif 147#endif
152 list_for_each(flist, &card->ctl_files) { 148 list_for_each_entry(ctl, &card->ctl_files, list) {
153 struct list_head *elist;
154 ctl = snd_ctl_file(flist);
155 if (!ctl->subscribed) 149 if (!ctl->subscribed)
156 continue; 150 continue;
157 spin_lock_irqsave(&ctl->read_lock, flags); 151 spin_lock_irqsave(&ctl->read_lock, flags);
158 list_for_each(elist, &ctl->events) { 152 list_for_each_entry(ev, &ctl->events, list) {
159 ev = snd_kctl_event(elist);
160 if (ev->id.numid == id->numid) { 153 if (ev->id.numid == id->numid) {
161 ev->mask |= mask; 154 ev->mask |= mask;
162 goto _found; 155 goto _found;
@@ -277,11 +270,9 @@ EXPORT_SYMBOL(snd_ctl_free_one);
277static unsigned int snd_ctl_hole_check(struct snd_card *card, 270static unsigned int snd_ctl_hole_check(struct snd_card *card,
278 unsigned int count) 271 unsigned int count)
279{ 272{
280 struct list_head *list;
281 struct snd_kcontrol *kctl; 273 struct snd_kcontrol *kctl;
282 274
283 list_for_each(list, &card->controls) { 275 list_for_each_entry(kctl, &card->controls, list) {
284 kctl = snd_kcontrol(list);
285 if ((kctl->id.numid <= card->last_numid && 276 if ((kctl->id.numid <= card->last_numid &&
286 kctl->id.numid + kctl->count > card->last_numid) || 277 kctl->id.numid + kctl->count > card->last_numid) ||
287 (kctl->id.numid <= card->last_numid + count - 1 && 278 (kctl->id.numid <= card->last_numid + count - 1 &&
@@ -498,12 +489,10 @@ EXPORT_SYMBOL(snd_ctl_rename_id);
498 */ 489 */
499struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid) 490struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid)
500{ 491{
501 struct list_head *list;
502 struct snd_kcontrol *kctl; 492 struct snd_kcontrol *kctl;
503 493
504 snd_assert(card != NULL && numid != 0, return NULL); 494 snd_assert(card != NULL && numid != 0, return NULL);
505 list_for_each(list, &card->controls) { 495 list_for_each_entry(kctl, &card->controls, list) {
506 kctl = snd_kcontrol(list);
507 if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid) 496 if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid)
508 return kctl; 497 return kctl;
509 } 498 }
@@ -527,14 +516,12 @@ EXPORT_SYMBOL(snd_ctl_find_numid);
527struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card, 516struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card,
528 struct snd_ctl_elem_id *id) 517 struct snd_ctl_elem_id *id)
529{ 518{
530 struct list_head *list;
531 struct snd_kcontrol *kctl; 519 struct snd_kcontrol *kctl;
532 520
533 snd_assert(card != NULL && id != NULL, return NULL); 521 snd_assert(card != NULL && id != NULL, return NULL);
534 if (id->numid != 0) 522 if (id->numid != 0)
535 return snd_ctl_find_numid(card, id->numid); 523 return snd_ctl_find_numid(card, id->numid);
536 list_for_each(list, &card->controls) { 524 list_for_each_entry(kctl, &card->controls, list) {
537 kctl = snd_kcontrol(list);
538 if (kctl->id.iface != id->iface) 525 if (kctl->id.iface != id->iface)
539 continue; 526 continue;
540 if (kctl->id.device != id->device) 527 if (kctl->id.device != id->device)
@@ -1182,7 +1169,6 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg
1182{ 1169{
1183 struct snd_ctl_file *ctl; 1170 struct snd_ctl_file *ctl;
1184 struct snd_card *card; 1171 struct snd_card *card;
1185 struct list_head *list;
1186 struct snd_kctl_ioctl *p; 1172 struct snd_kctl_ioctl *p;
1187 void __user *argp = (void __user *)arg; 1173 void __user *argp = (void __user *)arg;
1188 int __user *ip = argp; 1174 int __user *ip = argp;
@@ -1232,8 +1218,7 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg
1232#endif 1218#endif
1233 } 1219 }
1234 down_read(&snd_ioctl_rwsem); 1220 down_read(&snd_ioctl_rwsem);
1235 list_for_each(list, &snd_control_ioctls) { 1221 list_for_each_entry(p, &snd_control_ioctls, list) {
1236 p = list_entry(list, struct snd_kctl_ioctl, list);
1237 err = p->fioctl(card, ctl, cmd, arg); 1222 err = p->fioctl(card, ctl, cmd, arg);
1238 if (err != -ENOIOCTLCMD) { 1223 if (err != -ENOIOCTLCMD) {
1239 up_read(&snd_ioctl_rwsem); 1224 up_read(&snd_ioctl_rwsem);
@@ -1357,13 +1342,11 @@ EXPORT_SYMBOL(snd_ctl_register_ioctl_compat);
1357static int _snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn, 1342static int _snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn,
1358 struct list_head *lists) 1343 struct list_head *lists)
1359{ 1344{
1360 struct list_head *list;
1361 struct snd_kctl_ioctl *p; 1345 struct snd_kctl_ioctl *p;
1362 1346
1363 snd_assert(fcn != NULL, return -EINVAL); 1347 snd_assert(fcn != NULL, return -EINVAL);
1364 down_write(&snd_ioctl_rwsem); 1348 down_write(&snd_ioctl_rwsem);
1365 list_for_each(list, lists) { 1349 list_for_each_entry(p, lists, list) {
1366 p = list_entry(list, struct snd_kctl_ioctl, list);
1367 if (p->fioctl == fcn) { 1350 if (p->fioctl == fcn) {
1368 list_del(&p->list); 1351 list_del(&p->list);
1369 up_write(&snd_ioctl_rwsem); 1352 up_write(&snd_ioctl_rwsem);
@@ -1453,7 +1436,6 @@ static int snd_ctl_dev_register(struct snd_device *device)
1453static int snd_ctl_dev_disconnect(struct snd_device *device) 1436static int snd_ctl_dev_disconnect(struct snd_device *device)
1454{ 1437{
1455 struct snd_card *card = device->device_data; 1438 struct snd_card *card = device->device_data;
1456 struct list_head *flist;
1457 struct snd_ctl_file *ctl; 1439 struct snd_ctl_file *ctl;
1458 int err, cardnum; 1440 int err, cardnum;
1459 1441
@@ -1462,8 +1444,7 @@ static int snd_ctl_dev_disconnect(struct snd_device *device)
1462 snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); 1444 snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
1463 1445
1464 down_read(&card->controls_rwsem); 1446 down_read(&card->controls_rwsem);
1465 list_for_each(flist, &card->ctl_files) { 1447 list_for_each_entry(ctl, &card->ctl_files, list) {
1466 ctl = snd_ctl_file(flist);
1467 wake_up(&ctl->change_sleep); 1448 wake_up(&ctl->change_sleep);
1468 kill_fasync(&ctl->fasync, SIGIO, POLL_ERR); 1449 kill_fasync(&ctl->fasync, SIGIO, POLL_ERR);
1469 } 1450 }