device.c (f01387d2693813eb5271a3448e6a082322c7d75d) | device.c (e086e3035e0691b362755d1b5e24df631eee335a) |
---|---|
1/* 2 * Device management routines 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 4 * 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 59 unchanged lines hidden (view full) --- 68 break; 69 } 70 71 list_add(&dev->list, p); 72 return 0; 73} 74EXPORT_SYMBOL(snd_device_new); 75 | 1/* 2 * Device management routines 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 4 * 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 59 unchanged lines hidden (view full) --- 68 break; 69 } 70 71 list_add(&dev->list, p); 72 return 0; 73} 74EXPORT_SYMBOL(snd_device_new); 75 |
76static int __snd_device_disconnect(struct snd_device *dev) | 76static void __snd_device_disconnect(struct snd_device *dev) |
77{ 78 if (dev->state == SNDRV_DEV_REGISTERED) { 79 if (dev->ops->dev_disconnect && 80 dev->ops->dev_disconnect(dev)) 81 dev_err(dev->card->dev, "device disconnect failure\n"); 82 dev->state = SNDRV_DEV_DISCONNECTED; 83 } | 77{ 78 if (dev->state == SNDRV_DEV_REGISTERED) { 79 if (dev->ops->dev_disconnect && 80 dev->ops->dev_disconnect(dev)) 81 dev_err(dev->card->dev, "device disconnect failure\n"); 82 dev->state = SNDRV_DEV_DISCONNECTED; 83 } |
84 return 0; | |
85} 86 87static void __snd_device_free(struct snd_device *dev) 88{ 89 /* unlink */ 90 list_del(&dev->list); 91 92 __snd_device_disconnect(dev); --- 11 unchanged lines hidden (view full) --- 104 list_for_each_entry(dev, &card->devices, list) 105 if (dev->device_data == device_data) 106 return dev; 107 108 return NULL; 109} 110 111/** | 84} 85 86static void __snd_device_free(struct snd_device *dev) 87{ 88 /* unlink */ 89 list_del(&dev->list); 90 91 __snd_device_disconnect(dev); --- 11 unchanged lines hidden (view full) --- 103 list_for_each_entry(dev, &card->devices, list) 104 if (dev->device_data == device_data) 105 return dev; 106 107 return NULL; 108} 109 110/** |
111 * snd_device_disconnect - disconnect the device 112 * @card: the card instance 113 * @device_data: the data pointer to disconnect 114 * 115 * Turns the device into the disconnection state, invoking 116 * dev_disconnect callback, if the device was already registered. 117 * 118 * Usually called from snd_card_disconnect(). 119 * 120 * Return: Zero if successful, or a negative error code on failure or if the 121 * device not found. 122 */ 123void snd_device_disconnect(struct snd_card *card, void *device_data) 124{ 125 struct snd_device *dev; 126 127 if (snd_BUG_ON(!card || !device_data)) 128 return; 129 dev = look_for_dev(card, device_data); 130 if (dev) 131 __snd_device_disconnect(dev); 132 else 133 dev_dbg(card->dev, "device disconnect %p (from %pF), not found\n", 134 device_data, __builtin_return_address(0)); 135} 136EXPORT_SYMBOL_GPL(snd_device_disconnect); 137 138/** |
|
112 * snd_device_free - release the device from the card 113 * @card: the card instance 114 * @device_data: the data pointer to release 115 * 116 * Removes the device from the list on the card and invokes the 117 * callbacks, dev_disconnect and dev_free, corresponding to the state. 118 * Then release the device. 119 */ --- 70 unchanged lines hidden (view full) --- 190 } 191 return 0; 192} 193 194/* 195 * disconnect all the devices on the card. 196 * called from init.c 197 */ | 139 * snd_device_free - release the device from the card 140 * @card: the card instance 141 * @device_data: the data pointer to release 142 * 143 * Removes the device from the list on the card and invokes the 144 * callbacks, dev_disconnect and dev_free, corresponding to the state. 145 * Then release the device. 146 */ --- 70 unchanged lines hidden (view full) --- 217 } 218 return 0; 219} 220 221/* 222 * disconnect all the devices on the card. 223 * called from init.c 224 */ |
198int snd_device_disconnect_all(struct snd_card *card) | 225void snd_device_disconnect_all(struct snd_card *card) |
199{ 200 struct snd_device *dev; | 226{ 227 struct snd_device *dev; |
201 int err = 0; | |
202 203 if (snd_BUG_ON(!card)) | 228 229 if (snd_BUG_ON(!card)) |
204 return -ENXIO; 205 list_for_each_entry_reverse(dev, &card->devices, list) { 206 if (__snd_device_disconnect(dev) < 0) 207 err = -ENXIO; 208 } 209 return err; | 230 return; 231 list_for_each_entry_reverse(dev, &card->devices, list) 232 __snd_device_disconnect(dev); |
210} 211 212/* 213 * release all the devices on the card. 214 * called from init.c 215 */ 216void snd_device_free_all(struct snd_card *card) 217{ 218 struct snd_device *dev, *next; 219 220 if (snd_BUG_ON(!card)) 221 return; 222 list_for_each_entry_safe_reverse(dev, next, &card->devices, list) 223 __snd_device_free(dev); 224} | 233} 234 235/* 236 * release all the devices on the card. 237 * called from init.c 238 */ 239void snd_device_free_all(struct snd_card *card) 240{ 241 struct snd_device *dev, *next; 242 243 if (snd_BUG_ON(!card)) 244 return; 245 list_for_each_entry_safe_reverse(dev, next, &card->devices, list) 246 __snd_device_free(dev); 247} |