Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Johannes Berg and committed by
Jaroslav Kysela
9244b2c3 d595ee7e

+102 -214
+9 -28
sound/core/control.c
··· 108 108 static int snd_ctl_release(struct inode *inode, struct file *file) 109 109 { 110 110 unsigned long flags; 111 - struct list_head *list; 112 111 struct snd_card *card; 113 112 struct snd_ctl_file *ctl; 114 113 struct snd_kcontrol *control; ··· 121 122 list_del(&ctl->list); 122 123 write_unlock_irqrestore(&card->ctl_files_rwlock, flags); 123 124 down_write(&card->controls_rwsem); 124 - list_for_each(list, &card->controls) { 125 - control = snd_kcontrol(list); 125 + list_for_each_entry(control, &card->controls, list) 126 126 for (idx = 0; idx < control->count; idx++) 127 127 if (control->vd[idx].owner == ctl) 128 128 control->vd[idx].owner = NULL; 129 - } 130 129 up_write(&card->controls_rwsem); 131 130 snd_ctl_empty_read_queue(ctl); 132 131 kfree(ctl); ··· 137 140 struct snd_ctl_elem_id *id) 138 141 { 139 142 unsigned long flags; 140 - struct list_head *flist; 141 143 struct snd_ctl_file *ctl; 142 144 struct snd_kctl_event *ev; 143 145 ··· 145 149 #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) 146 150 card->mixer_oss_change_count++; 147 151 #endif 148 - list_for_each(flist, &card->ctl_files) { 149 - struct list_head *elist; 150 - ctl = snd_ctl_file(flist); 152 + list_for_each_entry(ctl, &card->ctl_files, list) { 151 153 if (!ctl->subscribed) 152 154 continue; 153 155 spin_lock_irqsave(&ctl->read_lock, flags); 154 - list_for_each(elist, &ctl->events) { 155 - ev = snd_kctl_event(elist); 156 + list_for_each_entry(ev, &ctl->events, list) { 156 157 if (ev->id.numid == id->numid) { 157 158 ev->mask |= mask; 158 159 goto _found; ··· 270 277 static unsigned int snd_ctl_hole_check(struct snd_card *card, 271 278 unsigned int count) 272 279 { 273 - struct list_head *list; 274 280 struct snd_kcontrol *kctl; 275 281 276 - list_for_each(list, &card->controls) { 277 - kctl = snd_kcontrol(list); 282 + list_for_each_entry(kctl, &card->controls, list) { 278 283 if ((kctl->id.numid <= card->last_numid && 279 284 kctl->id.numid + kctl->count > card->last_numid) || 280 285 (kctl->id.numid <= card->last_numid + count - 1 && ··· 489 498 */ 490 499 struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid) 491 500 { 492 - struct list_head *list; 493 501 struct snd_kcontrol *kctl; 494 502 495 503 snd_assert(card != NULL && numid != 0, return NULL); 496 - list_for_each(list, &card->controls) { 497 - kctl = snd_kcontrol(list); 504 + list_for_each_entry(kctl, &card->controls, list) { 498 505 if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid) 499 506 return kctl; 500 507 } ··· 516 527 struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card, 517 528 struct snd_ctl_elem_id *id) 518 529 { 519 - struct list_head *list; 520 530 struct snd_kcontrol *kctl; 521 531 522 532 snd_assert(card != NULL && id != NULL, return NULL); 523 533 if (id->numid != 0) 524 534 return snd_ctl_find_numid(card, id->numid); 525 - list_for_each(list, &card->controls) { 526 - kctl = snd_kcontrol(list); 535 + list_for_each_entry(kctl, &card->controls, list) { 527 536 if (kctl->id.iface != id->iface) 528 537 continue; 529 538 if (kctl->id.device != id->device) ··· 1169 1182 { 1170 1183 struct snd_ctl_file *ctl; 1171 1184 struct snd_card *card; 1172 - struct list_head *list; 1173 1185 struct snd_kctl_ioctl *p; 1174 1186 void __user *argp = (void __user *)arg; 1175 1187 int __user *ip = argp; ··· 1218 1232 #endif 1219 1233 } 1220 1234 down_read(&snd_ioctl_rwsem); 1221 - list_for_each(list, &snd_control_ioctls) { 1222 - p = list_entry(list, struct snd_kctl_ioctl, list); 1235 + list_for_each_entry(p, &snd_control_ioctls, list) { 1223 1236 err = p->fioctl(card, ctl, cmd, arg); 1224 1237 if (err != -ENOIOCTLCMD) { 1225 1238 up_read(&snd_ioctl_rwsem); ··· 1342 1357 static int _snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn, 1343 1358 struct list_head *lists) 1344 1359 { 1345 - struct list_head *list; 1346 1360 struct snd_kctl_ioctl *p; 1347 1361 1348 1362 snd_assert(fcn != NULL, return -EINVAL); 1349 1363 down_write(&snd_ioctl_rwsem); 1350 - list_for_each(list, lists) { 1351 - p = list_entry(list, struct snd_kctl_ioctl, list); 1364 + list_for_each_entry(p, lists, list) { 1352 1365 if (p->fioctl == fcn) { 1353 1366 list_del(&p->list); 1354 1367 up_write(&snd_ioctl_rwsem); ··· 1436 1453 static int snd_ctl_dev_disconnect(struct snd_device *device) 1437 1454 { 1438 1455 struct snd_card *card = device->device_data; 1439 - struct list_head *flist; 1440 1456 struct snd_ctl_file *ctl; 1441 1457 int err, cardnum; 1442 1458 ··· 1444 1462 snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); 1445 1463 1446 1464 down_read(&card->controls_rwsem); 1447 - list_for_each(flist, &card->ctl_files) { 1448 - ctl = snd_ctl_file(flist); 1465 + list_for_each_entry(ctl, &card->ctl_files, list) { 1449 1466 wake_up(&ctl->change_sleep); 1450 1467 kill_fasync(&ctl->fasync, SIGIO, POLL_ERR); 1451 1468 }
+2 -3
sound/core/control_compat.c
··· 392 392 static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) 393 393 { 394 394 struct snd_ctl_file *ctl; 395 - struct list_head *list; 395 + struct snd_kctl_ioctl *p; 396 396 void __user *argp = compat_ptr(arg); 397 397 int err; 398 398 ··· 427 427 } 428 428 429 429 down_read(&snd_ioctl_rwsem); 430 - list_for_each(list, &snd_control_compat_ioctls) { 431 - struct snd_kctl_ioctl *p = list_entry(list, struct snd_kctl_ioctl, list); 430 + list_for_each_entry(p, &snd_control_compat_ioctls, list) { 432 431 if (p->fioctl) { 433 432 err = p->fioctl(ctl->card, ctl, cmd, arg); 434 433 if (err != -ENOIOCTLCMD) {
+6 -18
sound/core/device.c
··· 79 79 */ 80 80 int snd_device_free(struct snd_card *card, void *device_data) 81 81 { 82 - struct list_head *list; 83 82 struct snd_device *dev; 84 83 85 84 snd_assert(card != NULL, return -ENXIO); 86 85 snd_assert(device_data != NULL, return -ENXIO); 87 - list_for_each(list, &card->devices) { 88 - dev = snd_device(list); 86 + list_for_each_entry(dev, &card->devices, list) { 89 87 if (dev->device_data != device_data) 90 88 continue; 91 89 /* unlink */ ··· 122 124 */ 123 125 int snd_device_disconnect(struct snd_card *card, void *device_data) 124 126 { 125 - struct list_head *list; 126 127 struct snd_device *dev; 127 128 128 129 snd_assert(card != NULL, return -ENXIO); 129 130 snd_assert(device_data != NULL, return -ENXIO); 130 - list_for_each(list, &card->devices) { 131 - dev = snd_device(list); 131 + list_for_each_entry(dev, &card->devices, list) { 132 132 if (dev->device_data != device_data) 133 133 continue; 134 134 if (dev->state == SNDRV_DEV_REGISTERED && ··· 157 161 */ 158 162 int snd_device_register(struct snd_card *card, void *device_data) 159 163 { 160 - struct list_head *list; 161 164 struct snd_device *dev; 162 165 int err; 163 166 164 167 snd_assert(card != NULL, return -ENXIO); 165 168 snd_assert(device_data != NULL, return -ENXIO); 166 - list_for_each(list, &card->devices) { 167 - dev = snd_device(list); 169 + list_for_each_entry(dev, &card->devices, list) { 168 170 if (dev->device_data != device_data) 169 171 continue; 170 172 if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) { ··· 186 192 */ 187 193 int snd_device_register_all(struct snd_card *card) 188 194 { 189 - struct list_head *list; 190 195 struct snd_device *dev; 191 196 int err; 192 197 193 198 snd_assert(card != NULL, return -ENXIO); 194 - list_for_each(list, &card->devices) { 195 - dev = snd_device(list); 199 + list_for_each_entry(dev, &card->devices, list) { 196 200 if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) { 197 201 if ((err = dev->ops->dev_register(dev)) < 0) 198 202 return err; ··· 207 215 int snd_device_disconnect_all(struct snd_card *card) 208 216 { 209 217 struct snd_device *dev; 210 - struct list_head *list; 211 218 int err = 0; 212 219 213 220 snd_assert(card != NULL, return -ENXIO); 214 - list_for_each(list, &card->devices) { 215 - dev = snd_device(list); 221 + list_for_each_entry(dev, &card->devices, list) { 216 222 if (snd_device_disconnect(card, dev->device_data) < 0) 217 223 err = -ENXIO; 218 224 } ··· 224 234 int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd) 225 235 { 226 236 struct snd_device *dev; 227 - struct list_head *list; 228 237 int err; 229 238 unsigned int range_low, range_high; 230 239 ··· 231 242 range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE; 232 243 range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1; 233 244 __again: 234 - list_for_each(list, &card->devices) { 235 - dev = snd_device(list); 245 + list_for_each_entry(dev, &card->devices, list) { 236 246 if (dev->type >= range_low && dev->type <= range_high) { 237 247 if ((err = snd_device_free(card, dev->device_data)) < 0) 238 248 return err;
+2 -8
sound/core/hwdep.c
··· 47 47 48 48 static struct snd_hwdep *snd_hwdep_search(struct snd_card *card, int device) 49 49 { 50 - struct list_head *p; 51 50 struct snd_hwdep *hwdep; 52 51 53 - list_for_each(p, &snd_hwdep_devices) { 54 - hwdep = list_entry(p, struct snd_hwdep, list); 52 + list_for_each_entry(hwdep, &snd_hwdep_devices, list) 55 53 if (hwdep->card == card && hwdep->device == device) 56 54 return hwdep; 57 - } 58 55 return NULL; 59 56 } 60 57 ··· 465 468 static void snd_hwdep_proc_read(struct snd_info_entry *entry, 466 469 struct snd_info_buffer *buffer) 467 470 { 468 - struct list_head *p; 469 471 struct snd_hwdep *hwdep; 470 472 471 473 mutex_lock(&register_mutex); 472 - list_for_each(p, &snd_hwdep_devices) { 473 - hwdep = list_entry(p, struct snd_hwdep, list); 474 + list_for_each_entry(hwdep, &snd_hwdep_devices, list) 474 475 snd_iprintf(buffer, "%02i-%02i: %s\n", 475 476 hwdep->card->number, hwdep->device, hwdep->name); 476 - } 477 477 mutex_unlock(&register_mutex); 478 478 } 479 479
+3 -7
sound/core/memalloc.c
··· 406 406 */ 407 407 size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id) 408 408 { 409 - struct list_head *p; 410 409 struct snd_mem_list *mem; 411 410 412 411 snd_assert(dmab, return 0); 413 412 414 413 mutex_lock(&list_mutex); 415 - list_for_each(p, &mem_list_head) { 416 - mem = list_entry(p, struct snd_mem_list, list); 414 + list_for_each_entry(mem, &mem_list_head, list) { 417 415 if (mem->id == id && 418 416 (mem->buffer.dev.dev == NULL || dmab->dev.dev == NULL || 419 417 ! memcmp(&mem->buffer.dev, &dmab->dev, sizeof(dmab->dev)))) { 420 418 struct device *dev = dmab->dev.dev; 421 - list_del(p); 419 + list_del(&mem->list); 422 420 *dmab = mem->buffer; 423 421 if (dmab->dev.dev == NULL) 424 422 dmab->dev.dev = dev; ··· 486 488 { 487 489 int len = 0; 488 490 long pages = snd_allocated_pages >> (PAGE_SHIFT-12); 489 - struct list_head *p; 490 491 struct snd_mem_list *mem; 491 492 int devno; 492 493 static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" }; ··· 495 498 "pages : %li bytes (%li pages per %likB)\n", 496 499 pages * PAGE_SIZE, pages, PAGE_SIZE / 1024); 497 500 devno = 0; 498 - list_for_each(p, &mem_list_head) { 499 - mem = list_entry(p, struct snd_mem_list, list); 501 + list_for_each_entry(mem, &mem_list_head, list) { 500 502 devno++; 501 503 len += snprintf(page + len, count - len, 502 504 "buffer %d : ID %08x : type %s\n",
+12 -20
sound/core/pcm.c
··· 45 45 46 46 static struct snd_pcm *snd_pcm_search(struct snd_card *card, int device) 47 47 { 48 - struct list_head *p; 49 48 struct snd_pcm *pcm; 50 49 51 - list_for_each(p, &snd_pcm_devices) { 52 - pcm = list_entry(p, struct snd_pcm, list); 50 + list_for_each_entry(pcm, &snd_pcm_devices, list) { 53 51 if (pcm->card == card && pcm->device == device) 54 52 return pcm; 55 53 } ··· 780 782 struct snd_pcm_runtime *runtime; 781 783 struct snd_ctl_file *kctl; 782 784 struct snd_card *card; 783 - struct list_head *list; 784 785 int prefer_subdevice = -1; 785 786 size_t size; 786 787 ··· 792 795 793 796 card = pcm->card; 794 797 down_read(&card->controls_rwsem); 795 - list_for_each(list, &card->ctl_files) { 796 - kctl = snd_ctl_file(list); 798 + list_for_each_entry(kctl, &card->ctl_files, list) { 797 799 if (kctl->pid == current->pid) { 798 800 prefer_subdevice = kctl->prefer_pcm_subdevice; 799 801 if (prefer_subdevice != -1) ··· 937 941 { 938 942 int cidx, err; 939 943 struct snd_pcm_substream *substream; 940 - struct list_head *list; 944 + struct snd_pcm_notify *notify; 941 945 char str[16]; 942 946 struct snd_pcm *pcm = device->device_data; 943 947 struct device *dev; ··· 984 988 for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) 985 989 snd_pcm_timer_init(substream); 986 990 } 987 - list_for_each(list, &snd_pcm_notify_list) { 988 - struct snd_pcm_notify *notify; 989 - notify = list_entry(list, struct snd_pcm_notify, list); 991 + 992 + list_for_each_entry(notify, &snd_pcm_notify_list, list) 990 993 notify->n_register(pcm); 991 - } 994 + 992 995 mutex_unlock(&register_mutex); 993 996 return 0; 994 997 } ··· 1030 1035 1031 1036 int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) 1032 1037 { 1033 - struct list_head *p; 1038 + struct snd_pcm *pcm; 1034 1039 1035 1040 snd_assert(notify != NULL && 1036 1041 notify->n_register != NULL && ··· 1039 1044 mutex_lock(&register_mutex); 1040 1045 if (nfree) { 1041 1046 list_del(&notify->list); 1042 - list_for_each(p, &snd_pcm_devices) 1043 - notify->n_unregister(list_entry(p, 1044 - struct snd_pcm, list)); 1047 + list_for_each_entry(pcm, &snd_pcm_devices, list) 1048 + notify->n_unregister(pcm); 1045 1049 } else { 1046 1050 list_add_tail(&notify->list, &snd_pcm_notify_list); 1047 - list_for_each(p, &snd_pcm_devices) 1048 - notify->n_register(list_entry(p, struct snd_pcm, list)); 1051 + list_for_each_entry(pcm, &snd_pcm_devices, list) 1052 + notify->n_register(pcm); 1049 1053 } 1050 1054 mutex_unlock(&register_mutex); 1051 1055 return 0; ··· 1060 1066 static void snd_pcm_proc_read(struct snd_info_entry *entry, 1061 1067 struct snd_info_buffer *buffer) 1062 1068 { 1063 - struct list_head *p; 1064 1069 struct snd_pcm *pcm; 1065 1070 1066 1071 mutex_lock(&register_mutex); 1067 - list_for_each(p, &snd_pcm_devices) { 1068 - pcm = list_entry(p, struct snd_pcm, list); 1072 + list_for_each_entry(pcm, &snd_pcm_devices, list) { 1069 1073 snd_iprintf(buffer, "%02i-%02i: %s : %s", 1070 1074 pcm->card->number, pcm->device, pcm->id, pcm->name); 1071 1075 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)
+10 -19
sound/core/rawmidi.c
··· 61 61 62 62 static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) 63 63 { 64 - struct list_head *p; 65 64 struct snd_rawmidi *rawmidi; 66 65 67 - list_for_each(p, &snd_rawmidi_devices) { 68 - rawmidi = list_entry(p, struct snd_rawmidi, list); 66 + list_for_each_entry(rawmidi, &snd_rawmidi_devices, list) 69 67 if (rawmidi->card == card && rawmidi->device == device) 70 68 return rawmidi; 71 - } 72 69 return NULL; 73 70 } 74 71 ··· 386 389 struct snd_rawmidi *rmidi; 387 390 struct snd_rawmidi_file *rawmidi_file; 388 391 wait_queue_t wait; 389 - struct list_head *list; 390 392 struct snd_ctl_file *kctl; 391 393 392 394 if (maj == snd_major) { ··· 422 426 while (1) { 423 427 subdevice = -1; 424 428 down_read(&card->controls_rwsem); 425 - list_for_each(list, &card->ctl_files) { 426 - kctl = snd_ctl_file(list); 429 + list_for_each_entry(kctl, &card->ctl_files, list) { 427 430 if (kctl->pid == current->pid) { 428 431 subdevice = kctl->prefer_rawmidi_subdevice; 429 432 if (subdevice != -1) ··· 570 575 struct snd_rawmidi *rmidi; 571 576 struct snd_rawmidi_str *pstr; 572 577 struct snd_rawmidi_substream *substream; 573 - struct list_head *list; 574 578 575 579 mutex_lock(&register_mutex); 576 580 rmidi = snd_rawmidi_search(card, info->device); ··· 583 589 return -ENOENT; 584 590 if (info->subdevice >= pstr->substream_count) 585 591 return -ENXIO; 586 - list_for_each(list, &pstr->substreams) { 587 - substream = list_entry(list, struct snd_rawmidi_substream, list); 592 + list_for_each_entry(substream, &pstr->substreams, list) { 588 593 if ((unsigned int)substream->number == info->subdevice) 589 594 return snd_rawmidi_info(substream, info); 590 595 } ··· 1306 1313 struct snd_rawmidi *rmidi; 1307 1314 struct snd_rawmidi_substream *substream; 1308 1315 struct snd_rawmidi_runtime *runtime; 1309 - struct list_head *list; 1310 1316 1311 1317 rmidi = entry->private_data; 1312 1318 snd_iprintf(buffer, "%s\n\n", rmidi->name); 1313 1319 mutex_lock(&rmidi->open_mutex); 1314 1320 if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) { 1315 - list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { 1316 - substream = list_entry(list, struct snd_rawmidi_substream, list); 1321 + list_for_each_entry(substream, 1322 + &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams, 1323 + list) { 1317 1324 snd_iprintf(buffer, 1318 1325 "Output %d\n" 1319 1326 " Tx bytes : %lu\n", ··· 1332 1339 } 1333 1340 } 1334 1341 if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT) { 1335 - list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams) { 1336 - substream = list_entry(list, struct snd_rawmidi_substream, list); 1342 + list_for_each_entry(substream, 1343 + &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams, 1344 + list) { 1337 1345 snd_iprintf(buffer, 1338 1346 "Input %d\n" 1339 1347 " Rx bytes : %lu\n", ··· 1619 1625 void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream, 1620 1626 struct snd_rawmidi_ops *ops) 1621 1627 { 1622 - struct list_head *list; 1623 1628 struct snd_rawmidi_substream *substream; 1624 1629 1625 - list_for_each(list, &rmidi->streams[stream].substreams) { 1626 - substream = list_entry(list, struct snd_rawmidi_substream, list); 1630 + list_for_each_entry(substream, &rmidi->streams[stream].substreams, list) 1627 1631 substream->ops = ops; 1628 - } 1629 1632 } 1630 1633 1631 1634 /*
+5 -9
sound/core/seq/seq_clientmgr.c
··· 659 659 int err = 0, num_ev = 0; 660 660 struct snd_seq_event event_saved; 661 661 struct snd_seq_client_port *src_port; 662 - struct list_head *p; 663 662 struct snd_seq_port_subs_info *grp; 664 663 665 664 src_port = snd_seq_port_use_ptr(client, event->source.port); ··· 673 674 read_lock(&grp->list_lock); 674 675 else 675 676 down_read(&grp->list_mutex); 676 - list_for_each(p, &grp->list_head) { 677 - subs = list_entry(p, struct snd_seq_subscribers, src_list); 677 + list_for_each_entry(subs, &grp->list_head, src_list) { 678 678 event->dest = subs->info.dest; 679 679 if (subs->info.flags & SNDRV_SEQ_PORT_SUBS_TIMESTAMP) 680 680 /* convert time according to flag with subscription */ ··· 707 709 { 708 710 int num_ev = 0, err = 0; 709 711 struct snd_seq_client *dest_client; 710 - struct list_head *p; 712 + struct snd_seq_client_port *port; 711 713 712 714 dest_client = get_event_dest_client(event, SNDRV_SEQ_FILTER_BROADCAST); 713 715 if (dest_client == NULL) 714 716 return 0; /* no matching destination */ 715 717 716 718 read_lock(&dest_client->ports_lock); 717 - list_for_each(p, &dest_client->ports_list_head) { 718 - struct snd_seq_client_port *port = list_entry(p, struct snd_seq_client_port, list); 719 + list_for_each_entry(port, &dest_client->ports_list_head, list) { 719 720 event->dest.port = port->addr.port; 720 721 /* pass NULL as source client to avoid error bounce */ 721 722 err = snd_seq_deliver_single_event(NULL, event, ··· 2470 2473 static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer, 2471 2474 struct snd_seq_client *client) 2472 2475 { 2473 - struct list_head *l; 2476 + struct snd_seq_client_port *p; 2474 2477 2475 2478 mutex_lock(&client->ports_mutex); 2476 - list_for_each(l, &client->ports_list_head) { 2477 - struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); 2479 + list_for_each_entry(p, &client->ports_list_head, list) { 2478 2480 snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n", 2479 2481 p->addr.port, p->name, 2480 2482 FLAG_PERM_RD(p->capability),
+10 -15
sound/core/seq/seq_device.c
··· 106 106 static void snd_seq_device_info(struct snd_info_entry *entry, 107 107 struct snd_info_buffer *buffer) 108 108 { 109 - struct list_head *head; 109 + struct ops_list *ops; 110 110 111 111 mutex_lock(&ops_mutex); 112 - list_for_each(head, &opslist) { 113 - struct ops_list *ops = list_entry(head, struct ops_list, list); 112 + list_for_each_entry(ops, &opslist, list) { 114 113 snd_iprintf(buffer, "snd-%s%s%s%s,%d\n", 115 114 ops->id, 116 115 ops->driver & DRIVER_LOADED ? ",loaded" : (ops->driver == DRIVER_EMPTY ? ",empty" : ""), ··· 142 143 void snd_seq_device_load_drivers(void) 143 144 { 144 145 #ifdef CONFIG_KMOD 145 - struct list_head *head; 146 + struct ops_list *ops; 146 147 147 148 /* Calling request_module during module_init() 148 149 * may cause blocking. ··· 154 155 return; 155 156 156 157 mutex_lock(&ops_mutex); 157 - list_for_each(head, &opslist) { 158 - struct ops_list *ops = list_entry(head, struct ops_list, list); 158 + list_for_each_entry(ops, &opslist, list) { 159 159 if (! (ops->driver & DRIVER_LOADED) && 160 160 ! (ops->driver & DRIVER_REQUESTED)) { 161 161 ops->used++; ··· 312 314 int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, 313 315 int argsize) 314 316 { 315 - struct list_head *head; 316 317 struct ops_list *ops; 318 + struct snd_seq_device *dev; 317 319 318 320 if (id == NULL || entry == NULL || 319 321 entry->init_device == NULL || entry->free_device == NULL) ··· 339 341 ops->argsize = argsize; 340 342 341 343 /* initialize existing devices if necessary */ 342 - list_for_each(head, &ops->dev_list) { 343 - struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list); 344 + list_for_each_entry(dev, &ops->dev_list, list) { 344 345 init_device(dev, ops); 345 346 } 346 347 mutex_unlock(&ops->reg_mutex); ··· 391 394 */ 392 395 int snd_seq_device_unregister_driver(char *id) 393 396 { 394 - struct list_head *head; 395 397 struct ops_list *ops; 398 + struct snd_seq_device *dev; 396 399 397 400 ops = find_driver(id, 0); 398 401 if (ops == NULL) ··· 408 411 /* close and release all devices associated with this driver */ 409 412 mutex_lock(&ops->reg_mutex); 410 413 ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */ 411 - list_for_each(head, &ops->dev_list) { 412 - struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list); 414 + list_for_each_entry(dev, &ops->dev_list, list) { 413 415 free_device(dev, ops); 414 416 } 415 417 ··· 508 512 */ 509 513 static struct ops_list * find_driver(char *id, int create_if_empty) 510 514 { 511 - struct list_head *head; 515 + struct ops_list *ops; 512 516 513 517 mutex_lock(&ops_mutex); 514 - list_for_each(head, &opslist) { 515 - struct ops_list *ops = list_entry(head, struct ops_list, list); 518 + list_for_each_entry(ops, &opslist, list) { 516 519 if (strcmp(ops->id, id) == 0) { 517 520 ops->used++; 518 521 mutex_unlock(&ops_mutex);
+17 -32
sound/core/seq/seq_ports.c
··· 59 59 struct snd_seq_client_port *snd_seq_port_use_ptr(struct snd_seq_client *client, 60 60 int num) 61 61 { 62 - struct list_head *p; 63 62 struct snd_seq_client_port *port; 64 63 65 64 if (client == NULL) 66 65 return NULL; 67 66 read_lock(&client->ports_lock); 68 - list_for_each(p, &client->ports_list_head) { 69 - port = list_entry(p, struct snd_seq_client_port, list); 67 + list_for_each_entry(port, &client->ports_list_head, list) { 70 68 if (port->addr.port == num) { 71 69 if (port->closing) 72 70 break; /* deleting now */ ··· 83 85 struct snd_seq_port_info *pinfo) 84 86 { 85 87 int num; 86 - struct list_head *p; 87 88 struct snd_seq_client_port *port, *found; 88 89 89 90 num = pinfo->addr.port; 90 91 found = NULL; 91 92 read_lock(&client->ports_lock); 92 - list_for_each(p, &client->ports_list_head) { 93 - port = list_entry(p, struct snd_seq_client_port, list); 93 + list_for_each_entry(port, &client->ports_list_head, list) { 94 94 if (port->addr.port < num) 95 95 continue; 96 96 if (port->addr.port == num) { ··· 127 131 int port) 128 132 { 129 133 unsigned long flags; 130 - struct snd_seq_client_port *new_port; 131 - struct list_head *l; 134 + struct snd_seq_client_port *new_port, *p; 132 135 int num = -1; 133 136 134 137 /* sanity check */ ··· 156 161 num = port >= 0 ? port : 0; 157 162 mutex_lock(&client->ports_mutex); 158 163 write_lock_irqsave(&client->ports_lock, flags); 159 - list_for_each(l, &client->ports_list_head) { 160 - struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); 164 + list_for_each_entry(p, &client->ports_list_head, list) { 161 165 if (p->addr.port > num) 162 166 break; 163 167 if (port < 0) /* auto-probe mode */ 164 168 num = p->addr.port + 1; 165 169 } 166 170 /* insert the new port */ 167 - list_add_tail(&new_port->list, l); 171 + list_add_tail(&new_port->list, &p->list); 168 172 client->num_ports++; 169 173 new_port->addr.port = num; /* store the port number in the port */ 170 174 write_unlock_irqrestore(&client->ports_lock, flags); ··· 281 287 int snd_seq_delete_port(struct snd_seq_client *client, int port) 282 288 { 283 289 unsigned long flags; 284 - struct list_head *l; 285 - struct snd_seq_client_port *found = NULL; 290 + struct snd_seq_client_port *found = NULL, *p; 286 291 287 292 mutex_lock(&client->ports_mutex); 288 293 write_lock_irqsave(&client->ports_lock, flags); 289 - list_for_each(l, &client->ports_list_head) { 290 - struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); 294 + list_for_each_entry(p, &client->ports_list_head, list) { 291 295 if (p->addr.port == port) { 292 296 /* ok found. delete from the list at first */ 293 - list_del(l); 297 + list_del(&p->list); 294 298 client->num_ports--; 295 299 found = p; 296 300 break; ··· 306 314 int snd_seq_delete_all_ports(struct snd_seq_client *client) 307 315 { 308 316 unsigned long flags; 309 - struct list_head deleted_list, *p, *n; 317 + struct list_head deleted_list; 318 + struct snd_seq_client_port *port, *tmp; 310 319 311 320 /* move the port list to deleted_list, and 312 321 * clear the port list in the client data. ··· 324 331 write_unlock_irqrestore(&client->ports_lock, flags); 325 332 326 333 /* remove each port in deleted_list */ 327 - list_for_each_safe(p, n, &deleted_list) { 328 - struct snd_seq_client_port *port = list_entry(p, struct snd_seq_client_port, list); 329 - list_del(p); 334 + list_for_each_entry_safe(port, tmp, &deleted_list, list) { 335 + list_del(&port->list); 330 336 snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port); 331 337 port_delete(client, port); 332 338 } ··· 492 500 { 493 501 struct snd_seq_port_subs_info *src = &src_port->c_src; 494 502 struct snd_seq_port_subs_info *dest = &dest_port->c_dest; 495 - struct snd_seq_subscribers *subs; 496 - struct list_head *p; 503 + struct snd_seq_subscribers *subs, *s; 497 504 int err, src_called = 0; 498 505 unsigned long flags; 499 506 int exclusive; ··· 516 525 if (src->exclusive || dest->exclusive) 517 526 goto __error; 518 527 /* check whether already exists */ 519 - list_for_each(p, &src->list_head) { 520 - struct snd_seq_subscribers *s = list_entry(p, struct snd_seq_subscribers, src_list); 528 + list_for_each_entry(s, &src->list_head, src_list) { 521 529 if (match_subs_info(info, &s->info)) 522 530 goto __error; 523 531 } 524 - list_for_each(p, &dest->list_head) { 525 - struct snd_seq_subscribers *s = list_entry(p, struct snd_seq_subscribers, dest_list); 532 + list_for_each_entry(s, &dest->list_head, dest_list) { 526 533 if (match_subs_info(info, &s->info)) 527 534 goto __error; 528 535 } ··· 571 582 struct snd_seq_port_subs_info *src = &src_port->c_src; 572 583 struct snd_seq_port_subs_info *dest = &dest_port->c_dest; 573 584 struct snd_seq_subscribers *subs; 574 - struct list_head *p; 575 585 int err = -ENOENT; 576 586 unsigned long flags; 577 587 ··· 578 590 down_write_nested(&dest->list_mutex, SINGLE_DEPTH_NESTING); 579 591 580 592 /* look for the connection */ 581 - list_for_each(p, &src->list_head) { 582 - subs = list_entry(p, struct snd_seq_subscribers, src_list); 593 + list_for_each_entry(subs, &src->list_head, src_list) { 583 594 if (match_subs_info(info, &subs->info)) { 584 595 write_lock_irqsave(&src->list_lock, flags); 585 596 // write_lock(&dest->list_lock); // no lock yet ··· 607 620 struct snd_seq_subscribers *snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp, 608 621 struct snd_seq_addr *dest_addr) 609 622 { 610 - struct list_head *p; 611 623 struct snd_seq_subscribers *s, *found = NULL; 612 624 613 625 down_read(&src_grp->list_mutex); 614 - list_for_each(p, &src_grp->list_head) { 615 - s = list_entry(p, struct snd_seq_subscribers, src_list); 626 + list_for_each_entry(s, &src_grp->list_head, src_list) { 616 627 if (addr_match(dest_addr, &s->info.dest)) { 617 628 found = s; 618 629 break;
+1 -3
sound/core/seq/seq_virmidi.c
··· 81 81 struct snd_seq_event *ev) 82 82 { 83 83 struct snd_virmidi *vmidi; 84 - struct list_head *list; 85 84 unsigned char msg[4]; 86 85 int len; 87 86 88 87 read_lock(&rdev->filelist_lock); 89 - list_for_each(list, &rdev->filelist) { 90 - vmidi = list_entry(list, struct snd_virmidi, list); 88 + list_for_each_entry(vmidi, &rdev->filelist, list) { 91 89 if (!vmidi->trigger) 92 90 continue; 93 91 if (ev->type == SNDRV_SEQ_EVENT_SYSEX) {
+25 -52
sound/core/timer.c
··· 130 130 static struct snd_timer *snd_timer_find(struct snd_timer_id *tid) 131 131 { 132 132 struct snd_timer *timer = NULL; 133 - struct list_head *p; 134 133 135 - list_for_each(p, &snd_timer_list) { 136 - timer = list_entry(p, struct snd_timer, device_list); 137 - 134 + list_for_each_entry(timer, &snd_timer_list, device_list) { 138 135 if (timer->tmr_class != tid->dev_class) 139 136 continue; 140 137 if ((timer->tmr_class == SNDRV_TIMER_CLASS_CARD || ··· 181 184 { 182 185 struct snd_timer *timer; 183 186 struct snd_timer_instance *master; 184 - struct list_head *p, *q; 185 187 186 188 /* FIXME: it's really dumb to look up all entries.. */ 187 - list_for_each(p, &snd_timer_list) { 188 - timer = list_entry(p, struct snd_timer, device_list); 189 - list_for_each(q, &timer->open_list_head) { 190 - master = list_entry(q, struct snd_timer_instance, open_list); 189 + list_for_each_entry(timer, &snd_timer_list, device_list) { 190 + list_for_each_entry(master, &timer->open_list_head, open_list) { 191 191 if (slave->slave_class == master->slave_class && 192 192 slave->slave_id == master->slave_id) { 193 193 list_del(&slave->open_list); ··· 208 214 */ 209 215 static void snd_timer_check_master(struct snd_timer_instance *master) 210 216 { 211 - struct snd_timer_instance *slave; 212 - struct list_head *p, *n; 217 + struct snd_timer_instance *slave, *tmp; 213 218 214 219 /* check all pending slaves */ 215 - list_for_each_safe(p, n, &snd_timer_slave_list) { 216 - slave = list_entry(p, struct snd_timer_instance, open_list); 220 + list_for_each_entry_safe(slave, tmp, &snd_timer_slave_list, open_list) { 217 221 if (slave->slave_class == master->slave_class && 218 222 slave->slave_id == master->slave_id) { 219 - list_del(p); 220 - list_add_tail(p, &master->slave_list_head); 223 + list_move_tail(&slave->open_list, &master->slave_list_head); 221 224 spin_lock_irq(&slave_active_lock); 222 225 slave->master = master; 223 226 slave->timer = master->timer; ··· 308 317 int snd_timer_close(struct snd_timer_instance *timeri) 309 318 { 310 319 struct snd_timer *timer = NULL; 311 - struct list_head *p, *n; 312 - struct snd_timer_instance *slave; 320 + struct snd_timer_instance *slave, *tmp; 313 321 314 322 snd_assert(timeri != NULL, return -ENXIO); 315 323 ··· 343 353 timer->hw.close) 344 354 timer->hw.close(timer); 345 355 /* remove slave links */ 346 - list_for_each_safe(p, n, &timeri->slave_list_head) { 347 - slave = list_entry(p, struct snd_timer_instance, open_list); 356 + list_for_each_entry_safe(slave, tmp, &timeri->slave_list_head, 357 + open_list) { 348 358 spin_lock_irq(&slave_active_lock); 349 359 _snd_timer_stop(slave, 1, SNDRV_TIMER_EVENT_RESOLUTION); 350 - list_del(p); 351 - list_add_tail(p, &snd_timer_slave_list); 360 + list_move_tail(&slave->open_list, &snd_timer_slave_list); 352 361 slave->master = NULL; 353 362 slave->timer = NULL; 354 363 spin_unlock_irq(&slave_active_lock); ··· 383 394 unsigned long flags; 384 395 unsigned long resolution = 0; 385 396 struct snd_timer_instance *ts; 386 - struct list_head *n; 387 397 struct timespec tstamp; 388 398 389 399 getnstimeofday(&tstamp); ··· 401 413 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE) 402 414 return; 403 415 spin_lock_irqsave(&timer->lock, flags); 404 - list_for_each(n, &ti->slave_active_head) { 405 - ts = list_entry(n, struct snd_timer_instance, active_list); 416 + list_for_each_entry(ts, &ti->slave_active_head, active_list) 406 417 if (ts->ccallback) 407 418 ts->ccallback(ti, event + 100, &tstamp, resolution); 408 - } 409 419 spin_unlock_irqrestore(&timer->lock, flags); 410 420 } 411 421 ··· 579 593 { 580 594 struct snd_timer_instance *ti; 581 595 unsigned long ticks = ~0UL; 582 - struct list_head *p; 583 596 584 - list_for_each(p, &timer->active_list_head) { 585 - ti = list_entry(p, struct snd_timer_instance, active_list); 597 + list_for_each_entry(ti, &timer->active_list_head, active_list) { 586 598 if (ti->flags & SNDRV_TIMER_IFLG_START) { 587 599 ti->flags &= ~SNDRV_TIMER_IFLG_START; 588 600 ti->flags |= SNDRV_TIMER_IFLG_RUNNING; ··· 645 661 */ 646 662 void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left) 647 663 { 648 - struct snd_timer_instance *ti, *ts; 664 + struct snd_timer_instance *ti, *ts, *tmp; 649 665 unsigned long resolution, ticks; 650 - struct list_head *p, *q, *n, *ack_list_head; 666 + struct list_head *p, *ack_list_head; 651 667 unsigned long flags; 652 668 int use_tasklet = 0; 653 669 ··· 663 679 resolution = timer->hw.resolution; 664 680 665 681 /* loop for all active instances 666 - * Here we cannot use list_for_each because the active_list of a 682 + * Here we cannot use list_for_each_entry because the active_list of a 667 683 * processed instance is relinked to done_list_head before the callback 668 684 * is called. 669 685 */ 670 - list_for_each_safe(p, n, &timer->active_list_head) { 671 - ti = list_entry(p, struct snd_timer_instance, active_list); 686 + list_for_each_entry_safe(ti, tmp, &timer->active_list_head, 687 + active_list) { 672 688 if (!(ti->flags & SNDRV_TIMER_IFLG_RUNNING)) 673 689 continue; 674 690 ti->pticks += ticks_left; ··· 684 700 } else { 685 701 ti->flags &= ~SNDRV_TIMER_IFLG_RUNNING; 686 702 if (--timer->running) 687 - list_del(p); 703 + list_del(&ti->active_list); 688 704 } 689 705 if ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) || 690 706 (ti->flags & SNDRV_TIMER_IFLG_FAST)) ··· 693 709 ack_list_head = &timer->sack_list_head; 694 710 if (list_empty(&ti->ack_list)) 695 711 list_add_tail(&ti->ack_list, ack_list_head); 696 - list_for_each(q, &ti->slave_active_head) { 697 - ts = list_entry(q, struct snd_timer_instance, active_list); 712 + list_for_each_entry(ts, &ti->slave_active_head, active_list) { 698 713 ts->pticks = ti->pticks; 699 714 ts->resolution = resolution; 700 715 if (list_empty(&ts->ack_list)) ··· 827 844 { 828 845 struct snd_timer *timer = dev->device_data; 829 846 struct snd_timer *timer1; 830 - struct list_head *p; 831 847 832 848 snd_assert(timer != NULL && timer->hw.start != NULL && 833 849 timer->hw.stop != NULL, return -ENXIO); ··· 835 853 return -EINVAL; 836 854 837 855 mutex_lock(&register_mutex); 838 - list_for_each(p, &snd_timer_list) { 839 - timer1 = list_entry(p, struct snd_timer, device_list); 856 + list_for_each_entry(timer1, &snd_timer_list, device_list) { 840 857 if (timer1->tmr_class > timer->tmr_class) 841 858 break; 842 859 if (timer1->tmr_class < timer->tmr_class) ··· 858 877 mutex_unlock(&register_mutex); 859 878 return -EBUSY; 860 879 } 861 - list_add_tail(&timer->device_list, p); 880 + list_add_tail(&timer->device_list, &timer1->device_list); 862 881 mutex_unlock(&register_mutex); 863 882 return 0; 864 883 } ··· 877 896 unsigned long flags; 878 897 unsigned long resolution = 0; 879 898 struct snd_timer_instance *ti, *ts; 880 - struct list_head *p, *n; 881 899 882 900 if (! (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)) 883 901 return; ··· 891 911 else 892 912 resolution = timer->hw.resolution; 893 913 } 894 - list_for_each(p, &timer->active_list_head) { 895 - ti = list_entry(p, struct snd_timer_instance, active_list); 914 + list_for_each_entry(ti, &timer->active_list_head, active_list) { 896 915 if (ti->ccallback) 897 916 ti->ccallback(ti, event, tstamp, resolution); 898 - list_for_each(n, &ti->slave_active_head) { 899 - ts = list_entry(n, struct snd_timer_instance, active_list); 917 + list_for_each_entry(ts, &ti->slave_active_head, active_list) 900 918 if (ts->ccallback) 901 919 ts->ccallback(ts, event, tstamp, resolution); 902 - } 903 920 } 904 921 spin_unlock_irqrestore(&timer->lock, flags); 905 922 } ··· 1034 1057 { 1035 1058 struct snd_timer *timer; 1036 1059 struct snd_timer_instance *ti; 1037 - struct list_head *p, *q; 1038 1060 1039 1061 mutex_lock(&register_mutex); 1040 - list_for_each(p, &snd_timer_list) { 1041 - timer = list_entry(p, struct snd_timer, device_list); 1062 + list_for_each_entry(timer, &snd_timer_list, device_list) { 1042 1063 switch (timer->tmr_class) { 1043 1064 case SNDRV_TIMER_CLASS_GLOBAL: 1044 1065 snd_iprintf(buffer, "G%i: ", timer->tmr_device); ··· 1063 1088 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE) 1064 1089 snd_iprintf(buffer, " SLAVE"); 1065 1090 snd_iprintf(buffer, "\n"); 1066 - list_for_each(q, &timer->open_list_head) { 1067 - ti = list_entry(q, struct snd_timer_instance, open_list); 1091 + list_for_each_entry(ti, &timer->open_list_head, open_list) 1068 1092 snd_iprintf(buffer, " Client %s : %s\n", 1069 1093 ti->owner ? ti->owner : "unknown", 1070 1094 ti->flags & (SNDRV_TIMER_IFLG_START | 1071 1095 SNDRV_TIMER_IFLG_RUNNING) 1072 1096 ? "running" : "stopped"); 1073 - } 1074 1097 } 1075 1098 mutex_unlock(&register_mutex); 1076 1099 }