aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/device.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2020-03-23 18:06:42 +0100
committerTakashi Iwai <tiwai@suse.de>2020-03-23 18:09:19 +0100
commitc208a5335036a332c0248b0e16fca57332b3f1d1 (patch)
tree70ac581c06c71927be783ffbd3d465c1496c6b99 /sound/core/device.c
parentALSA: usb-audio: Create a registration quirk for Kingston HyperX Amp (0951:16d8) (diff)
downloadlinux-dev-c208a5335036a332c0248b0e16fca57332b3f1d1.tar.xz
linux-dev-c208a5335036a332c0248b0e16fca57332b3f1d1.zip
ALSA: core: Add snd_device_get_state() helper
A new small helper to get the current state of the device registration for the given object. It'll be used for USB-audio driver to check the delayed device registrations. Link: https://lore.kernel.org/r/20200323170643.19181-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/device.c')
-rw-r--r--sound/core/device.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/sound/core/device.c b/sound/core/device.c
index cdc5af526739..bf0b04a7ee79 100644
--- a/sound/core/device.c
+++ b/sound/core/device.c
@@ -237,3 +237,24 @@ void snd_device_free_all(struct snd_card *card)
list_for_each_entry_safe_reverse(dev, next, &card->devices, list)
__snd_device_free(dev);
}
+
+/**
+ * snd_device_get_state - Get the current state of the given device
+ * @card: the card instance
+ * @device_data: the data pointer to release
+ *
+ * Returns the current state of the given device object. For the valid
+ * device, either @SNDRV_DEV_BUILD, @SNDRV_DEV_REGISTERED or
+ * @SNDRV_DEV_DISCONNECTED is returned.
+ * Or for a non-existing device, -1 is returned as an error.
+ */
+int snd_device_get_state(struct snd_card *card, void *device_data)
+{
+ struct snd_device *dev;
+
+ dev = look_for_dev(card, device_data);
+ if (dev)
+ return dev->state;
+ return -1;
+}
+EXPORT_SYMBOL_GPL(snd_device_get_state);