- 追加された行はこの色です。
- 削除された行はこの色です。
*参照元 [#i55b1ea6]
#backlinks
*説明 [#i4b1dd0d]
-パス: [[linux-4.4.1/]]
-パス: [[linux-4.4.1/drivers/base/platform.c]]
-FIXME: これは何?
--説明
-デバイスが使用するリソースを指定する。
--追加ではなく上書きとなる。以前に設定されていたリソースは消去される。
**引数 [#je40c673]
-struct platform_device *pdev
--
--デバイス
--[[linux-4.4.1/platform_device]]
-const struct resource *res
--
--リソースの配列
--[[linux-4.4.1/resource]]
-unsigned int num
--
--リソースの項目数
**返り値 [#mb2398bd]
-int
--
--成功ならば 0、失敗ならば負のエラー値。
**参考 [#b6462cb4]
対となる(取得)関数
-[[linux-4.4.1/platform_get_resource()]]
*実装 [#u6f691ba]
/**
* platform_device_add_resources - add resources to a platform device
* @pdev: platform device allocated by platform_device_alloc to add resources to
* @res: set of resources that needs to be allocated for the device
* @num: number of resources
*
* Add a copy of the resources to the platform device. The memory
* associated with the resources will be freed when the platform device is
* released.
*/
int platform_device_add_resources(struct platform_device *pdev,
const struct resource *res, unsigned int num)
{
struct resource *r = NULL;
if (res) {
r = kmemdup(res, sizeof(struct resource) * num, GFP_KERNEL);
if (!r)
return -ENOMEM;
}
-
-引数で渡されたリソースの配列を複製する。
--[[linux-4.4.1/kmemdup()]]
kfree(pdev->resource);
-以前に設定していたリソースを解放する。初回(pdev->resource == NULL)なら何も起きない。
--[[linux-4.4.1/kfree()]]
pdev->resource = r;
pdev->num_resources = num;
return 0;
}
EXPORT_SYMBOL_GPL(platform_device_add_resources);
-
-GPL ライセンスのモジュールにシンボルを公開する。
--[[linux-4.4.1/EXPORT_SYMBOL_GPL()]]
*コメント [#y64a9422]