*参照元 [#bc86c8b1]
#backlinks

*説明 [#x4e94b5c]
-パス: [[linux-4.4.1/sound/core/control.c]]

-FIXME: これは何?
--説明


**引数 [#i4be6ad1]
-struct snd_card *card
--
--[[linux-4.4.1/snd_card]]
-struct snd_kcontrol *kcontrol
--
--[[linux-4.4.1/snd_kcontrol]]


**返り値 [#vdf5ca8c]
-int
--


**参考 [#ufd59cf1]


*実装 [#d897f6a1]
 /**
  * snd_ctl_add - add the control instance to the card
  * @card: the card instance
  * @kcontrol: the control instance to add
  *
  * Adds the control instance created via snd_ctl_new() or
  * snd_ctl_new1() to the given card. Assigns also an unique
  * numid used for fast search.
  *
  * It frees automatically the control which cannot be added.
  *
  * Return: Zero if successful, or a negative error code on failure.
  *
  */
 int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
 {
         struct snd_ctl_elem_id id;
         unsigned int idx;
         unsigned int count;
         int err = -EINVAL;
 
         if (! kcontrol)
                 return err;
         if (snd_BUG_ON(!card || !kcontrol->info))
                 goto error;
-
--[[linux-4.4.1/snd_BUG_ON()]]

         id = kcontrol->id;
         if (id.index > UINT_MAX - kcontrol->count)
                 goto error;
 
         down_write(&card->controls_rwsem);
-
--[[linux-4.4.1/down_write()]]

         if (snd_ctl_find_id(card, &id)) {
                 up_write(&card->controls_rwsem);
                 dev_err(card->dev, "control %i:%i:%i:%s:%i is already present\n",
                                         id.iface,
                                         id.device,
                                         id.subdevice,
                                         id.name,
                                         id.index);
                 err = -EBUSY;
                 goto error;
-
--[[linux-4.4.1/snd_ctl_find_id()]]
--[[linux-4.4.1/up_write()]]
--[[linux-4.4.1/dev_err()]]

         }
         if (snd_ctl_find_hole(card, kcontrol->count) < 0) {
                 up_write(&card->controls_rwsem);
                 err = -ENOMEM;
                 goto error;
-
--[[linux-4.4.1/snd_ctl_find_hole()]]

         }
         list_add_tail(&kcontrol->list, &card->controls);
         card->controls_count += kcontrol->count;
         kcontrol->id.numid = card->last_numid + 1;
         card->last_numid += kcontrol->count;
         id = kcontrol->id;
         count = kcontrol->count;
         up_write(&card->controls_rwsem);
-
--[[linux-4.4.1/list_add_tail()]]

         for (idx = 0; idx < count; idx++, id.index++, id.numid++)
                 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);
-
--[[linux-4.4.1/snd_ctl_notify()]]

         return 0;
 
  error:
         snd_ctl_free_one(kcontrol);
-
--[[linux-4.4.1/snd_ctl_free_one()]]

         return err;
 }
 EXPORT_SYMBOL(snd_ctl_add);
-
--[[linux-4.4.1/EXPORT_SYMBOL()]]


*コメント [#f656ad9e]


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS