diff options
| author | Ohad Ben-Cohen <ohad@wizery.com> | 2011-09-02 13:32:32 -0400 |
|---|---|---|
| committer | Joerg Roedel <joerg.roedel@amd.com> | 2011-09-05 09:15:59 -0400 |
| commit | 4099818842abd98ef2b18a8ac7a2e2ad3bc3d7c2 (patch) | |
| tree | a7486a45b806b8cf42d8996e712ab4e9d31d620e | |
| parent | 403f81d8ee532c976d50a5e1051f14ec78ae8db3 (diff) | |
iommu/core: use the existing IS_ALIGNED macro
Replace iommu's alignment checks with the existing IS_ALIGNED macro,
to drop a few lines of code and utilize IS_ALIGNED's type safety.
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
| -rw-r--r-- | drivers/iommu/iommu.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 6e6b6a11b3ce..e61a9bad6df3 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | #include <linux/kernel.h> | ||
| 19 | #include <linux/bug.h> | 20 | #include <linux/bug.h> |
| 20 | #include <linux/types.h> | 21 | #include <linux/types.h> |
| 21 | #include <linux/module.h> | 22 | #include <linux/module.h> |
| @@ -97,13 +98,11 @@ EXPORT_SYMBOL_GPL(iommu_domain_has_cap); | |||
| 97 | int iommu_map(struct iommu_domain *domain, unsigned long iova, | 98 | int iommu_map(struct iommu_domain *domain, unsigned long iova, |
| 98 | phys_addr_t paddr, int gfp_order, int prot) | 99 | phys_addr_t paddr, int gfp_order, int prot) |
| 99 | { | 100 | { |
| 100 | unsigned long invalid_mask; | ||
| 101 | size_t size; | 101 | size_t size; |
| 102 | 102 | ||
| 103 | size = 0x1000UL << gfp_order; | 103 | size = 0x1000UL << gfp_order; |
| 104 | invalid_mask = size - 1; | ||
| 105 | 104 | ||
| 106 | BUG_ON((iova | paddr) & invalid_mask); | 105 | BUG_ON(!IS_ALIGNED(iova | paddr, size)); |
| 107 | 106 | ||
| 108 | return iommu_ops->map(domain, iova, paddr, gfp_order, prot); | 107 | return iommu_ops->map(domain, iova, paddr, gfp_order, prot); |
| 109 | } | 108 | } |
| @@ -111,13 +110,11 @@ EXPORT_SYMBOL_GPL(iommu_map); | |||
| 111 | 110 | ||
| 112 | int iommu_unmap(struct iommu_domain *domain, unsigned long iova, int gfp_order) | 111 | int iommu_unmap(struct iommu_domain *domain, unsigned long iova, int gfp_order) |
| 113 | { | 112 | { |
| 114 | unsigned long invalid_mask; | ||
| 115 | size_t size; | 113 | size_t size; |
| 116 | 114 | ||
| 117 | size = 0x1000UL << gfp_order; | 115 | size = 0x1000UL << gfp_order; |
| 118 | invalid_mask = size - 1; | ||
| 119 | 116 | ||
| 120 | BUG_ON(iova & invalid_mask); | 117 | BUG_ON(!IS_ALIGNED(iova, size)); |
| 121 | 118 | ||
| 122 | return iommu_ops->unmap(domain, iova, gfp_order); | 119 | return iommu_ops->unmap(domain, iova, gfp_order); |
| 123 | } | 120 | } |
