https://github.com/torvalds/linux
Revision ae6b289a37890909fea0e4a1666e19377fa0ed2c authored by Chris Fries on 07 November 2017, 19:46:13 UTC, committed by Masahiro Yamada on 23 November 2017, 04:12:37 UTC
Set the clang KBUILD_CFLAGS up before including arch/ Makefiles,
so that ld-options (etc.) can work correctly.

This fixes errors with clang such as ld-options trying to CC
against your host architecture, but LD trying to link against
your target architecture.

Signed-off-by: Chris Fries <cfries@google.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent bf070bb
Raw File
Tip revision: ae6b289a37890909fea0e4a1666e19377fa0ed2c authored by Chris Fries on 07 November 2017, 19:46:13 UTC
kbuild: Set KBUILD_CFLAGS before incl. arch Makefile
Tip revision: ae6b289
iommu-helper.c
// SPDX-License-Identifier: GPL-2.0
/*
 * IOMMU helper functions for the free area management
 */

#include <linux/export.h>
#include <linux/bitmap.h>
#include <linux/bug.h>

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;
}

unsigned long iommu_area_alloc(unsigned long *map, unsigned long size,
			       unsigned long start, unsigned int nr,
			       unsigned long shift, unsigned long boundary_size,
			       unsigned long align_mask)
{
	unsigned long index;

	/* We don't want the last of the limit */
	size -= 1;
again:
	index = bitmap_find_next_zero_area(map, size, start, nr, align_mask);
	if (index < size) {
		if (iommu_is_span_boundary(index, nr, shift, boundary_size)) {
			start = ALIGN(shift + index, boundary_size) - shift;
			goto again;
		}
		bitmap_set(map, index, nr);
		return index;
	}
	return -1;
}
EXPORT_SYMBOL(iommu_area_alloc);
back to top