bitops.h: improve sign extending API

From: Martin Kepplinger
Date: Thu Oct 15 2015 - 12:23:44 EST


PATCH 1/2 improves the doc of sign_extend32()

This should help to avoid different manual approaches to sign extension


PATCH 2/2 adds sign_extend64()

An informal example of what could follow in
arch/sh/kernel/traps_64.c after PATCH 2/2:

@@ -101,7 +102,7 @@ static int generate_and_check_address(struct pt_regs *regs,
__s64 displacement;
displacement = (opcode >> 10) & 0x3ff;
- displacement = ((displacement << 54) >> 54); /* sign extend */
+ displacement = sign_extend64(displacement, 9);
addr = (__u64)((__s64)base_address + (displacement << width_shift));
} else {


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/