diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2006-10-05 10:02:22 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2007-02-09 03:00:10 -0500 |
commit | 9244b2c3079faac79b3b961116bd548c45087e2c (patch) | |
tree | 1a9e2ead054ed58efcad3fd43fb2aedeb6731baa /sound/core/device.c | |
parent | d595ee7e0162ae66faa8c4c7d8c2069b40d64fed (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/device.c')
-rw-r--r-- | sound/core/device.c | 24 |
1 files changed, 6 insertions, 18 deletions
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 | */ |
80 | int snd_device_free(struct snd_card *card, void *device_data) | 80 | int 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 | */ |
125 | int snd_device_disconnect(struct snd_card *card, void *device_data) | 123 | int 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 | */ |
162 | int snd_device_register(struct snd_card *card, void *device_data) | 158 | int 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 | */ |
193 | int snd_device_register_all(struct snd_card *card) | 187 | int 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) | |||
215 | int snd_device_disconnect_all(struct snd_card *card) | 207 | int 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) | |||
234 | int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd) | 224 | int 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; |