Skip to content

Commit

Permalink
iommu/core: use the existing IS_ALIGNED macro
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ohad Ben-Cohen authored and Joerg Roedel committed Sep 5, 2011
1 parent 403f81d commit 4099818
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/iommu/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <linux/kernel.h>
#include <linux/bug.h>
#include <linux/types.h>
#include <linux/module.h>
Expand Down Expand Up @@ -97,27 +98,23 @@ EXPORT_SYMBOL_GPL(iommu_domain_has_cap);
int iommu_map(struct iommu_domain *domain, unsigned long iova,
phys_addr_t paddr, int gfp_order, int prot)
{
unsigned long invalid_mask;
size_t size;

size = 0x1000UL << gfp_order;
invalid_mask = size - 1;

BUG_ON((iova | paddr) & invalid_mask);
BUG_ON(!IS_ALIGNED(iova | paddr, size));

return iommu_ops->map(domain, iova, paddr, gfp_order, prot);
}
EXPORT_SYMBOL_GPL(iommu_map);

int iommu_unmap(struct iommu_domain *domain, unsigned long iova, int gfp_order)
{
unsigned long invalid_mask;
size_t size;

size = 0x1000UL << gfp_order;
invalid_mask = size - 1;

BUG_ON(iova & invalid_mask);
BUG_ON(!IS_ALIGNED(iova, size));

return iommu_ops->unmap(domain, iova, gfp_order);
}
Expand Down

0 comments on commit 4099818

Please sign in to comment.