iommu/ipmmu-vmsa: Break out domain allocation code
authorMagnus Damm <damm+renesas@opensource.se>
Wed, 17 May 2017 10:06:59 +0000 (19:06 +0900)
committerJoerg Roedel <jroedel@suse.de>
Wed, 17 May 2017 13:21:53 +0000 (15:21 +0200)
Break out the domain allocation code into a separate function.

This is preparation for future code sharing.

Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
Reviewed-by: Joerg Roedel <jroedel@suse.de>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/ipmmu-vmsa.c

index c4c35abc1c1a2db6178d681038f5e4180e942935..eb5008596051cd27042cd8dbd05269c7459fc28d 100644 (file)
@@ -509,13 +509,10 @@ static irqreturn_t ipmmu_irq(int irq, void *dev)
  * IOMMU Operations
  */
 
-static struct iommu_domain *ipmmu_domain_alloc(unsigned type)
+static struct iommu_domain *__ipmmu_domain_alloc(unsigned type)
 {
        struct ipmmu_vmsa_domain *domain;
 
-       if (type != IOMMU_DOMAIN_UNMANAGED)
-               return NULL;
-
        domain = kzalloc(sizeof(*domain), GFP_KERNEL);
        if (!domain)
                return NULL;
@@ -525,6 +522,14 @@ static struct iommu_domain *ipmmu_domain_alloc(unsigned type)
        return &domain->io_domain;
 }
 
+static struct iommu_domain *ipmmu_domain_alloc(unsigned type)
+{
+       if (type != IOMMU_DOMAIN_UNMANAGED)
+               return NULL;
+
+       return __ipmmu_domain_alloc(type);
+}
+
 static void ipmmu_domain_free(struct iommu_domain *io_domain)
 {
        struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);