From: Will Deacon Date: Thu, 19 Dec 2019 12:03:43 +0000 (+0000) Subject: drivers/iommu: Allow IOMMU bus ops to be unregistered X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=4312cf7f16c8d43e154bf2a6eea6d1e9347c922c;p=linux.git drivers/iommu: Allow IOMMU bus ops to be unregistered 'bus_set_iommu()' allows IOMMU drivers to register their ops for a given bus type. Unfortunately, it then doesn't allow them to be removed, which is necessary for modular drivers to shutdown cleanly so that they can be reloaded later on. Allow 'bus_set_iommu()' to take a NULL 'ops' argument, which clear the ops pointer for the selected bus_type. Signed-off-by: Will Deacon Tested-by: John Garry # smmu v3 Reviewed-by: Greg Kroah-Hartman Signed-off-by: Joerg Roedel --- diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 32ceda1d50314..ffe6f685ceae4 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1558,6 +1558,11 @@ int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops) { int err; + if (ops == NULL) { + bus->iommu_ops = NULL; + return 0; + } + if (bus->iommu_ops != NULL) return -EBUSY;