aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/core/control.c37
-rw-r--r--sound/core/control_compat.c5
-rw-r--r--sound/core/device.c24
-rw-r--r--sound/core/hwdep.c10
-rw-r--r--sound/core/memalloc.c10
-rw-r--r--sound/core/pcm.c32
-rw-r--r--sound/core/rawmidi.c29
-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
-rw-r--r--sound/core/timer.c77
12 files changed, 102 insertions, 214 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 }
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index ab48962c48ce..9311ca397bbc 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -392,7 +392,7 @@ enum {
392static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) 392static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
393{ 393{
394 struct snd_ctl_file *ctl; 394 struct snd_ctl_file *ctl;
395 struct list_head *list; 395 struct snd_kctl_ioctl *p;
396 void __user *argp = compat_ptr(arg); 396 void __user *argp = compat_ptr(arg);
397 int err; 397 int err;
398 398
@@ -427,8 +427,7 @@ static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, uns
427 } 427 }
428 428
429 down_read(&snd_ioctl_rwsem); 429 down_read(&snd_ioctl_rwsem);
430 list_for_each(list, &snd_control_compat_ioctls) { 430 list_for_each_entry(p, &snd_control_compat_ioctls, list) {
431 struct snd_kctl_ioctl *p = list_entry(list, struct snd_kctl_ioctl, list);
432 if (p->fioctl) { 431 if (p->fioctl) {
433 err = p->fioctl(ctl->card, ctl, cmd, arg); 432 err = p->fioctl(ctl->card, ctl, cmd, arg);
434 if (err != -ENOIOCTLCMD) { 433 if (err != -ENOIOCTLCMD) {
diff --git a/sound/core/device.c b/sound/core/device.c
index ccb25816ac9e..5858b02b0b1d 100644
--- a/sound/core/device.c
+++ b/sound/core/device.c
@@ -79,13 +79,11 @@ EXPORT_SYMBOL(snd_device_new);
79 */ 79 */
80int snd_device_free(struct snd_card *card, void *device_data) 80int snd_device_free(struct snd_card *card, void *device_data)
81{ 81{
82 struct list_head *list;
83 struct snd_device *dev; 82 struct snd_device *dev;
84 83
85 snd_assert(card != NULL, return -ENXIO); 84 snd_assert(card != NULL, return -ENXIO);
86 snd_assert(device_data != NULL, return -ENXIO); 85 snd_assert(device_data != NULL, return -ENXIO);
87 list_for_each(list, &card->devices) { 86 list_for_each_entry(dev, &card->devices, list) {
88 dev = snd_device(list);
89 if (dev->device_data != device_data) 87 if (dev->device_data != device_data)
90 continue; 88 continue;
91 /* unlink */ 89 /* unlink */
@@ -124,13 +122,11 @@ EXPORT_SYMBOL(snd_device_free);
124 */ 122 */
125int snd_device_disconnect(struct snd_card *card, void *device_data) 123int snd_device_disconnect(struct snd_card *card, void *device_data)
126{ 124{
127 struct list_head *list;
128 struct snd_device *dev; 125 struct snd_device *dev;
129 126
130 snd_assert(card != NULL, return -ENXIO); 127 snd_assert(card != NULL, return -ENXIO);
131 snd_assert(device_data != NULL, return -ENXIO); 128 snd_assert(device_data != NULL, return -ENXIO);
132 list_for_each(list, &card->devices) { 129 list_for_each_entry(dev, &card->devices, list) {
133 dev = snd_device(list);
134 if (dev->device_data != device_data) 130 if (dev->device_data != device_data)
135 continue; 131 continue;
136 if (dev->state == SNDRV_DEV_REGISTERED && 132 if (dev->state == SNDRV_DEV_REGISTERED &&
@@ -161,14 +157,12 @@ int snd_device_disconnect(struct snd_card *card, void *device_data)
161 */ 157 */
162int snd_device_register(struct snd_card *card, void *device_data) 158int snd_device_register(struct snd_card *card, void *device_data)
163{ 159{
164 struct list_head *list;
165 struct snd_device *dev; 160 struct snd_device *dev;
166 int err; 161 int err;
167 162
168 snd_assert(card != NULL, return -ENXIO); 163 snd_assert(card != NULL, return -ENXIO);
169 snd_assert(device_data != NULL, return -ENXIO); 164 snd_assert(device_data != NULL, return -ENXIO);
170 list_for_each(list, &card->devices) { 165 list_for_each_entry(dev, &card->devices, list) {
171 dev = snd_device(list);
172 if (dev->device_data != device_data) 166 if (dev->device_data != device_data)
173 continue; 167 continue;
174 if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) { 168 if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
@@ -192,13 +186,11 @@ EXPORT_SYMBOL(snd_device_register);
192 */ 186 */
193int snd_device_register_all(struct snd_card *card) 187int snd_device_register_all(struct snd_card *card)
194{ 188{
195 struct list_head *list;
196 struct snd_device *dev; 189 struct snd_device *dev;
197 int err; 190 int err;
198 191
199 snd_assert(card != NULL, return -ENXIO); 192 snd_assert(card != NULL, return -ENXIO);
200 list_for_each(list, &card->devices) { 193 list_for_each_entry(dev, &card->devices, list) {
201 dev = snd_device(list);
202 if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) { 194 if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
203 if ((err = dev->ops->dev_register(dev)) < 0) 195 if ((err = dev->ops->dev_register(dev)) < 0)
204 return err; 196 return err;
@@ -215,12 +207,10 @@ int snd_device_register_all(struct snd_card *card)
215int snd_device_disconnect_all(struct snd_card *card) 207int snd_device_disconnect_all(struct snd_card *card)
216{ 208{
217 struct snd_device *dev; 209 struct snd_device *dev;
218 struct list_head *list;
219 int err = 0; 210 int err = 0;
220 211
221 snd_assert(card != NULL, return -ENXIO); 212 snd_assert(card != NULL, return -ENXIO);
222 list_for_each(list, &card->devices) { 213 list_for_each_entry(dev, &card->devices, list) {
223 dev = snd_device(list);
224 if (snd_device_disconnect(card, dev->device_data) < 0) 214 if (snd_device_disconnect(card, dev->device_data) < 0)
225 err = -ENXIO; 215 err = -ENXIO;
226 } 216 }
@@ -234,7 +224,6 @@ int snd_device_disconnect_all(struct snd_card *card)
234int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd) 224int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
235{ 225{
236 struct snd_device *dev; 226 struct snd_device *dev;
237 struct list_head *list;
238 int err; 227 int err;
239 unsigned int range_low, range_high; 228 unsigned int range_low, range_high;
240 229
@@ -242,8 +231,7 @@ int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
242 range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE; 231 range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE;
243 range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1; 232 range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1;
244 __again: 233 __again:
245 list_for_each(list, &card->devices) { 234 list_for_each_entry(dev, &card->devices, list) {
246 dev = snd_device(list);
247 if (dev->type >= range_low && dev->type <= range_high) { 235 if (dev->type >= range_low && dev->type <= range_high) {
248 if ((err = snd_device_free(card, dev->device_data)) < 0) 236 if ((err = snd_device_free(card, dev->device_data)) < 0)
249 return err; 237 return err;
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 46b47689362c..a6a6ad0ad3c8 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -47,14 +47,11 @@ static int snd_hwdep_dev_disconnect(struct snd_device *device);
47 47
48static struct snd_hwdep *snd_hwdep_search(struct snd_card *card, int device) 48static struct snd_hwdep *snd_hwdep_search(struct snd_card *card, int device)
49{ 49{
50 struct list_head *p;
51 struct snd_hwdep *hwdep; 50 struct snd_hwdep *hwdep;
52 51
53 list_for_each(p, &snd_hwdep_devices) { 52 list_for_each_entry(hwdep, &snd_hwdep_devices, list)
54 hwdep = list_entry(p, struct snd_hwdep, list);
55 if (hwdep->card == card && hwdep->device == device) 53 if (hwdep->card == card && hwdep->device == device)
56 return hwdep; 54 return hwdep;
57 }
58 return NULL; 55 return NULL;
59} 56}
60 57
@@ -468,15 +465,12 @@ static int snd_hwdep_dev_disconnect(struct snd_device *device)
468static void snd_hwdep_proc_read(struct snd_info_entry *entry, 465static void snd_hwdep_proc_read(struct snd_info_entry *entry,
469 struct snd_info_buffer *buffer) 466 struct snd_info_buffer *buffer)
470{ 467{
471 struct list_head *p;
472 struct snd_hwdep *hwdep; 468 struct snd_hwdep *hwdep;
473 469
474 mutex_lock(&register_mutex); 470 mutex_lock(&register_mutex);
475 list_for_each(p, &snd_hwdep_devices) { 471 list_for_each_entry(hwdep, &snd_hwdep_devices, list)
476 hwdep = list_entry(p, struct snd_hwdep, list);
477 snd_iprintf(buffer, "%02i-%02i: %s\n", 472 snd_iprintf(buffer, "%02i-%02i: %s\n",
478 hwdep->card->number, hwdep->device, hwdep->name); 473 hwdep->card->number, hwdep->device, hwdep->name);
479 }
480 mutex_unlock(&register_mutex); 474 mutex_unlock(&register_mutex);
481} 475}
482 476
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index bc0bd0910a62..f057430db0d0 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -406,19 +406,17 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab)
406 */ 406 */
407size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id) 407size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id)
408{ 408{
409 struct list_head *p;
410 struct snd_mem_list *mem; 409 struct snd_mem_list *mem;
411 410
412 snd_assert(dmab, return 0); 411 snd_assert(dmab, return 0);
413 412
414 mutex_lock(&list_mutex); 413 mutex_lock(&list_mutex);
415 list_for_each(p, &mem_list_head) { 414 list_for_each_entry(mem, &mem_list_head, list) {
416 mem = list_entry(p, struct snd_mem_list, list);
417 if (mem->id == id && 415 if (mem->id == id &&
418 (mem->buffer.dev.dev == NULL || dmab->dev.dev == NULL || 416 (mem->buffer.dev.dev == NULL || dmab->dev.dev == NULL ||
419 ! memcmp(&mem->buffer.dev, &dmab->dev, sizeof(dmab->dev)))) { 417 ! memcmp(&mem->buffer.dev, &dmab->dev, sizeof(dmab->dev)))) {
420 struct device *dev = dmab->dev.dev; 418 struct device *dev = dmab->dev.dev;
421 list_del(p); 419 list_del(&mem->list);
422 *dmab = mem->buffer; 420 *dmab = mem->buffer;
423 if (dmab->dev.dev == NULL) 421 if (dmab->dev.dev == NULL)
424 dmab->dev.dev = dev; 422 dmab->dev.dev = dev;
@@ -488,7 +486,6 @@ static int snd_mem_proc_read(char *page, char **start, off_t off,
488{ 486{
489 int len = 0; 487 int len = 0;
490 long pages = snd_allocated_pages >> (PAGE_SHIFT-12); 488 long pages = snd_allocated_pages >> (PAGE_SHIFT-12);
491 struct list_head *p;
492 struct snd_mem_list *mem; 489 struct snd_mem_list *mem;
493 int devno; 490 int devno;
494 static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" }; 491 static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" };
@@ -498,8 +495,7 @@ static int snd_mem_proc_read(char *page, char **start, off_t off,
498 "pages : %li bytes (%li pages per %likB)\n", 495 "pages : %li bytes (%li pages per %likB)\n",
499 pages * PAGE_SIZE, pages, PAGE_SIZE / 1024); 496 pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);
500 devno = 0; 497 devno = 0;
501 list_for_each(p, &mem_list_head) { 498 list_for_each_entry(mem, &mem_list_head, list) {
502 mem = list_entry(p, struct snd_mem_list, list);
503 devno++; 499 devno++;
504 len += snprintf(page + len, count - len, 500 len += snprintf(page + len, count - len,
505 "buffer %d : ID %08x : type %s\n", 501 "buffer %d : ID %08x : type %s\n",
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 4701f07ee0ae..76fcc5234d83 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -45,11 +45,9 @@ static int snd_pcm_dev_disconnect(struct snd_device *device);
45 45
46static struct snd_pcm *snd_pcm_search(struct snd_card *card, int device) 46static struct snd_pcm *snd_pcm_search(struct snd_card *card, int device)
47{ 47{
48 struct list_head *p;
49 struct snd_pcm *pcm; 48 struct snd_pcm *pcm;
50 49
51 list_for_each(p, &snd_pcm_devices) { 50 list_for_each_entry(pcm, &snd_pcm_devices, list) {
52 pcm = list_entry(p, struct snd_pcm, list);
53 if (pcm->card == card && pcm->device == device) 51 if (pcm->card == card && pcm->device == device)
54 return pcm; 52 return pcm;
55 } 53 }
@@ -782,7 +780,6 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
782 struct snd_pcm_runtime *runtime; 780 struct snd_pcm_runtime *runtime;
783 struct snd_ctl_file *kctl; 781 struct snd_ctl_file *kctl;
784 struct snd_card *card; 782 struct snd_card *card;
785 struct list_head *list;
786 int prefer_subdevice = -1; 783 int prefer_subdevice = -1;
787 size_t size; 784 size_t size;
788 785
@@ -795,8 +792,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
795 792
796 card = pcm->card; 793 card = pcm->card;
797 down_read(&card->controls_rwsem); 794 down_read(&card->controls_rwsem);
798 list_for_each(list, &card->ctl_files) { 795 list_for_each_entry(kctl, &card->ctl_files, list) {
799 kctl = snd_ctl_file(list);
800 if (kctl->pid == current->pid) { 796 if (kctl->pid == current->pid) {
801 prefer_subdevice = kctl->prefer_pcm_subdevice; 797 prefer_subdevice = kctl->prefer_pcm_subdevice;
802 if (prefer_subdevice != -1) 798 if (prefer_subdevice != -1)
@@ -941,7 +937,7 @@ static int snd_pcm_dev_register(struct snd_device *device)
941{ 937{
942 int cidx, err; 938 int cidx, err;
943 struct snd_pcm_substream *substream; 939 struct snd_pcm_substream *substream;
944 struct list_head *list; 940 struct snd_pcm_notify *notify;
945 char str[16]; 941 char str[16];
946 struct snd_pcm *pcm = device->device_data; 942 struct snd_pcm *pcm = device->device_data;
947 struct device *dev; 943 struct device *dev;
@@ -988,11 +984,10 @@ static int snd_pcm_dev_register(struct snd_device *device)
988 for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) 984 for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
989 snd_pcm_timer_init(substream); 985 snd_pcm_timer_init(substream);
990 } 986 }
991 list_for_each(list, &snd_pcm_notify_list) { 987
992 struct snd_pcm_notify *notify; 988 list_for_each_entry(notify, &snd_pcm_notify_list, list)
993 notify = list_entry(list, struct snd_pcm_notify, list);
994 notify->n_register(pcm); 989 notify->n_register(pcm);
995 } 990
996 mutex_unlock(&register_mutex); 991 mutex_unlock(&register_mutex);
997 return 0; 992 return 0;
998} 993}
@@ -1035,7 +1030,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
1035 1030
1036int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) 1031int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
1037{ 1032{
1038 struct list_head *p; 1033 struct snd_pcm *pcm;
1039 1034
1040 snd_assert(notify != NULL && 1035 snd_assert(notify != NULL &&
1041 notify->n_register != NULL && 1036 notify->n_register != NULL &&
@@ -1044,13 +1039,12 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
1044 mutex_lock(&register_mutex); 1039 mutex_lock(&register_mutex);
1045 if (nfree) { 1040 if (nfree) {
1046 list_del(&notify->list); 1041 list_del(&notify->list);
1047 list_for_each(p, &snd_pcm_devices) 1042 list_for_each_entry(pcm, &snd_pcm_devices, list)
1048 notify->n_unregister(list_entry(p, 1043 notify->n_unregister(pcm);
1049 struct snd_pcm, list));
1050 } else { 1044 } else {
1051 list_add_tail(&notify->list, &snd_pcm_notify_list); 1045 list_add_tail(&notify->list, &snd_pcm_notify_list);
1052 list_for_each(p, &snd_pcm_devices) 1046 list_for_each_entry(pcm, &snd_pcm_devices, list)
1053 notify->n_register(list_entry(p, struct snd_pcm, list)); 1047 notify->n_register(pcm);
1054 } 1048 }
1055 mutex_unlock(&register_mutex); 1049 mutex_unlock(&register_mutex);
1056 return 0; 1050 return 0;
@@ -1066,12 +1060,10 @@ EXPORT_SYMBOL(snd_pcm_notify);
1066static void snd_pcm_proc_read(struct snd_info_entry *entry, 1060static void snd_pcm_proc_read(struct snd_info_entry *entry,
1067 struct snd_info_buffer *buffer) 1061 struct snd_info_buffer *buffer)
1068{ 1062{
1069 struct list_head *p;
1070 struct snd_pcm *pcm; 1063 struct snd_pcm *pcm;
1071 1064
1072 mutex_lock(&register_mutex); 1065 mutex_lock(&register_mutex);
1073 list_for_each(p, &snd_pcm_devices) { 1066 list_for_each_entry(pcm, &snd_pcm_devices, list) {
1074 pcm = list_entry(p, struct snd_pcm, list);
1075 snd_iprintf(buffer, "%02i-%02i: %s : %s", 1067 snd_iprintf(buffer, "%02i-%02i: %s : %s",
1076 pcm->card->number, pcm->device, pcm->id, pcm->name); 1068 pcm->card->number, pcm->device, pcm->id, pcm->name);
1077 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) 1069 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 0f055bfcbdac..7e6ceec738d5 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -61,14 +61,11 @@ static DEFINE_MUTEX(register_mutex);
61 61
62static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) 62static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device)
63{ 63{
64 struct list_head *p;
65 struct snd_rawmidi *rawmidi; 64 struct snd_rawmidi *rawmidi;
66 65
67 list_for_each(p, &snd_rawmidi_devices) { 66 list_for_each_entry(rawmidi, &snd_rawmidi_devices, list)
68 rawmidi = list_entry(p, struct snd_rawmidi, list);
69 if (rawmidi->card == card && rawmidi->device == device) 67 if (rawmidi->card == card && rawmidi->device == device)
70 return rawmidi; 68 return rawmidi;
71 }
72 return NULL; 69 return NULL;
73} 70}
74 71
@@ -389,7 +386,6 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
389 struct snd_rawmidi *rmidi; 386 struct snd_rawmidi *rmidi;
390 struct snd_rawmidi_file *rawmidi_file; 387 struct snd_rawmidi_file *rawmidi_file;
391 wait_queue_t wait; 388 wait_queue_t wait;
392 struct list_head *list;
393 struct snd_ctl_file *kctl; 389 struct snd_ctl_file *kctl;
394 390
395 if (maj == snd_major) { 391 if (maj == snd_major) {
@@ -426,8 +422,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
426 while (1) { 422 while (1) {
427 subdevice = -1; 423 subdevice = -1;
428 down_read(&card->controls_rwsem); 424 down_read(&card->controls_rwsem);
429 list_for_each(list, &card->ctl_files) { 425 list_for_each_entry(kctl, &card->ctl_files, list) {
430 kctl = snd_ctl_file(list);
431 if (kctl->pid == current->pid) { 426 if (kctl->pid == current->pid) {
432 subdevice = kctl->prefer_rawmidi_subdevice; 427 subdevice = kctl->prefer_rawmidi_subdevice;
433 if (subdevice != -1) 428 if (subdevice != -1)
@@ -575,7 +570,6 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info
575 struct snd_rawmidi *rmidi; 570 struct snd_rawmidi *rmidi;
576 struct snd_rawmidi_str *pstr; 571 struct snd_rawmidi_str *pstr;
577 struct snd_rawmidi_substream *substream; 572 struct snd_rawmidi_substream *substream;
578 struct list_head *list;
579 573
580 mutex_lock(&register_mutex); 574 mutex_lock(&register_mutex);
581 rmidi = snd_rawmidi_search(card, info->device); 575 rmidi = snd_rawmidi_search(card, info->device);
@@ -589,8 +583,7 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info
589 return -ENOENT; 583 return -ENOENT;
590 if (info->subdevice >= pstr->substream_count) 584 if (info->subdevice >= pstr->substream_count)
591 return -ENXIO; 585 return -ENXIO;
592 list_for_each(list, &pstr->substreams) { 586 list_for_each_entry(substream, &pstr->substreams, list) {
593 substream = list_entry(list, struct snd_rawmidi_substream, list);
594 if ((unsigned int)substream->number == info->subdevice) 587 if ((unsigned int)substream->number == info->subdevice)
595 return snd_rawmidi_info(substream, info); 588 return snd_rawmidi_info(substream, info);
596 } 589 }
@@ -1313,14 +1306,14 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
1313 struct snd_rawmidi *rmidi; 1306 struct snd_rawmidi *rmidi;
1314 struct snd_rawmidi_substream *substream; 1307 struct snd_rawmidi_substream *substream;
1315 struct snd_rawmidi_runtime *runtime; 1308 struct snd_rawmidi_runtime *runtime;
1316 struct list_head *list;
1317 1309
1318 rmidi = entry->private_data; 1310 rmidi = entry->private_data;
1319 snd_iprintf(buffer, "%s\n\n", rmidi->name); 1311 snd_iprintf(buffer, "%s\n\n", rmidi->name);
1320 mutex_lock(&rmidi->open_mutex); 1312 mutex_lock(&rmidi->open_mutex);
1321 if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) { 1313 if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) {
1322 list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { 1314 list_for_each_entry(substream,
1323 substream = list_entry(list, struct snd_rawmidi_substream, list); 1315 &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams,
1316 list) {
1324 snd_iprintf(buffer, 1317 snd_iprintf(buffer,
1325 "Output %d\n" 1318 "Output %d\n"
1326 " Tx bytes : %lu\n", 1319 " Tx bytes : %lu\n",
@@ -1339,8 +1332,9 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
1339 } 1332 }
1340 } 1333 }
1341 if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT) { 1334 if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT) {
1342 list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams) { 1335 list_for_each_entry(substream,
1343 substream = list_entry(list, struct snd_rawmidi_substream, list); 1336 &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams,
1337 list) {
1344 snd_iprintf(buffer, 1338 snd_iprintf(buffer,
1345 "Input %d\n" 1339 "Input %d\n"
1346 " Rx bytes : %lu\n", 1340 " Rx bytes : %lu\n",
@@ -1625,13 +1619,10 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device)
1625void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream, 1619void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream,
1626 struct snd_rawmidi_ops *ops) 1620 struct snd_rawmidi_ops *ops)
1627{ 1621{
1628 struct list_head *list;
1629 struct snd_rawmidi_substream *substream; 1622 struct snd_rawmidi_substream *substream;
1630 1623
1631 list_for_each(list, &rmidi->streams[stream].substreams) { 1624 list_for_each_entry(substream, &rmidi->streams[stream].substreams, list)
1632 substream = list_entry(list, struct snd_rawmidi_substream, list);
1633 substream->ops = ops; 1625 substream->ops = ops;
1634 }
1635} 1626}
1636 1627
1637/* 1628/*
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) {
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 10a79aed33f8..4e79f9ce1a85 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -130,11 +130,8 @@ static struct snd_timer_instance *snd_timer_instance_new(char *owner,
130static struct snd_timer *snd_timer_find(struct snd_timer_id *tid) 130static struct snd_timer *snd_timer_find(struct snd_timer_id *tid)
131{ 131{
132 struct snd_timer *timer = NULL; 132 struct snd_timer *timer = NULL;
133 struct list_head *p;
134
135 list_for_each(p, &snd_timer_list) {
136 timer = list_entry(p, struct snd_timer, device_list);
137 133
134 list_for_each_entry(timer, &snd_timer_list, device_list) {
138 if (timer->tmr_class != tid->dev_class) 135 if (timer->tmr_class != tid->dev_class)
139 continue; 136 continue;
140 if ((timer->tmr_class == SNDRV_TIMER_CLASS_CARD || 137 if ((timer->tmr_class == SNDRV_TIMER_CLASS_CARD ||
@@ -184,13 +181,10 @@ static void snd_timer_check_slave(struct snd_timer_instance *slave)
184{ 181{
185 struct snd_timer *timer; 182 struct snd_timer *timer;
186 struct snd_timer_instance *master; 183 struct snd_timer_instance *master;
187 struct list_head *p, *q;
188 184
189 /* FIXME: it's really dumb to look up all entries.. */ 185 /* FIXME: it's really dumb to look up all entries.. */
190 list_for_each(p, &snd_timer_list) { 186 list_for_each_entry(timer, &snd_timer_list, device_list) {
191 timer = list_entry(p, struct snd_timer, device_list); 187 list_for_each_entry(master, &timer->open_list_head, open_list) {
192 list_for_each(q, &timer->open_list_head) {
193 master = list_entry(q, struct snd_timer_instance, open_list);
194 if (slave->slave_class == master->slave_class && 188 if (slave->slave_class == master->slave_class &&
195 slave->slave_id == master->slave_id) { 189 slave->slave_id == master->slave_id) {
196 list_del(&slave->open_list); 190 list_del(&slave->open_list);
@@ -214,16 +208,13 @@ static void snd_timer_check_slave(struct snd_timer_instance *slave)
214 */ 208 */
215static void snd_timer_check_master(struct snd_timer_instance *master) 209static void snd_timer_check_master(struct snd_timer_instance *master)
216{ 210{
217 struct snd_timer_instance *slave; 211 struct snd_timer_instance *slave, *tmp;
218 struct list_head *p, *n;
219 212
220 /* check all pending slaves */ 213 /* check all pending slaves */
221 list_for_each_safe(p, n, &snd_timer_slave_list) { 214 list_for_each_entry_safe(slave, tmp, &snd_timer_slave_list, open_list) {
222 slave = list_entry(p, struct snd_timer_instance, open_list);
223 if (slave->slave_class == master->slave_class && 215 if (slave->slave_class == master->slave_class &&
224 slave->slave_id == master->slave_id) { 216 slave->slave_id == master->slave_id) {
225 list_del(p); 217 list_move_tail(&slave->open_list, &master->slave_list_head);
226 list_add_tail(p, &master->slave_list_head);
227 spin_lock_irq(&slave_active_lock); 218 spin_lock_irq(&slave_active_lock);
228 slave->master = master; 219 slave->master = master;
229 slave->timer = master->timer; 220 slave->timer = master->timer;
@@ -317,8 +308,7 @@ static int _snd_timer_stop(struct snd_timer_instance *timeri,
317int snd_timer_close(struct snd_timer_instance *timeri) 308int snd_timer_close(struct snd_timer_instance *timeri)
318{ 309{
319 struct snd_timer *timer = NULL; 310 struct snd_timer *timer = NULL;
320 struct list_head *p, *n; 311 struct snd_timer_instance *slave, *tmp;
321 struct snd_timer_instance *slave;
322 312
323 snd_assert(timeri != NULL, return -ENXIO); 313 snd_assert(timeri != NULL, return -ENXIO);
324 314
@@ -353,12 +343,11 @@ int snd_timer_close(struct snd_timer_instance *timeri)
353 timer->hw.close) 343 timer->hw.close)
354 timer->hw.close(timer); 344 timer->hw.close(timer);
355 /* remove slave links */ 345 /* remove slave links */
356 list_for_each_safe(p, n, &timeri->slave_list_head) { 346 list_for_each_entry_safe(slave, tmp, &timeri->slave_list_head,
357 slave = list_entry(p, struct snd_timer_instance, open_list); 347 open_list) {
358 spin_lock_irq(&slave_active_lock); 348 spin_lock_irq(&slave_active_lock);
359 _snd_timer_stop(slave, 1, SNDRV_TIMER_EVENT_RESOLUTION); 349 _snd_timer_stop(slave, 1, SNDRV_TIMER_EVENT_RESOLUTION);
360 list_del(p); 350 list_move_tail(&slave->open_list, &snd_timer_slave_list);
361 list_add_tail(p, &snd_timer_slave_list);
362 slave->master = NULL; 351 slave->master = NULL;
363 slave->timer = NULL; 352 slave->timer = NULL;
364 spin_unlock_irq(&slave_active_lock); 353 spin_unlock_irq(&slave_active_lock);
@@ -394,7 +383,6 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
394 unsigned long flags; 383 unsigned long flags;
395 unsigned long resolution = 0; 384 unsigned long resolution = 0;
396 struct snd_timer_instance *ts; 385 struct snd_timer_instance *ts;
397 struct list_head *n;
398 struct timespec tstamp; 386 struct timespec tstamp;
399 387
400 getnstimeofday(&tstamp); 388 getnstimeofday(&tstamp);
@@ -413,11 +401,9 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
413 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE) 401 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
414 return; 402 return;
415 spin_lock_irqsave(&timer->lock, flags); 403 spin_lock_irqsave(&timer->lock, flags);
416 list_for_each(n, &ti->slave_active_head) { 404 list_for_each_entry(ts, &ti->slave_active_head, active_list)
417 ts = list_entry(n, struct snd_timer_instance, active_list);
418 if (ts->ccallback) 405 if (ts->ccallback)
419 ts->ccallback(ti, event + 100, &tstamp, resolution); 406 ts->ccallback(ti, event + 100, &tstamp, resolution);
420 }
421 spin_unlock_irqrestore(&timer->lock, flags); 407 spin_unlock_irqrestore(&timer->lock, flags);
422} 408}
423 409
@@ -593,10 +579,8 @@ static void snd_timer_reschedule(struct snd_timer * timer, unsigned long ticks_l
593{ 579{
594 struct snd_timer_instance *ti; 580 struct snd_timer_instance *ti;
595 unsigned long ticks = ~0UL; 581 unsigned long ticks = ~0UL;
596 struct list_head *p;
597 582
598 list_for_each(p, &timer->active_list_head) { 583 list_for_each_entry(ti, &timer->active_list_head, active_list) {
599 ti = list_entry(p, struct snd_timer_instance, active_list);
600 if (ti->flags & SNDRV_TIMER_IFLG_START) { 584 if (ti->flags & SNDRV_TIMER_IFLG_START) {
601 ti->flags &= ~SNDRV_TIMER_IFLG_START; 585 ti->flags &= ~SNDRV_TIMER_IFLG_START;
602 ti->flags |= SNDRV_TIMER_IFLG_RUNNING; 586 ti->flags |= SNDRV_TIMER_IFLG_RUNNING;
@@ -661,9 +645,9 @@ static void snd_timer_tasklet(unsigned long arg)
661 */ 645 */
662void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left) 646void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
663{ 647{
664 struct snd_timer_instance *ti, *ts; 648 struct snd_timer_instance *ti, *ts, *tmp;
665 unsigned long resolution, ticks; 649 unsigned long resolution, ticks;
666 struct list_head *p, *q, *n, *ack_list_head; 650 struct list_head *p, *ack_list_head;
667 unsigned long flags; 651 unsigned long flags;
668 int use_tasklet = 0; 652 int use_tasklet = 0;
669 653
@@ -679,12 +663,12 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
679 resolution = timer->hw.resolution; 663 resolution = timer->hw.resolution;
680 664
681 /* loop for all active instances 665 /* loop for all active instances
682 * Here we cannot use list_for_each because the active_list of a 666 * Here we cannot use list_for_each_entry because the active_list of a
683 * processed instance is relinked to done_list_head before the callback 667 * processed instance is relinked to done_list_head before the callback
684 * is called. 668 * is called.
685 */ 669 */
686 list_for_each_safe(p, n, &timer->active_list_head) { 670 list_for_each_entry_safe(ti, tmp, &timer->active_list_head,
687 ti = list_entry(p, struct snd_timer_instance, active_list); 671 active_list) {
688 if (!(ti->flags & SNDRV_TIMER_IFLG_RUNNING)) 672 if (!(ti->flags & SNDRV_TIMER_IFLG_RUNNING))
689 continue; 673 continue;
690 ti->pticks += ticks_left; 674 ti->pticks += ticks_left;
@@ -700,7 +684,7 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
700 } else { 684 } else {
701 ti->flags &= ~SNDRV_TIMER_IFLG_RUNNING; 685 ti->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
702 if (--timer->running) 686 if (--timer->running)
703 list_del(p); 687 list_del(&ti->active_list);
704 } 688 }
705 if ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) || 689 if ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) ||
706 (ti->flags & SNDRV_TIMER_IFLG_FAST)) 690 (ti->flags & SNDRV_TIMER_IFLG_FAST))
@@ -709,8 +693,7 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
709 ack_list_head = &timer->sack_list_head; 693 ack_list_head = &timer->sack_list_head;
710 if (list_empty(&ti->ack_list)) 694 if (list_empty(&ti->ack_list))
711 list_add_tail(&ti->ack_list, ack_list_head); 695 list_add_tail(&ti->ack_list, ack_list_head);
712 list_for_each(q, &ti->slave_active_head) { 696 list_for_each_entry(ts, &ti->slave_active_head, active_list) {
713 ts = list_entry(q, struct snd_timer_instance, active_list);
714 ts->pticks = ti->pticks; 697 ts->pticks = ti->pticks;
715 ts->resolution = resolution; 698 ts->resolution = resolution;
716 if (list_empty(&ts->ack_list)) 699 if (list_empty(&ts->ack_list))
@@ -844,7 +827,6 @@ static int snd_timer_dev_register(struct snd_device *dev)
844{ 827{
845 struct snd_timer *timer = dev->device_data; 828 struct snd_timer *timer = dev->device_data;
846 struct snd_timer *timer1; 829 struct snd_timer *timer1;
847 struct list_head *p;
848 830
849 snd_assert(timer != NULL && timer->hw.start != NULL && 831 snd_assert(timer != NULL && timer->hw.start != NULL &&
850 timer->hw.stop != NULL, return -ENXIO); 832 timer->hw.stop != NULL, return -ENXIO);
@@ -853,8 +835,7 @@ static int snd_timer_dev_register(struct snd_device *dev)
853 return -EINVAL; 835 return -EINVAL;
854 836
855 mutex_lock(&register_mutex); 837 mutex_lock(&register_mutex);
856 list_for_each(p, &snd_timer_list) { 838 list_for_each_entry(timer1, &snd_timer_list, device_list) {
857 timer1 = list_entry(p, struct snd_timer, device_list);
858 if (timer1->tmr_class > timer->tmr_class) 839 if (timer1->tmr_class > timer->tmr_class)
859 break; 840 break;
860 if (timer1->tmr_class < timer->tmr_class) 841 if (timer1->tmr_class < timer->tmr_class)
@@ -877,7 +858,7 @@ static int snd_timer_dev_register(struct snd_device *dev)
877 mutex_unlock(&register_mutex); 858 mutex_unlock(&register_mutex);
878 return -EBUSY; 859 return -EBUSY;
879 } 860 }
880 list_add_tail(&timer->device_list, p); 861 list_add_tail(&timer->device_list, &timer1->device_list);
881 mutex_unlock(&register_mutex); 862 mutex_unlock(&register_mutex);
882 return 0; 863 return 0;
883} 864}
@@ -896,7 +877,6 @@ void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstam
896 unsigned long flags; 877 unsigned long flags;
897 unsigned long resolution = 0; 878 unsigned long resolution = 0;
898 struct snd_timer_instance *ti, *ts; 879 struct snd_timer_instance *ti, *ts;
899 struct list_head *p, *n;
900 880
901 if (! (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)) 881 if (! (timer->hw.flags & SNDRV_TIMER_HW_SLAVE))
902 return; 882 return;
@@ -911,15 +891,12 @@ void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstam
911 else 891 else
912 resolution = timer->hw.resolution; 892 resolution = timer->hw.resolution;
913 } 893 }
914 list_for_each(p, &timer->active_list_head) { 894 list_for_each_entry(ti, &timer->active_list_head, active_list) {
915 ti = list_entry(p, struct snd_timer_instance, active_list);
916 if (ti->ccallback) 895 if (ti->ccallback)
917 ti->ccallback(ti, event, tstamp, resolution); 896 ti->ccallback(ti, event, tstamp, resolution);
918 list_for_each(n, &ti->slave_active_head) { 897 list_for_each_entry(ts, &ti->slave_active_head, active_list)
919 ts = list_entry(n, struct snd_timer_instance, active_list);
920 if (ts->ccallback) 898 if (ts->ccallback)
921 ts->ccallback(ts, event, tstamp, resolution); 899 ts->ccallback(ts, event, tstamp, resolution);
922 }
923 } 900 }
924 spin_unlock_irqrestore(&timer->lock, flags); 901 spin_unlock_irqrestore(&timer->lock, flags);
925} 902}
@@ -1057,11 +1034,9 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
1057{ 1034{
1058 struct snd_timer *timer; 1035 struct snd_timer *timer;
1059 struct snd_timer_instance *ti; 1036 struct snd_timer_instance *ti;
1060 struct list_head *p, *q;
1061 1037
1062 mutex_lock(&register_mutex); 1038 mutex_lock(&register_mutex);
1063 list_for_each(p, &snd_timer_list) { 1039 list_for_each_entry(timer, &snd_timer_list, device_list) {
1064 timer = list_entry(p, struct snd_timer, device_list);
1065 switch (timer->tmr_class) { 1040 switch (timer->tmr_class) {
1066 case SNDRV_TIMER_CLASS_GLOBAL: 1041 case SNDRV_TIMER_CLASS_GLOBAL:
1067 snd_iprintf(buffer, "G%i: ", timer->tmr_device); 1042 snd_iprintf(buffer, "G%i: ", timer->tmr_device);
@@ -1088,14 +1063,12 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
1088 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE) 1063 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
1089 snd_iprintf(buffer, " SLAVE"); 1064 snd_iprintf(buffer, " SLAVE");
1090 snd_iprintf(buffer, "\n"); 1065 snd_iprintf(buffer, "\n");
1091 list_for_each(q, &timer->open_list_head) { 1066 list_for_each_entry(ti, &timer->open_list_head, open_list)
1092 ti = list_entry(q, struct snd_timer_instance, open_list);
1093 snd_iprintf(buffer, " Client %s : %s\n", 1067 snd_iprintf(buffer, " Client %s : %s\n",
1094 ti->owner ? ti->owner : "unknown", 1068 ti->owner ? ti->owner : "unknown",
1095 ti->flags & (SNDRV_TIMER_IFLG_START | 1069 ti->flags & (SNDRV_TIMER_IFLG_START |
1096 SNDRV_TIMER_IFLG_RUNNING) 1070 SNDRV_TIMER_IFLG_RUNNING)
1097 ? "running" : "stopped"); 1071 ? "running" : "stopped");
1098 }
1099 } 1072 }
1100 mutex_unlock(&register_mutex); 1073 mutex_unlock(&register_mutex);
1101} 1074}