From 4b440be667c6187717c99e4d427119fa415ced29 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 29 Jan 2015 21:32:47 +0100 Subject: ALSA: Add a helper to initialize device Introduce a new helper function snd_device_initialize() to initialize the device object for sound devices. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/init.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'sound/core/init.c') diff --git a/sound/core/init.c b/sound/core/init.c index 074875d..9619459 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -157,6 +157,29 @@ static int get_slot_from_bitmask(int mask, int (*check)(struct module *, int), return mask; /* unchanged */ } +/* the default release callback set in snd_device_initialize() below; + * this is just NOP for now, as almost all jobs are already done in + * dev_free callback of snd_device chain instead. + */ +static void default_release(struct device *dev) +{ +} + +/** + * snd_device_initialize - Initialize struct device for sound devices + * @dev: device to initialize + * @card: card to assign, optional + */ +void snd_device_initialize(struct device *dev, struct snd_card *card) +{ + device_initialize(dev); + if (card) + dev->parent = &card->card_dev; + dev->class = sound_class; + dev->release = default_release; +} +EXPORT_SYMBOL_GPL(snd_device_initialize); + static int snd_card_do_free(struct snd_card *card); static const struct attribute_group *card_dev_attr_groups[]; -- cgit v1.1