{
struct iommu_group *group = dev->iommu_group;
struct group_device *device;
--- const struct iommu_ops *ops;
---
--- if (!dev->iommu || !group)
--- return;
---
--- iommu_device_unlink(dev->iommu->iommu_dev, dev);
mutex_lock(&group->mutex);
--- device = __iommu_group_remove_device(group, dev);
+++ for_each_group_device(group, device) {
+++ if (device->dev != dev)
+++ continue;
--- /*
--- * If the group has become empty then ownership must have been released,
--- * and the current domain must be set back to NULL or the default
--- * domain.
--- */
--- if (list_empty(&group->devices))
--- WARN_ON(group->owner_cnt ||
--- group->domain != group->default_domain);
+++ list_del(&device->list);
+++ __iommu_group_free_device(group, device);
+++ if (dev->iommu && dev->iommu->iommu_dev)
+++ iommu_deinit_device(dev);
+++ else
+++ dev->iommu_group = NULL;
+++ break;
+++ }
+++ mutex_unlock(&group->mutex);
/*
--- * release_device() must stop using any attached domain on the device.
--- * If there are still other devices in the group they are not effected
--- * by this callback.
--- *
--- * The IOMMU driver must set the device to either an identity or
--- * blocking translation and stop using any domain pointer, as it is
--- * going to be freed.
+++ * Pairs with the get in iommu_init_device() or
+++ * iommu_group_add_device()
*/
--- ops = dev_iommu_ops(dev);
--- if (ops->release_device)
--- ops->release_device(dev);
--- mutex_unlock(&group->mutex);
+++ iommu_group_put(group);
+++ }
+
-- if (device)
-- __iommu_group_release_device(group, device);
+++ static void iommu_release_device(struct device *dev)
+++ {
+++ struct iommu_group *group = dev->iommu_group;
- if (device)
- __iommu_group_release_device(group, device);
-- module_put(ops->owner);
-- dev_iommu_free(dev);
+++ if (group)
+++ __iommu_group_remove_device(dev);
++
- module_put(ops->owner);
- dev_iommu_free(dev);
+++ /* Free any fwspec if no iommu_driver was ever attached */
+++ if (dev->iommu)
+++ dev_iommu_free(dev);
}
static int __init iommu_set_def_domain_type(char *str)