*参照元 [#heb67385]
#backlinks

*説明 [#j118c1b0]
-パス: [[linux-4.4.1/drivers/iommu/iommu.c]]

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


**引数 [#da5bbb58]
-struct iommu_group *group
--
--[[linux-4.4.1/iommu_group]]
-struct device *dev
--
--[[linux-4.4.1/device]]


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


**参考 [#ie433ac1]

struct device の iommu_group を参照する関数

-[[linux-4.4.1/iommu_group_get()]]


*実装 [#o97c3a9d]
 /**
  * iommu_group_add_device - add a device to an iommu group
  * @group: the group into which to add the device (reference should be held)
  * @dev: the device
  *
  * This function is called by an iommu driver to add a device into a
  * group.  Adding a device increments the group reference count.
  */
 int iommu_group_add_device(struct iommu_group *group, struct device *dev)
 {
 	int ret, i = 0;
 	struct iommu_device *device;
 
-
--[[linux-4.4.1/iommu_device]]

 	device = kzalloc(sizeof(*device), GFP_KERNEL);
 	if (!device)
 		return -ENOMEM;
 
-
--[[linux-4.4.1/kzalloc()]]

 	device->dev = dev;
 
 	ret = sysfs_create_link(&dev->kobj, &group->kobj, "iommu_group");
 	if (ret) {
 		kfree(device);
 		return ret;
 	}
 
-
--[[linux-4.4.1/sysfs_create_link()]]
--[[linux-4.4.1/kfree()]]

 	device->name = kasprintf(GFP_KERNEL, "%s", kobject_name(&dev->kobj));
-
--[[linux-4.4.1/kasprintf()]]
--[[linux-4.4.1/kobject_name()]]

 rename:
 	if (!device->name) {
 		sysfs_remove_link(&dev->kobj, "iommu_group");
 		kfree(device);
 		return -ENOMEM;
 	}
 
-
--[[linux-4.4.1/sysfs_remove_link()]]
--[[linux-4.4.1/kfree()]]

 	ret = sysfs_create_link_nowarn(group->devices_kobj,
 				       &dev->kobj, device->name);
 	if (ret) {
 		kfree(device->name);
 		if (ret == -EEXIST && i >= 0) {
 			/*
 			 * Account for the slim chance of collision
 			 * and append an instance to the name.
 			 */
 			device->name = kasprintf(GFP_KERNEL, "%s.%d",
 						 kobject_name(&dev->kobj), i++);
 			goto rename;
 		}
 
 		sysfs_remove_link(&dev->kobj, "iommu_group");
 		kfree(device);
 		return ret;
 	}
 
-
--[[linux-4.4.1/kasprintf()]]
--[[linux-4.4.1/sysfs_remove_link()]]

 	kobject_get(group->devices_kobj);
 
-
--[[linux-4.4.1/kobject_get()]]

 	dev->iommu_group = group;
 
 	iommu_group_create_direct_mappings(group, dev);
 
-
--[[linux-4.4.1/iommu_group_create_direct_mappings()]]

 	mutex_lock(&group->mutex);
 	list_add_tail(&device->list, &group->devices);
 	if (group->domain)
 		__iommu_attach_device(group->domain, dev);
 	mutex_unlock(&group->mutex);
 
-
--[[linux-4.4.1/mutex_lock()]]
--[[linux-4.4.1/list_add_tail()]]
--[[linux-4.4.1/__iommu_attach_device()]]
--[[linux-4.4.1/mutex_unlock()]]

 	/* Notify any listeners about change to group. */
 	blocking_notifier_call_chain(&group->notifier,
 				     IOMMU_GROUP_NOTIFY_ADD_DEVICE, dev);
 
-
--[[linux-4.4.1/blocking_notifier_call_chain()]]

 	trace_add_device_to_group(group->id, dev);
 
-
--[[linux-4.4.1/trace_add_device_to_group()]]

 	pr_info("Adding device %s to group %d\n", dev_name(dev), group->id);
 
-
--[[linux-4.4.1/pr_info()]]
--[[linux-4.4.1/dev_name()]]

 	return 0;
 }
 EXPORT_SYMBOL_GPL(iommu_group_add_device);
-
--[[linux-4.4.1/EXPORT_SYMBOL_GPL()]]


*コメント [#ldc445ce]

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