diff options
| author | Takashi Iwai <tiwai@suse.de> | 2015-02-27 12:01:22 -0500 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2015-03-03 05:26:28 -0500 |
| commit | e086e3035e0691b362755d1b5e24df631eee335a (patch) | |
| tree | b803d38bb739c3de78d7ed74fd99b397fa9ecfe7 /sound/core | |
| parent | 61ca4107a16828559e2463e49b87002990da0b98 (diff) | |
ALSA: core: Re-add snd_device_disconnect()
Revive snd_device_disconnect() again so that it can be called from the
individual driver. This time, HD-audio will need it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
| -rw-r--r-- | sound/core/device.c | 43 | ||||
| -rw-r--r-- | sound/core/init.c | 5 |
2 files changed, 34 insertions, 14 deletions
diff --git a/sound/core/device.c b/sound/core/device.c index 41bec3075ae5..446dc452654e 100644 --- a/sound/core/device.c +++ b/sound/core/device.c | |||
| @@ -73,7 +73,7 @@ int snd_device_new(struct snd_card *card, enum snd_device_type type, | |||
| 73 | } | 73 | } |
| 74 | EXPORT_SYMBOL(snd_device_new); | 74 | EXPORT_SYMBOL(snd_device_new); |
| 75 | 75 | ||
| 76 | static int __snd_device_disconnect(struct snd_device *dev) | 76 | static void __snd_device_disconnect(struct snd_device *dev) |
| 77 | { | 77 | { |
| 78 | if (dev->state == SNDRV_DEV_REGISTERED) { | 78 | if (dev->state == SNDRV_DEV_REGISTERED) { |
| 79 | if (dev->ops->dev_disconnect && | 79 | if (dev->ops->dev_disconnect && |
| @@ -81,7 +81,6 @@ static int __snd_device_disconnect(struct snd_device *dev) | |||
| 81 | dev_err(dev->card->dev, "device disconnect failure\n"); | 81 | dev_err(dev->card->dev, "device disconnect failure\n"); |
| 82 | dev->state = SNDRV_DEV_DISCONNECTED; | 82 | dev->state = SNDRV_DEV_DISCONNECTED; |
| 83 | } | 83 | } |
| 84 | return 0; | ||
| 85 | } | 84 | } |
| 86 | 85 | ||
| 87 | static void __snd_device_free(struct snd_device *dev) | 86 | static void __snd_device_free(struct snd_device *dev) |
| @@ -109,6 +108,34 @@ static struct snd_device *look_for_dev(struct snd_card *card, void *device_data) | |||
| 109 | } | 108 | } |
| 110 | 109 | ||
| 111 | /** | 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 | */ | ||
| 123 | void 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 | } | ||
| 136 | EXPORT_SYMBOL_GPL(snd_device_disconnect); | ||
| 137 | |||
| 138 | /** | ||
| 112 | * snd_device_free - release the device from the card | 139 | * snd_device_free - release the device from the card |
| 113 | * @card: the card instance | 140 | * @card: the card instance |
| 114 | * @device_data: the data pointer to release | 141 | * @device_data: the data pointer to release |
| @@ -195,18 +222,14 @@ int snd_device_register_all(struct snd_card *card) | |||
| 195 | * disconnect all the devices on the card. | 222 | * disconnect all the devices on the card. |
| 196 | * called from init.c | 223 | * called from init.c |
| 197 | */ | 224 | */ |
| 198 | int snd_device_disconnect_all(struct snd_card *card) | 225 | void snd_device_disconnect_all(struct snd_card *card) |
| 199 | { | 226 | { |
| 200 | struct snd_device *dev; | 227 | struct snd_device *dev; |
| 201 | int err = 0; | ||
| 202 | 228 | ||
| 203 | if (snd_BUG_ON(!card)) | 229 | if (snd_BUG_ON(!card)) |
| 204 | return -ENXIO; | 230 | return; |
| 205 | list_for_each_entry_reverse(dev, &card->devices, list) { | 231 | list_for_each_entry_reverse(dev, &card->devices, list) |
| 206 | if (__snd_device_disconnect(dev) < 0) | 232 | __snd_device_disconnect(dev); |
| 207 | err = -ENXIO; | ||
| 208 | } | ||
| 209 | return err; | ||
| 210 | } | 233 | } |
| 211 | 234 | ||
| 212 | /* | 235 | /* |
diff --git a/sound/core/init.c b/sound/core/init.c index 35419054821c..04734e047bfe 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
| @@ -400,7 +400,6 @@ static const struct file_operations snd_shutdown_f_ops = | |||
| 400 | int snd_card_disconnect(struct snd_card *card) | 400 | int snd_card_disconnect(struct snd_card *card) |
| 401 | { | 401 | { |
| 402 | struct snd_monitor_file *mfile; | 402 | struct snd_monitor_file *mfile; |
| 403 | int err; | ||
| 404 | 403 | ||
| 405 | if (!card) | 404 | if (!card) |
| 406 | return -EINVAL; | 405 | return -EINVAL; |
| @@ -445,9 +444,7 @@ int snd_card_disconnect(struct snd_card *card) | |||
| 445 | #endif | 444 | #endif |
| 446 | 445 | ||
| 447 | /* notify all devices that we are disconnected */ | 446 | /* notify all devices that we are disconnected */ |
| 448 | err = snd_device_disconnect_all(card); | 447 | snd_device_disconnect_all(card); |
| 449 | if (err < 0) | ||
| 450 | dev_err(card->dev, "not all devices for card %i can be disconnected\n", card->number); | ||
| 451 | 448 | ||
| 452 | snd_info_card_disconnect(card); | 449 | snd_info_card_disconnect(card); |
| 453 | if (card->registered) { | 450 | if (card->registered) { |
