aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-03-16 09:48:20 -0400
committerTakashi Iwai <tiwai@suse.de>2015-03-16 09:48:20 -0400
commit2a557a861ae44e1941452bc2d700f1be58c1325b (patch)
treed98a4731e5ead58134d231590047904afa6c37da /sound/core
parent8f88f0256f2e8afd83177b3554992009acb98996 (diff)
parentb2a0bafa758256442e04d1f34d6d0746b846d23d (diff)
Merge branch 'topic/hda-unbind' into for-next
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/device.c43
-rw-r--r--sound/core/init.c5
2 files changed, 34 insertions, 14 deletions
diff --git a/sound/core/device.c b/sound/core/device.c
index c1a845b42a8b..8918838b1999 100644
--- a/sound/core/device.c
+++ b/sound/core/device.c
@@ -71,7 +71,7 @@ int snd_device_new(struct snd_card *card, enum snd_device_type type,
71} 71}
72EXPORT_SYMBOL(snd_device_new); 72EXPORT_SYMBOL(snd_device_new);
73 73
74static int __snd_device_disconnect(struct snd_device *dev) 74static void __snd_device_disconnect(struct snd_device *dev)
75{ 75{
76 if (dev->state == SNDRV_DEV_REGISTERED) { 76 if (dev->state == SNDRV_DEV_REGISTERED) {
77 if (dev->ops->dev_disconnect && 77 if (dev->ops->dev_disconnect &&
@@ -79,7 +79,6 @@ static int __snd_device_disconnect(struct snd_device *dev)
79 dev_err(dev->card->dev, "device disconnect failure\n"); 79 dev_err(dev->card->dev, "device disconnect failure\n");
80 dev->state = SNDRV_DEV_DISCONNECTED; 80 dev->state = SNDRV_DEV_DISCONNECTED;
81 } 81 }
82 return 0;
83} 82}
84 83
85static void __snd_device_free(struct snd_device *dev) 84static void __snd_device_free(struct snd_device *dev)
@@ -107,6 +106,34 @@ static struct snd_device *look_for_dev(struct snd_card *card, void *device_data)
107} 106}
108 107
109/** 108/**
109 * snd_device_disconnect - disconnect the device
110 * @card: the card instance
111 * @device_data: the data pointer to disconnect
112 *
113 * Turns the device into the disconnection state, invoking
114 * dev_disconnect callback, if the device was already registered.
115 *
116 * Usually called from snd_card_disconnect().
117 *
118 * Return: Zero if successful, or a negative error code on failure or if the
119 * device not found.
120 */
121void snd_device_disconnect(struct snd_card *card, void *device_data)
122{
123 struct snd_device *dev;
124
125 if (snd_BUG_ON(!card || !device_data))
126 return;
127 dev = look_for_dev(card, device_data);
128 if (dev)
129 __snd_device_disconnect(dev);
130 else
131 dev_dbg(card->dev, "device disconnect %p (from %pF), not found\n",
132 device_data, __builtin_return_address(0));
133}
134EXPORT_SYMBOL_GPL(snd_device_disconnect);
135
136/**
110 * snd_device_free - release the device from the card 137 * snd_device_free - release the device from the card
111 * @card: the card instance 138 * @card: the card instance
112 * @device_data: the data pointer to release 139 * @device_data: the data pointer to release
@@ -193,18 +220,14 @@ int snd_device_register_all(struct snd_card *card)
193 * disconnect all the devices on the card. 220 * disconnect all the devices on the card.
194 * called from init.c 221 * called from init.c
195 */ 222 */
196int snd_device_disconnect_all(struct snd_card *card) 223void snd_device_disconnect_all(struct snd_card *card)
197{ 224{
198 struct snd_device *dev; 225 struct snd_device *dev;
199 int err = 0;
200 226
201 if (snd_BUG_ON(!card)) 227 if (snd_BUG_ON(!card))
202 return -ENXIO; 228 return;
203 list_for_each_entry_reverse(dev, &card->devices, list) { 229 list_for_each_entry_reverse(dev, &card->devices, list)
204 if (__snd_device_disconnect(dev) < 0) 230 __snd_device_disconnect(dev);
205 err = -ENXIO;
206 }
207 return err;
208} 231}
209 232
210/* 233/*
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 =
400int snd_card_disconnect(struct snd_card *card) 400int 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) {