参照元

説明

引数

返り値

参考

実装

/**
 * snd_soc_register_dais - Register a DAI with the ASoC core
 *
 * @component: The component the DAIs are registered for
 * @dai_drv: DAI driver to use for the DAIs
 * @count: Number of DAIs
 * @legacy_dai_naming: Use the legacy naming scheme and let the DAI inherit the
 *                     parent's name.
 */
static int snd_soc_register_dais(struct snd_soc_component *component,
        struct snd_soc_dai_driver *dai_drv, size_t count,
        bool legacy_dai_naming)
{
        struct device *dev = component->dev;
        struct snd_soc_dai *dai;
        unsigned int i;
        int ret;
        dev_dbg(dev, "ASoC: dai register %s #%Zu\n", dev_name(dev), count);
        component->dai_drv = dai_drv;
        component->num_dai = count;

        for (i = 0; i < count; i++) {

                dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL);
                if (dai == NULL) {
                        ret = -ENOMEM;
                        goto err;
                }
                /*
                 * Back in the old days when we still had component-less DAIs,
                 * instead of having a static name, component-less DAIs would
                 * inherit the name of the parent device so it is possible to
                 * register multiple instances of the DAI. We still need to keep
                 * the same naming style even though those DAIs are not
                 * component-less anymore.
                 */
                if (count == 1 && legacy_dai_naming &&
                        (dai_drv[i].id == 0 || dai_drv[i].name == NULL)) {
                        dai->name = fmt_single_name(dev, &dai->id);
                } else {
                        dai->name = fmt_multiple_name(dev, &dai_drv[i]);
                        if (dai_drv[i].id)
                                dai->id = dai_drv[i].id;
                        else
                                dai->id = i;
                }
                if (dai->name == NULL) {
                        kfree(dai);
                        ret = -ENOMEM;
                        goto err;
                }
                dai->component = component;
                dai->dev = dev;
                dai->driver = &dai_drv[i];
                if (!dai->driver->ops)
                        dai->driver->ops = &null_dai_ops;

                list_add(&dai->list, &component->dai_list);
                dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name);
        }
        return 0;

err:
        snd_soc_unregister_dais(component);
        return ret;
}

コメント


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-02-15 (月) 10:54:06