Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1517380ybb; Sat, 11 Apr 2020 05:27:52 -0700 (PDT) X-Google-Smtp-Source: APiQypJwU12F/1CLwWk4dDhRYWEN9LjoFZZZMc1o6qFEYLysN0AzlPi3+pNlg96IsmZOoNPu79mc X-Received: by 2002:ac8:710c:: with SMTP id z12mr3293765qto.193.1586608072154; Sat, 11 Apr 2020 05:27:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586608072; cv=none; d=google.com; s=arc-20160816; b=KekGYfoxI6b3tzKSizAJm/jp17GPgDObc45MLuCpLzm8c1xf4B3MhDO/x57ZzG5gLw aQpR2rweE+Dhn54WEmW/J3wM2Vm6QupvHPXvGer5tr6tM1nIytqhSsSPopwqqc7iwvqu 0nL8Qs1UelD913X2Qazfg+V3vrANicDqTGLX/WkmWuAMTm6/UNRhpVUB5PuuUoDkdpUZ 1YVKkjB/4JTu1IbwWLiLjkN9enLZAb3CrztuL7isi8iF7Zq7dSfA+ojTfYdpv4HJRzj6 2afm7OoEmXoOlhc766t0/b//onLx6Q9JDJWw4pH7ilOmoEL0pJAnURKz40UknKsMGysY 9mrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BW5XvzhOEYnKQm3m2bPpunSHZ2/5byROuxFoYEfv8cQ=; b=K8fGmpxh8BYk0aRLCSD+eAYB+Q95xsUyD6l+PCjgUC75i39rU6xaTkOcMmbSzvTNDx s+hzJl+kUfoXK8uevia6UKY+WGEaHDrcPrXBuBjeYkmXWWfmc7n/xxeCgDbKvxtzFmLw /Hw1dOK6qaEH1Zm7I5WRc+TAaCVP2WxufqnRbB0cEnhfJxcLP7DcAFU+xeLn66e66U0h mpDS1ob2Eh2vyPD9B5+R6e4rMEbTqFIAdM/jacaOM7dB3bRbVLRuge03EQZ8NTxGauXG ac/3PSqsmtsqiRliQVCxsDf9hvR2MFVisy2zWNUFglQNyNl4ms0ksbwcVg7p4Q3qKs2J laTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1fGL2WnZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l14si2667086qtu.233.2020.04.11.05.27.37; Sat, 11 Apr 2020 05:27:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1fGL2WnZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728167AbgDKMYz (ORCPT + 99 others); Sat, 11 Apr 2020 08:24:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:51804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727455AbgDKMRO (ORCPT ); Sat, 11 Apr 2020 08:17:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 46B0620644; Sat, 11 Apr 2020 12:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586607433; bh=gEa7ZsGQJJwe1Lbv3f9ZrcIEEZjZ69oRQJWfv5TR+Lc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1fGL2WnZnibXWio8e0Wbrh6bgus/9t2bwotv21ZifeyuO3CxpJgQ9A13et2ctqVIQ dCGnErq9Gv4Lbh6R8OAPmW+EQtPbo3SkaqA9UV1reIuXqTitHKwGPkeNVXRyv3stKZ 8UcXFQ+Tl8h1cgfhMI6VHEyxNMAErgzKn9TcZYxM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yury Norov , Allison Randal , Joe Perches , Thomas Gleixner , William Breathitt Gray , Andrew Morton , Linus Torvalds Subject: [PATCH 5.4 18/41] uapi: rename ext2_swab() to swab() and share globally in swab.h Date: Sat, 11 Apr 2020 14:09:27 +0200 Message-Id: <20200411115505.337339823@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200411115504.124035693@linuxfoundation.org> References: <20200411115504.124035693@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yury Norov commit d5767057c9a76a29f073dad66b7fa12a90e8c748 upstream. ext2_swab() is defined locally in lib/find_bit.c However it is not specific to ext2, neither to bitmaps. There are many potential users of it, so rename it to just swab() and move to include/uapi/linux/swab.h ABI guarantees that size of unsigned long corresponds to BITS_PER_LONG, therefore drop unneeded cast. Link: http://lkml.kernel.org/r/20200103202846.21616-1-yury.norov@gmail.com Signed-off-by: Yury Norov Cc: Allison Randal Cc: Joe Perches Cc: Thomas Gleixner Cc: William Breathitt Gray Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- include/linux/swab.h | 1 + include/uapi/linux/swab.h | 10 ++++++++++ lib/find_bit.c | 16 ++-------------- 3 files changed, 13 insertions(+), 14 deletions(-) --- a/include/linux/swab.h +++ b/include/linux/swab.h @@ -7,6 +7,7 @@ # define swab16 __swab16 # define swab32 __swab32 # define swab64 __swab64 +# define swab __swab # define swahw32 __swahw32 # define swahb32 __swahb32 # define swab16p __swab16p --- a/include/uapi/linux/swab.h +++ b/include/uapi/linux/swab.h @@ -4,6 +4,7 @@ #include #include +#include #include /* @@ -132,6 +133,15 @@ static inline __attribute_const__ __u32 __fswab64(x)) #endif +static __always_inline unsigned long __swab(const unsigned long y) +{ +#if BITS_PER_LONG == 64 + return __swab64(y); +#else /* BITS_PER_LONG == 32 */ + return __swab32(y); +#endif +} + /** * __swahw32 - return a word-swapped 32-bit value * @x: value to wordswap --- a/lib/find_bit.c +++ b/lib/find_bit.c @@ -149,18 +149,6 @@ EXPORT_SYMBOL(find_last_bit); #ifdef __BIG_ENDIAN -/* include/linux/byteorder does not support "unsigned long" type */ -static inline unsigned long ext2_swab(const unsigned long y) -{ -#if BITS_PER_LONG == 64 - return (unsigned long) __swab64((u64) y); -#elif BITS_PER_LONG == 32 - return (unsigned long) __swab32((u32) y); -#else -#error BITS_PER_LONG not defined -#endif -} - #if !defined(find_next_bit_le) || !defined(find_next_zero_bit_le) static inline unsigned long _find_next_bit_le(const unsigned long *addr1, const unsigned long *addr2, unsigned long nbits, @@ -177,7 +165,7 @@ static inline unsigned long _find_next_b tmp ^= invert; /* Handle 1st word. */ - tmp &= ext2_swab(BITMAP_FIRST_WORD_MASK(start)); + tmp &= swab(BITMAP_FIRST_WORD_MASK(start)); start = round_down(start, BITS_PER_LONG); while (!tmp) { @@ -191,7 +179,7 @@ static inline unsigned long _find_next_b tmp ^= invert; } - return min(start + __ffs(ext2_swab(tmp)), nbits); + return min(start + __ffs(swab(tmp)), nbits); } #endif