summaryrefslogtreecommitdiff
path: root/sound/core/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/init.c')
-rw-r--r--sound/core/init.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/sound/core/init.c b/sound/core/init.c
index baef2688d0cf..d61bde1225f2 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -111,28 +111,36 @@ 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)
+/* the default release callback set in snd_device_alloc() */
+static void default_release_alloc(struct device *dev)
{
+ kfree(dev);
}
/**
- * snd_device_initialize - Initialize struct device for sound devices
- * @dev: device to initialize
+ * snd_device_alloc - Allocate and initialize struct device for sound devices
+ * @dev_p: pointer to store the allocated device
* @card: card to assign, optional
+ *
+ * For releasing the allocated device, call put_device().
*/
-void snd_device_initialize(struct device *dev, struct snd_card *card)
+int snd_device_alloc(struct device **dev_p, struct snd_card *card)
{
+ struct device *dev;
+
+ *dev_p = NULL;
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ if (!dev)
+ return -ENOMEM;
device_initialize(dev);
if (card)
dev->parent = &card->card_dev;
dev->class = &sound_class;
- dev->release = default_release;
+ dev->release = default_release_alloc;
+ *dev_p = dev;
+ return 0;
}
-EXPORT_SYMBOL_GPL(snd_device_initialize);
+EXPORT_SYMBOL_GPL(snd_device_alloc);
static int snd_card_init(struct snd_card *card, struct device *parent,
int idx, const char *xid, struct module *module,