From: Martin Kepplinger Date: Sat, 7 Nov 2015 00:30:58 +0000 (-0800) Subject: bitops.h: improve sign_extend32()'s documentation X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e2eb53aa96754b97d158eff884dde88abbad925e;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git bitops.h: improve sign_extend32()'s documentation It is often overlooked that sign_extend32(), despite its name, is safe to use for 16 and 8 bit types as well. This should help prevent sign extension being done manually some other way. Signed-off-by: Martin Kepplinger Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Thomas Gleixner Cc: "H. Peter Anvin" Cc: George Spelvin Cc: Rasmus Villemoes Cc: Maxime Coquelin Cc: Denys Vlasenko Cc: Yury Norov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/include/linux/bitops.h b/include/linux/bitops.h index e63553386ae7..5629923a8701 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -164,6 +164,8 @@ static inline __u8 ror8(__u8 word, unsigned int shift) * sign_extend32 - sign extend a 32-bit value using specified bit as sign-bit * @value: value to sign extend * @index: 0 based bit index (0<=index<32) to sign bit + * + * This is safe to use for 16- and 8-bit types as well. */ static inline __s32 sign_extend32(__u32 value, int index) {