]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
ALSA: core: Add snd_device_get_state() helper
authorTakashi Iwai <tiwai@suse.de>
Mon, 23 Mar 2020 17:06:42 +0000 (18:06 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 23 Mar 2020 17:09:19 +0000 (18:09 +0100)
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>
include/sound/core.h
sound/core/device.c

index ac8b692b69b45cb15433c83d8b520cdd9c23217a..381a010a1bd4d2f38d953340f3f42f9e66306848 100644 (file)
@@ -266,6 +266,7 @@ void snd_device_disconnect(struct snd_card *card, void *device_data);
 void snd_device_disconnect_all(struct snd_card *card);
 void snd_device_free(struct snd_card *card, void *device_data);
 void snd_device_free_all(struct snd_card *card);
+int snd_device_get_state(struct snd_card *card, void *device_data);
 
 /* isadma.c */
 
index cdc5af526739366dfa1fcb58b9f9d2694c84b62c..bf0b04a7ee79756c2b3ff907b8acbaa1a24f59e1 100644 (file)
@@ -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);