From: Martin Kepplinger Date: Wed, 21 Oct 2015 22:03:51 +0000 (+1100) Subject: bitops.h: improve sign_extend32()'s documentation X-Git-Tag: KARO-TX6UL-2015-11-03~14^2~56 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9228cba6ca06ead7a6c299659f56eaeeb1ae0055;p=karo-tx-linux.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 Cc: Linus Torvalds Signed-off-by: Andrew Morton --- 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) {