|
@@ -1658,43 +1658,18 @@ out:
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-struct iommu_instance {
|
|
|
- struct list_head list;
|
|
|
- struct fwnode_handle *fwnode;
|
|
|
- const struct iommu_ops *ops;
|
|
|
-};
|
|
|
-static LIST_HEAD(iommu_instance_list);
|
|
|
-static DEFINE_SPINLOCK(iommu_instance_lock);
|
|
|
-
|
|
|
-void iommu_register_instance(struct fwnode_handle *fwnode,
|
|
|
- const struct iommu_ops *ops)
|
|
|
-{
|
|
|
- struct iommu_instance *iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
|
|
|
-
|
|
|
- if (WARN_ON(!iommu))
|
|
|
- return;
|
|
|
-
|
|
|
- of_node_get(to_of_node(fwnode));
|
|
|
- INIT_LIST_HEAD(&iommu->list);
|
|
|
- iommu->fwnode = fwnode;
|
|
|
- iommu->ops = ops;
|
|
|
- spin_lock(&iommu_instance_lock);
|
|
|
- list_add_tail(&iommu->list, &iommu_instance_list);
|
|
|
- spin_unlock(&iommu_instance_lock);
|
|
|
-}
|
|
|
-
|
|
|
const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)
|
|
|
{
|
|
|
- struct iommu_instance *instance;
|
|
|
const struct iommu_ops *ops = NULL;
|
|
|
+ struct iommu_device *iommu;
|
|
|
|
|
|
- spin_lock(&iommu_instance_lock);
|
|
|
- list_for_each_entry(instance, &iommu_instance_list, list)
|
|
|
- if (instance->fwnode == fwnode) {
|
|
|
- ops = instance->ops;
|
|
|
+ spin_lock(&iommu_device_lock);
|
|
|
+ list_for_each_entry(iommu, &iommu_device_list, list)
|
|
|
+ if (iommu->fwnode == fwnode) {
|
|
|
+ ops = iommu->ops;
|
|
|
break;
|
|
|
}
|
|
|
- spin_unlock(&iommu_instance_lock);
|
|
|
+ spin_unlock(&iommu_device_lock);
|
|
|
return ops;
|
|
|
}
|
|
|
|