Skip to content

Commit c208a53

Browse files
committed
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/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 55f7326 commit c208a53

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

include/sound/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ void snd_device_disconnect(struct snd_card *card, void *device_data);
266266
void snd_device_disconnect_all(struct snd_card *card);
267267
void snd_device_free(struct snd_card *card, void *device_data);
268268
void snd_device_free_all(struct snd_card *card);
269+
int snd_device_get_state(struct snd_card *card, void *device_data);
269270

270271
/* isadma.c */
271272

sound/core/device.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,24 @@ void snd_device_free_all(struct snd_card *card)
237237
list_for_each_entry_safe_reverse(dev, next, &card->devices, list)
238238
__snd_device_free(dev);
239239
}
240+
241+
/**
242+
* snd_device_get_state - Get the current state of the given device
243+
* @card: the card instance
244+
* @device_data: the data pointer to release
245+
*
246+
* Returns the current state of the given device object. For the valid
247+
* device, either @SNDRV_DEV_BUILD, @SNDRV_DEV_REGISTERED or
248+
* @SNDRV_DEV_DISCONNECTED is returned.
249+
* Or for a non-existing device, -1 is returned as an error.
250+
*/
251+
int snd_device_get_state(struct snd_card *card, void *device_data)
252+
{
253+
struct snd_device *dev;
254+
255+
dev = look_for_dev(card, device_data);
256+
if (dev)
257+
return dev->state;
258+
return -1;
259+
}
260+
EXPORT_SYMBOL_GPL(snd_device_get_state);

0 commit comments

Comments
 (0)