*参照元 [#ac30b911] #backlinks *説明 [#sd4b909d] -パス: [[linux-2.6.33/]] -パス: [[linux-2.6.33/sound/core/init.c]] -FIXME: これは何? --説明 **引数 [#rbe22aa6] -int idx -- -const char *xid -- -struct module *module -- --[[linux-2.6.33/module]] -int extra_size -- -struct snd_card **card_ret -- --[[linux-2.6.33/snd_card]] **返り値 [#a29fd629] -int -- **参考 [#r8556b4b] *実装 [#daa2102b] /** * snd_card_create - create and initialize a soundcard structure * @idx: card index (address) [0 ... (SNDRV_CARDS-1)] * @xid: card identification (ASCII string) * @module: top level module for locking * @extra_size: allocate this extra size after the main soundcard structure * @card_ret: the pointer to store the created card instance * * Creates and initializes a soundcard structure. * * The function allocates snd_card instance via kzalloc with the given * space for the driver to use freely. The allocated struct is stored * in the given card_ret pointer. * * Returns zero if successful or a negative error code. */ int snd_card_create(int idx, const char *xid, struct module *module, int extra_size, struct snd_card **card_ret) { struct snd_card *card; int err, idx2; if (snd_BUG_ON(!card_ret)) return -EINVAL; *card_ret = NULL; - --[[linux-2.6.33/snd_BUG_ON()]] if (extra_size < 0) extra_size = 0; card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL); if (!card) return -ENOMEM; if (xid) strlcpy(card->id, xid, sizeof(card->id)); - --[[linux-2.6.33/kzalloc()]] - --[[linux-2.6.33/strlcpy()]] err = 0; mutex_lock(&snd_card_mutex); - --[[linux-2.6.33/mutex_lock()]] - --[[linux-2.6.33/snd_card_mutex(global)]] if (idx < 0) { for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) /* idx == -1 == 0xffff means: take any free slot */ if (~snd_cards_lock & idx & 1<<idx2) { if (module_slot_match(module, idx2)) { idx = idx2; break; } } } - --[[linux-2.6.33/SNDRV_CARDS]] - --[[linux-2.6.33/module_slot_match()]] - --[[linux-2.6.33/snd_cards_lock(global)]] if (idx < 0) { for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) /* idx == -1 == 0xffff means: take any free slot */ if (~snd_cards_lock & idx & 1<<idx2) { if (!slots[idx2] || !*slots[idx2]) { idx = idx2; break; } } } if (idx < 0) err = -ENODEV; else if (idx < snd_ecards_limit) { if (snd_cards_lock & (1 << idx)) err = -EBUSY; /* invalid */ } else if (idx >= SNDRV_CARDS) err = -ENODEV; - --[[linux-2.6.33/snd_ecards_limit(global)]] if (err < 0) { mutex_unlock(&snd_card_mutex); snd_printk(KERN_ERR "cannot find the slot for index %d (range 0-%i), error: %d\n", idx, snd_ecards_limit - 1, err); goto __error; } - --[[linux-2.6.33/mutex_unlock()]] - --[[linux-2.6.33/snd_printk()]] snd_cards_lock |= 1 << idx; /* lock it */ if (idx >= snd_ecards_limit) snd_ecards_limit = idx + 1; /* increase the limit */ mutex_unlock(&snd_card_mutex); card->number = idx; card->module = module; INIT_LIST_HEAD(&card->devices); init_rwsem(&card->controls_rwsem); rwlock_init(&card->ctl_files_rwlock); INIT_LIST_HEAD(&card->controls); INIT_LIST_HEAD(&card->ctl_files); spin_lock_init(&card->files_lock); INIT_LIST_HEAD(&card->files_list); init_waitqueue_head(&card->shutdown_sleep); - --[[linux-2.6.33/INIT_LIST_HEAD()]] - --[[linux-2.6.33/init_rwsem()]] - --[[linux-2.6.33/rwlock_init()]] - --[[linux-2.6.33/spin_lock_init()]] - --[[linux-2.6.33/init_waitqueue_head()]] #ifdef CONFIG_PM mutex_init(&card->power_lock); init_waitqueue_head(&card->power_sleep); #endif /* the control interface cannot be accessed from the user space until */ /* snd_cards_bitmask and snd_cards are set with snd_card_register */ err = snd_ctl_create(card); if (err < 0) { snd_printk(KERN_ERR "unable to register control minors\n"); goto __error; } - --[[linux-2.6.33/snd_ctl_create()]] err = snd_info_card_create(card); if (err < 0) { snd_printk(KERN_ERR "unable to create card info\n"); goto __error_ctl; } - --[[linux-2.6.33/snd_info_card_create()]] if (extra_size > 0) card->private_data = (char *)card + sizeof(struct snd_card); *card_ret = card; return 0; __error_ctl: snd_device_free_all(card, SNDRV_DEV_CMD_PRE); - --[[linux-2.6.33/snd_device_free_all()]] - --[[linux-2.6.33/SNDRV_DEV_CMD_PRE]] __error: kfree(card); - --[[linux-2.6.33/kfree()]] return err; } EXPORT_SYMBOL(snd_card_create); -ライセンスに関係なくシンボルを公開する。 --[[linux-2.6.33/EXPORT_SYMBOL()]] *コメント [#i649ec9f]