diff options
Diffstat (limited to 'include/linux/iommu-helper.h')
| -rw-r--r-- | include/linux/iommu-helper.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/include/linux/iommu-helper.h b/include/linux/iommu-helper.h index 86bdeffe43ad..74be34f3a20a 100644 --- a/include/linux/iommu-helper.h +++ b/include/linux/iommu-helper.h @@ -1,7 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _LINUX_IOMMU_HELPER_H #define _LINUX_IOMMU_HELPER_H -#include <linux/kernel.h> +#include <linux/bug.h> +#include <linux/log2.h> +#include <linux/math.h> +#include <linux/types.h> static inline unsigned long iommu_device_max_index(unsigned long size, unsigned long offset, @@ -13,9 +17,15 @@ static inline unsigned long iommu_device_max_index(unsigned long size, return size; } -extern int iommu_is_span_boundary(unsigned int index, unsigned int nr, - unsigned long shift, - unsigned long boundary_size); +static inline int iommu_is_span_boundary(unsigned int index, unsigned int nr, + unsigned long shift, unsigned long boundary_size) +{ + BUG_ON(!is_power_of_2(boundary_size)); + + shift = (shift + index) & (boundary_size - 1); + return shift + nr > boundary_size; +} + extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, unsigned long shift, |
