From ace9429bb58fd418f0c81d4c2835699bddf6bde6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 11 Apr 2024 10:27:49 +0200 Subject: Adding upstream version 6.6.15. Signed-off-by: Daniel Baumann --- arch/sh/include/asm/bitops.h | 72 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 arch/sh/include/asm/bitops.h (limited to 'arch/sh/include/asm/bitops.h') diff --git a/arch/sh/include/asm/bitops.h b/arch/sh/include/asm/bitops.h new file mode 100644 index 0000000000..10ceb0d6b5 --- /dev/null +++ b/arch/sh/include/asm/bitops.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_SH_BITOPS_H +#define __ASM_SH_BITOPS_H + +#ifndef _LINUX_BITOPS_H +#error only can be included directly +#endif + +/* For __swab32 */ +#include +#include + +#ifdef CONFIG_GUSA_RB +#include +#elif defined(CONFIG_CPU_SH2A) +#include +#include +#elif defined(CONFIG_CPU_SH4A) +#include +#elif defined(CONFIG_CPU_J2) && defined(CONFIG_SMP) +#include +#else +#include +#include +#endif + +static inline unsigned long ffz(unsigned long word) +{ + unsigned long result; + + __asm__("1:\n\t" + "shlr %1\n\t" + "bt/s 1b\n\t" + " add #1, %0" + : "=r" (result), "=r" (word) + : "0" (~0L), "1" (word) + : "t"); + return result; +} + +/** + * __ffs - find first bit in word. + * @word: The word to search + * + * Undefined if no bit exists, so code should check against 0 first. + */ +static inline unsigned long __ffs(unsigned long word) +{ + unsigned long result; + + __asm__("1:\n\t" + "shlr %1\n\t" + "bf/s 1b\n\t" + " add #1, %0" + : "=r" (result), "=r" (word) + : "0" (~0L), "1" (word) + : "t"); + return result; +} + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#endif /* __ASM_SH_BITOPS_H */ -- cgit v1.2.3