summaryrefslogtreecommitdiff
path: root/sound/core/device.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-03-16 14:48:20 +0100
committerTakashi Iwai <tiwai@suse.de>2015-03-16 14:48:20 +0100
commit2a557a861ae44e1941452bc2d700f1be58c1325b (patch)
treed98a4731e5ead58134d231590047904afa6c37da /sound/core/device.c
parent8f88f0256f2e8afd83177b3554992009acb98996 (diff)
parentb2a0bafa758256442e04d1f34d6d0746b846d23d (diff)
Merge branch 'topic/hda-unbind' into for-next
Diffstat (limited to 'sound/core/device.c')
-rw-r--r--sound/core/device.c43
1 files changed, 33 insertions, 10 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,
}
EXPORT_SYMBOL(snd_device_new);
-static int __snd_device_disconnect(struct snd_device *dev)
+static void __snd_device_disconnect(struct snd_device *dev)
{
if (dev->state == SNDRV_DEV_REGISTERED) {
if (dev->ops->dev_disconnect &&
@@ -79,7 +79,6 @@ static int __snd_device_disconnect(struct snd_device *dev)
dev_err(dev->card->dev, "device disconnect failure\n");
dev->state = SNDRV_DEV_DISCONNECTED;
}
- return 0;
}
static 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)
}
/**
+ * snd_device_disconnect - disconnect the device
+ * @card: the card instance
+ * @device_data: the data pointer to disconnect
+ *
+ * Turns the device into the disconnection state, invoking
+ * dev_disconnect callback, if the device was already registered.
+ *
+ * Usually called from snd_card_disconnect().
+ *
+ * Return: Zero if successful, or a negative error code on failure or if the
+ * device not found.
+ */
+void snd_device_disconnect(struct snd_card *card, void *device_data)
+{
+ struct snd_device *dev;
+
+ if (snd_BUG_ON(!card || !device_data))
+ return;
+ dev = look_for_dev(card, device_data);
+ if (dev)
+ __snd_device_disconnect(dev);
+ else
+ dev_dbg(card->dev, "device disconnect %p (from %pF), not found\n",
+ device_data, __builtin_return_address(0));
+}
+EXPORT_SYMBOL_GPL(snd_device_disconnect);
+
+/**
* snd_device_free - release the device from the card
* @card: the card instance
* @device_data: the data pointer to release
@@ -193,18 +220,14 @@ int snd_device_register_all(struct snd_card *card)
* disconnect all the devices on the card.
* called from init.c
*/
-int snd_device_disconnect_all(struct snd_card *card)
+void snd_device_disconnect_all(struct snd_card *card)
{
struct snd_device *dev;
- int err = 0;
if (snd_BUG_ON(!card))
- return -ENXIO;
- list_for_each_entry_reverse(dev, &card->devices, list) {
- if (__snd_device_disconnect(dev) < 0)
- err = -ENXIO;
- }
- return err;
+ return;
+ list_for_each_entry_reverse(dev, &card->devices, list)
+ __snd_device_disconnect(dev);
}
/*