iommu: Tidy up window attributes
authorRobin Murphy <robin.murphy@arm.com>
Wed, 19 Sep 2018 10:12:57 +0000 (11:12 +0100)
committerJoerg Roedel <jroedel@suse.de>
Tue, 25 Sep 2018 12:54:53 +0000 (14:54 +0200)
The external interface to get/set window attributes is already
abstracted behind iommu_domain_{get,set}_attr(), so there's no real
reason for the internal interface to be different. Since we only have
one window-based driver anyway, clean up the core code by just moving
the DOMAIN_ATTR_WINDOWS handling directly into the PAMU driver.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/fsl_pamu_domain.c
drivers/iommu/iommu.c

index f089136..f83965e 100644 (file)
@@ -818,6 +818,7 @@ static int fsl_pamu_set_domain_attr(struct iommu_domain *domain,
                                    enum iommu_attr attr_type, void *data)
 {
        struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain);
+       u32 *count;
        int ret = 0;
 
        switch (attr_type) {
@@ -830,6 +831,15 @@ static int fsl_pamu_set_domain_attr(struct iommu_domain *domain,
        case DOMAIN_ATTR_FSL_PAMU_ENABLE:
                ret = configure_domain_dma_state(dma_domain, *(int *)data);
                break;
+       case DOMAIN_ATTR_WINDOWS:
+               count = data;
+
+               if (domain->ops->domain_set_windows != NULL)
+                       ret = domain->ops->domain_set_windows(domain, *count);
+               else
+                       ret = -ENODEV;
+
+               break;
        default:
                pr_debug("Unsupported attribute type\n");
                ret = -EINVAL;
@@ -843,6 +853,7 @@ static int fsl_pamu_get_domain_attr(struct iommu_domain *domain,
                                    enum iommu_attr attr_type, void *data)
 {
        struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain);
+       u32 *count;
        int ret = 0;
 
        switch (attr_type) {
@@ -856,6 +867,15 @@ static int fsl_pamu_get_domain_attr(struct iommu_domain *domain,
        case DOMAIN_ATTR_FSL_PAMUV1:
                *(int *)data = DOMAIN_ATTR_FSL_PAMUV1;
                break;
+       case DOMAIN_ATTR_WINDOWS:
+               count = data;
+
+               if (domain->ops->domain_get_windows != NULL)
+                       *count = domain->ops->domain_get_windows(domain);
+               else
+                       ret = -ENODEV;
+
+               break;
        default:
                pr_debug("Unsupported attribute type\n");
                ret = -EINVAL;
index 9d70344..e9b50ab 100644 (file)
@@ -1805,7 +1805,6 @@ int iommu_domain_get_attr(struct iommu_domain *domain,
        struct iommu_domain_geometry *geometry;
        bool *paging;
        int ret = 0;
-       u32 *count;
 
        switch (attr) {
        case DOMAIN_ATTR_GEOMETRY:
@@ -1817,15 +1816,6 @@ int iommu_domain_get_attr(struct iommu_domain *domain,
                paging  = data;
                *paging = (domain->pgsize_bitmap != 0UL);
                break;
-       case DOMAIN_ATTR_WINDOWS:
-               count = data;
-
-               if (domain->ops->domain_get_windows != NULL)
-                       *count = domain->ops->domain_get_windows(domain);
-               else
-                       ret = -ENODEV;
-
-               break;
        default:
                if (!domain->ops->domain_get_attr)
                        return -EINVAL;
@@ -1841,18 +1831,8 @@ int iommu_domain_set_attr(struct iommu_domain *domain,
                          enum iommu_attr attr, void *data)
 {
        int ret = 0;
-       u32 *count;
 
        switch (attr) {
-       case DOMAIN_ATTR_WINDOWS:
-               count = data;
-
-               if (domain->ops->domain_set_windows != NULL)
-                       ret = domain->ops->domain_set_windows(domain, *count);
-               else
-                       ret = -ENODEV;
-
-               break;
        default:
                if (domain->ops->domain_set_attr == NULL)
                        return -EINVAL;