aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/pcm.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2006-10-05 10:02:22 -0400
committerJaroslav Kysela <perex@suse.cz>2007-02-09 03:00:10 -0500
commit9244b2c3079faac79b3b961116bd548c45087e2c (patch)
tree1a9e2ead054ed58efcad3fd43fb2aedeb6731baa /sound/core/pcm.c
parentd595ee7e0162ae66faa8c4c7d8c2069b40d64fed (diff)
[ALSA] alsa core: convert to list_for_each_entry*
This patch converts most uses of list_for_each to list_for_each_entry all across alsa. In some place apparently an item can be on a list with different pointers so of course that isn't compatible with list_for_each, I therefore didn't touch those places. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/core/pcm.c')
-rw-r--r--sound/core/pcm.c32
1 files changed, 12 insertions, 20 deletions
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)