From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753749AbbJOQWL (ORCPT ); Thu, 15 Oct 2015 12:22:11 -0400 Received: from mout01.posteo.de ([185.67.36.65]:49259 "EHLO mout01.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752502AbbJOQWH (ORCPT ); Thu, 15 Oct 2015 12:22:07 -0400 From: Martin Kepplinger To: mingo@kernel.org, akpm@linux-foundation.org, linux@horizon.com, linux@rasmusvillemoes.dk, maxime.coquelin@st.com, dvlasenk@redhat.com, yury.norov@gmail.com, torvalds@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Martin Kepplinger , Martin Kepplinger Subject: [PATCH 1/2] bitops.h: Improve sign_extend32()'s documentation Date: Thu, 15 Oct 2015 18:18:28 +0200 Message-Id: <1444925909-6013-2-git-send-email-martink@posteo.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444925909-6013-1-git-send-email-martink@posteo.de> References: <1444925909-6013-1-git-send-email-martink@posteo.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is often overlooked that sign_extend32(), despite it's name, is safe to use for 16 and 8 bit types aswell. This should help that sign extension isn't done manually some other way. Signed-off-by: Martin Kepplinger --- include/linux/bitops.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index e635533..2177c01 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 aswell. */ static inline __s32 sign_extend32(__u32 value, int index) { -- 2.1.4