aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/seq
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/seq
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/seq')
-rw-r--r--sound/core/seq/seq_clientmgr.c14
-rw-r--r--sound/core/seq/seq_device.c25
-rw-r--r--sound/core/seq/seq_ports.c49
-rw-r--r--sound/core/seq/seq_virmidi.c4
4 files changed, 33 insertions, 59 deletions
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 532a660df51d..bb9dd9fa8e51 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -659,7 +659,6 @@ static int deliver_to_subscribers(struct snd_seq_client *client,
659 int err = 0, num_ev = 0; 659 int err = 0, num_ev = 0;
660 struct snd_seq_event event_saved; 660 struct snd_seq_event event_saved;
661 struct snd_seq_client_port *src_port; 661 struct snd_seq_client_port *src_port;
662 struct list_head *p;
663 struct snd_seq_port_subs_info *grp; 662 struct snd_seq_port_subs_info *grp;
664 663
665 src_port = snd_seq_port_use_ptr(client, event->source.port); 664 src_port = snd_seq_port_use_ptr(client, event->source.port);
@@ -674,8 +673,7 @@ static int deliver_to_subscribers(struct snd_seq_client *client,
674 read_lock(&grp->list_lock); 673 read_lock(&grp->list_lock);
675 else 674 else
676 down_read(&grp->list_mutex); 675 down_read(&grp->list_mutex);
677 list_for_each(p, &grp->list_head) { 676 list_for_each_entry(subs, &grp->list_head, src_list) {
678 subs = list_entry(p, struct snd_seq_subscribers, src_list);
679 event->dest = subs->info.dest; 677 event->dest = subs->info.dest;
680 if (subs->info.flags & SNDRV_SEQ_PORT_SUBS_TIMESTAMP) 678 if (subs->info.flags & SNDRV_SEQ_PORT_SUBS_TIMESTAMP)
681 /* convert time according to flag with subscription */ 679 /* convert time according to flag with subscription */
@@ -709,15 +707,14 @@ static int port_broadcast_event(struct snd_seq_client *client,
709{ 707{
710 int num_ev = 0, err = 0; 708 int num_ev = 0, err = 0;
711 struct snd_seq_client *dest_client; 709 struct snd_seq_client *dest_client;
712 struct list_head *p; 710 struct snd_seq_client_port *port;
713 711
714 dest_client = get_event_dest_client(event, SNDRV_SEQ_FILTER_BROADCAST); 712 dest_client = get_event_dest_client(event, SNDRV_SEQ_FILTER_BROADCAST);
715 if (dest_client == NULL) 713 if (dest_client == NULL)
716 return 0; /* no matching destination */ 714 return 0; /* no matching destination */
717 715
718 read_lock(&dest_client->ports_lock); 716 read_lock(&dest_client->ports_lock);
719 list_for_each(p, &dest_client->ports_list_head) { 717 list_for_each_entry(port, &dest_client->ports_list_head, list) {
720 struct snd_seq_client_port *port = list_entry(p, struct snd_seq_client_port, list);
721 event->dest.port = port->addr.port; 718 event->dest.port = port->addr.port;
722 /* pass NULL as source client to avoid error bounce */ 719 /* pass NULL as source client to avoid error bounce */
723 err = snd_seq_deliver_single_event(NULL, event, 720 err = snd_seq_deliver_single_event(NULL, event,
@@ -2473,11 +2470,10 @@ static void snd_seq_info_dump_subscribers(struct snd_info_buffer *buffer,
2473static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer, 2470static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer,
2474 struct snd_seq_client *client) 2471 struct snd_seq_client *client)
2475{ 2472{
2476 struct list_head *l; 2473 struct snd_seq_client_port *p;
2477 2474
2478 mutex_lock(&client->ports_mutex); 2475 mutex_lock(&client->ports_mutex);
2479 list_for_each(l, &client->ports_list_head) { 2476 list_for_each_entry(p, &client->ports_list_head, list) {
2480 struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
2481 snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n", 2477 snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n",
2482 p->addr.port, p->name, 2478 p->addr.port, p->name,
2483 FLAG_PERM_RD(p->capability), 2479 FLAG_PERM_RD(p->capability),
diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
index b79d011813c0..37852cdace76 100644
--- a/sound/core/seq/seq_device.c
+++ b/sound/core/seq/seq_device.c
@@ -106,11 +106,10 @@ static void remove_drivers(void);
106static void snd_seq_device_info(struct snd_info_entry *entry, 106static void snd_seq_device_info(struct snd_info_entry *entry,
107 struct snd_info_buffer *buffer) 107 struct snd_info_buffer *buffer)
108{ 108{
109 struct list_head *head; 109 struct ops_list *ops;
110 110
111 mutex_lock(&ops_mutex); 111 mutex_lock(&ops_mutex);
112 list_for_each(head, &opslist) { 112 list_for_each_entry(ops, &opslist, list) {
113 struct ops_list *ops = list_entry(head, struct ops_list, list);
114 snd_iprintf(buffer, "snd-%s%s%s%s,%d\n", 113 snd_iprintf(buffer, "snd-%s%s%s%s,%d\n",
115 ops->id, 114 ops->id,
116 ops->driver & DRIVER_LOADED ? ",loaded" : (ops->driver == DRIVER_EMPTY ? ",empty" : ""), 115 ops->driver & DRIVER_LOADED ? ",loaded" : (ops->driver == DRIVER_EMPTY ? ",empty" : ""),
@@ -143,7 +142,7 @@ void snd_seq_autoload_unlock(void)
143void snd_seq_device_load_drivers(void) 142void snd_seq_device_load_drivers(void)
144{ 143{
145#ifdef CONFIG_KMOD 144#ifdef CONFIG_KMOD
146 struct list_head *head; 145 struct ops_list *ops;
147 146
148 /* Calling request_module during module_init() 147 /* Calling request_module during module_init()
149 * may cause blocking. 148 * may cause blocking.
@@ -155,8 +154,7 @@ void snd_seq_device_load_drivers(void)
155 return; 154 return;
156 155
157 mutex_lock(&ops_mutex); 156 mutex_lock(&ops_mutex);
158 list_for_each(head, &opslist) { 157 list_for_each_entry(ops, &opslist, list) {
159 struct ops_list *ops = list_entry(head, struct ops_list, list);
160 if (! (ops->driver & DRIVER_LOADED) && 158 if (! (ops->driver & DRIVER_LOADED) &&
161 ! (ops->driver & DRIVER_REQUESTED)) { 159 ! (ops->driver & DRIVER_REQUESTED)) {
162 ops->used++; 160 ops->used++;
@@ -314,8 +312,8 @@ static int snd_seq_device_dev_disconnect(struct snd_device *device)
314int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, 312int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
315 int argsize) 313 int argsize)
316{ 314{
317 struct list_head *head;
318 struct ops_list *ops; 315 struct ops_list *ops;
316 struct snd_seq_device *dev;
319 317
320 if (id == NULL || entry == NULL || 318 if (id == NULL || entry == NULL ||
321 entry->init_device == NULL || entry->free_device == NULL) 319 entry->init_device == NULL || entry->free_device == NULL)
@@ -341,8 +339,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
341 ops->argsize = argsize; 339 ops->argsize = argsize;
342 340
343 /* initialize existing devices if necessary */ 341 /* initialize existing devices if necessary */
344 list_for_each(head, &ops->dev_list) { 342 list_for_each_entry(dev, &ops->dev_list, list) {
345 struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
346 init_device(dev, ops); 343 init_device(dev, ops);
347 } 344 }
348 mutex_unlock(&ops->reg_mutex); 345 mutex_unlock(&ops->reg_mutex);
@@ -394,8 +391,8 @@ static struct ops_list * create_driver(char *id)
394 */ 391 */
395int snd_seq_device_unregister_driver(char *id) 392int snd_seq_device_unregister_driver(char *id)
396{ 393{
397 struct list_head *head;
398 struct ops_list *ops; 394 struct ops_list *ops;
395 struct snd_seq_device *dev;
399 396
400 ops = find_driver(id, 0); 397 ops = find_driver(id, 0);
401 if (ops == NULL) 398 if (ops == NULL)
@@ -411,8 +408,7 @@ int snd_seq_device_unregister_driver(char *id)
411 /* close and release all devices associated with this driver */ 408 /* close and release all devices associated with this driver */
412 mutex_lock(&ops->reg_mutex); 409 mutex_lock(&ops->reg_mutex);
413 ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */ 410 ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */
414 list_for_each(head, &ops->dev_list) { 411 list_for_each_entry(dev, &ops->dev_list, list) {
415 struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
416 free_device(dev, ops); 412 free_device(dev, ops);
417 } 413 }
418 414
@@ -512,11 +508,10 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
512 */ 508 */
513static struct ops_list * find_driver(char *id, int create_if_empty) 509static struct ops_list * find_driver(char *id, int create_if_empty)
514{ 510{
515 struct list_head *head; 511 struct ops_list *ops;
516 512
517 mutex_lock(&ops_mutex); 513 mutex_lock(&ops_mutex);
518 list_for_each(head, &opslist) { 514 list_for_each_entry(ops, &opslist, list) {
519 struct ops_list *ops = list_entry(head, struct ops_list, list);
520 if (strcmp(ops->id, id) == 0) { 515 if (strcmp(ops->id, id) == 0) {
521 ops->used++; 516 ops->used++;
522 mutex_unlock(&ops_mutex); 517 mutex_unlock(&ops_mutex);
diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c
index 8c64b58ff77b..d88153438d69 100644
--- a/sound/core/seq/seq_ports.c
+++ b/sound/core/seq/seq_ports.c
@@ -59,14 +59,12 @@ much elements are in array.
59struct snd_seq_client_port *snd_seq_port_use_ptr(struct snd_seq_client *client, 59struct snd_seq_client_port *snd_seq_port_use_ptr(struct snd_seq_client *client,
60 int num) 60 int num)
61{ 61{
62 struct list_head *p;
63 struct snd_seq_client_port *port; 62 struct snd_seq_client_port *port;
64 63
65 if (client == NULL) 64 if (client == NULL)
66 return NULL; 65 return NULL;
67 read_lock(&client->ports_lock); 66 read_lock(&client->ports_lock);
68 list_for_each(p, &client->ports_list_head) { 67 list_for_each_entry(port, &client->ports_list_head, list) {
69 port = list_entry(p, struct snd_seq_client_port, list);
70 if (port->addr.port == num) { 68 if (port->addr.port == num) {
71 if (port->closing) 69 if (port->closing)
72 break; /* deleting now */ 70 break; /* deleting now */
@@ -85,14 +83,12 @@ struct snd_seq_client_port *snd_seq_port_query_nearest(struct snd_seq_client *cl
85 struct snd_seq_port_info *pinfo) 83 struct snd_seq_port_info *pinfo)
86{ 84{
87 int num; 85 int num;
88 struct list_head *p;
89 struct snd_seq_client_port *port, *found; 86 struct snd_seq_client_port *port, *found;
90 87
91 num = pinfo->addr.port; 88 num = pinfo->addr.port;
92 found = NULL; 89 found = NULL;
93 read_lock(&client->ports_lock); 90 read_lock(&client->ports_lock);
94 list_for_each(p, &client->ports_list_head) { 91 list_for_each_entry(port, &client->ports_list_head, list) {
95 port = list_entry(p, struct snd_seq_client_port, list);
96 if (port->addr.port < num) 92 if (port->addr.port < num)
97 continue; 93 continue;
98 if (port->addr.port == num) { 94 if (port->addr.port == num) {
@@ -131,8 +127,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
131 int port) 127 int port)
132{ 128{
133 unsigned long flags; 129 unsigned long flags;
134 struct snd_seq_client_port *new_port; 130 struct snd_seq_client_port *new_port, *p;
135 struct list_head *l;
136 int num = -1; 131 int num = -1;
137 132
138 /* sanity check */ 133 /* sanity check */
@@ -161,15 +156,14 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
161 num = port >= 0 ? port : 0; 156 num = port >= 0 ? port : 0;
162 mutex_lock(&client->ports_mutex); 157 mutex_lock(&client->ports_mutex);
163 write_lock_irqsave(&client->ports_lock, flags); 158 write_lock_irqsave(&client->ports_lock, flags);
164 list_for_each(l, &client->ports_list_head) { 159 list_for_each_entry(p, &client->ports_list_head, list) {
165 struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
166 if (p->addr.port > num) 160 if (p->addr.port > num)
167 break; 161 break;
168 if (port < 0) /* auto-probe mode */ 162 if (port < 0) /* auto-probe mode */
169 num = p->addr.port + 1; 163 num = p->addr.port + 1;
170 } 164 }
171 /* insert the new port */ 165 /* insert the new port */
172 list_add_tail(&new_port->list, l); 166 list_add_tail(&new_port->list, &p->list);
173 client->num_ports++; 167 client->num_ports++;
174 new_port->addr.port = num; /* store the port number in the port */ 168 new_port->addr.port = num; /* store the port number in the port */
175 write_unlock_irqrestore(&client->ports_lock, flags); 169 write_unlock_irqrestore(&client->ports_lock, flags);
@@ -287,16 +281,14 @@ static int port_delete(struct snd_seq_client *client,
287int snd_seq_delete_port(struct snd_seq_client *client, int port) 281int snd_seq_delete_port(struct snd_seq_client *client, int port)
288{ 282{
289 unsigned long flags; 283 unsigned long flags;
290 struct list_head *l; 284 struct snd_seq_client_port *found = NULL, *p;
291 struct snd_seq_client_port *found = NULL;
292 285
293 mutex_lock(&client->ports_mutex); 286 mutex_lock(&client->ports_mutex);
294 write_lock_irqsave(&client->ports_lock, flags); 287 write_lock_irqsave(&client->ports_lock, flags);
295 list_for_each(l, &client->ports_list_head) { 288 list_for_each_entry(p, &client->ports_list_head, list) {
296 struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
297 if (p->addr.port == port) { 289 if (p->addr.port == port) {
298 /* ok found. delete from the list at first */ 290 /* ok found. delete from the list at first */
299 list_del(l); 291 list_del(&p->list);
300 client->num_ports--; 292 client->num_ports--;
301 found = p; 293 found = p;
302 break; 294 break;
@@ -314,7 +306,8 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port)
314int snd_seq_delete_all_ports(struct snd_seq_client *client) 306int snd_seq_delete_all_ports(struct snd_seq_client *client)
315{ 307{
316 unsigned long flags; 308 unsigned long flags;
317 struct list_head deleted_list, *p, *n; 309 struct list_head deleted_list;
310 struct snd_seq_client_port *port, *tmp;
318 311
319 /* move the port list to deleted_list, and 312 /* move the port list to deleted_list, and
320 * clear the port list in the client data. 313 * clear the port list in the client data.
@@ -331,9 +324,8 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client)
331 write_unlock_irqrestore(&client->ports_lock, flags); 324 write_unlock_irqrestore(&client->ports_lock, flags);
332 325
333 /* remove each port in deleted_list */ 326 /* remove each port in deleted_list */
334 list_for_each_safe(p, n, &deleted_list) { 327 list_for_each_entry_safe(port, tmp, &deleted_list, list) {
335 struct snd_seq_client_port *port = list_entry(p, struct snd_seq_client_port, list); 328 list_del(&port->list);
336 list_del(p);
337 snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port); 329 snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port);
338 port_delete(client, port); 330 port_delete(client, port);
339 } 331 }
@@ -500,8 +492,7 @@ int snd_seq_port_connect(struct snd_seq_client *connector,
500{ 492{
501 struct snd_seq_port_subs_info *src = &src_port->c_src; 493 struct snd_seq_port_subs_info *src = &src_port->c_src;
502 struct snd_seq_port_subs_info *dest = &dest_port->c_dest; 494 struct snd_seq_port_subs_info *dest = &dest_port->c_dest;
503 struct snd_seq_subscribers *subs; 495 struct snd_seq_subscribers *subs, *s;
504 struct list_head *p;
505 int err, src_called = 0; 496 int err, src_called = 0;
506 unsigned long flags; 497 unsigned long flags;
507 int exclusive; 498 int exclusive;
@@ -525,13 +516,11 @@ int snd_seq_port_connect(struct snd_seq_client *connector,
525 if (src->exclusive || dest->exclusive) 516 if (src->exclusive || dest->exclusive)
526 goto __error; 517 goto __error;
527 /* check whether already exists */ 518 /* check whether already exists */
528 list_for_each(p, &src->list_head) { 519 list_for_each_entry(s, &src->list_head, src_list) {
529 struct snd_seq_subscribers *s = list_entry(p, struct snd_seq_subscribers, src_list);
530 if (match_subs_info(info, &s->info)) 520 if (match_subs_info(info, &s->info))
531 goto __error; 521 goto __error;
532 } 522 }
533 list_for_each(p, &dest->list_head) { 523 list_for_each_entry(s, &dest->list_head, dest_list) {
534 struct snd_seq_subscribers *s = list_entry(p, struct snd_seq_subscribers, dest_list);
535 if (match_subs_info(info, &s->info)) 524 if (match_subs_info(info, &s->info))
536 goto __error; 525 goto __error;
537 } 526 }
@@ -582,7 +571,6 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector,
582 struct snd_seq_port_subs_info *src = &src_port->c_src; 571 struct snd_seq_port_subs_info *src = &src_port->c_src;
583 struct snd_seq_port_subs_info *dest = &dest_port->c_dest; 572 struct snd_seq_port_subs_info *dest = &dest_port->c_dest;
584 struct snd_seq_subscribers *subs; 573 struct snd_seq_subscribers *subs;
585 struct list_head *p;
586 int err = -ENOENT; 574 int err = -ENOENT;
587 unsigned long flags; 575 unsigned long flags;
588 576
@@ -590,8 +578,7 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector,
590 down_write_nested(&dest->list_mutex, SINGLE_DEPTH_NESTING); 578 down_write_nested(&dest->list_mutex, SINGLE_DEPTH_NESTING);
591 579
592 /* look for the connection */ 580 /* look for the connection */
593 list_for_each(p, &src->list_head) { 581 list_for_each_entry(subs, &src->list_head, src_list) {
594 subs = list_entry(p, struct snd_seq_subscribers, src_list);
595 if (match_subs_info(info, &subs->info)) { 582 if (match_subs_info(info, &subs->info)) {
596 write_lock_irqsave(&src->list_lock, flags); 583 write_lock_irqsave(&src->list_lock, flags);
597 // write_lock(&dest->list_lock); // no lock yet 584 // write_lock(&dest->list_lock); // no lock yet
@@ -620,12 +607,10 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector,
620struct snd_seq_subscribers *snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp, 607struct snd_seq_subscribers *snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp,
621 struct snd_seq_addr *dest_addr) 608 struct snd_seq_addr *dest_addr)
622{ 609{
623 struct list_head *p;
624 struct snd_seq_subscribers *s, *found = NULL; 610 struct snd_seq_subscribers *s, *found = NULL;
625 611
626 down_read(&src_grp->list_mutex); 612 down_read(&src_grp->list_mutex);
627 list_for_each(p, &src_grp->list_head) { 613 list_for_each_entry(s, &src_grp->list_head, src_list) {
628 s = list_entry(p, struct snd_seq_subscribers, src_list);
629 if (addr_match(dest_addr, &s->info.dest)) { 614 if (addr_match(dest_addr, &s->info.dest)) {
630 found = s; 615 found = s;
631 break; 616 break;
diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c
index 0cfa06c6b81f..972f93405364 100644
--- a/sound/core/seq/seq_virmidi.c
+++ b/sound/core/seq/seq_virmidi.c
@@ -81,13 +81,11 @@ static int snd_virmidi_dev_receive_event(struct snd_virmidi_dev *rdev,
81 struct snd_seq_event *ev) 81 struct snd_seq_event *ev)
82{ 82{
83 struct snd_virmidi *vmidi; 83 struct snd_virmidi *vmidi;
84 struct list_head *list;
85 unsigned char msg[4]; 84 unsigned char msg[4];
86 int len; 85 int len;
87 86
88 read_lock(&rdev->filelist_lock); 87 read_lock(&rdev->filelist_lock);
89 list_for_each(list, &rdev->filelist) { 88 list_for_each_entry(vmidi, &rdev->filelist, list) {
90 vmidi = list_entry(list, struct snd_virmidi, list);
91 if (!vmidi->trigger) 89 if (!vmidi->trigger)
92 continue; 90 continue;
93 if (ev->type == SNDRV_SEQ_EVENT_SYSEX) { 91 if (ev->type == SNDRV_SEQ_EVENT_SYSEX) {