Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1516523ybb; Sat, 11 Apr 2020 05:26:26 -0700 (PDT) X-Google-Smtp-Source: APiQypJAeTfMlgW5wEo61ZmDJ6wHmi2KGdnOUrUkQng7CHqJBFzRbD5qbtni9KWOZMVhgXI8wdbX X-Received: by 2002:a37:b93:: with SMTP id 141mr8229473qkl.192.1586607986432; Sat, 11 Apr 2020 05:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586607986; cv=none; d=google.com; s=arc-20160816; b=B64DNtVMjT9QFsTCnHu/FFkjmpR+LuAt8ZCqu9BSjuoCBm4Ncn1H6rtLkb3Qn9Gqwj 35AI2uz5kebcTEPK7wNwwLKD9HUNcm6csM967HC/t9Lo1hMrUeM9P3EUtq2kLDMtJtzw eio7v035b8Ks9Hp6RDqyxoG0I2Ur66g6k8kcZbMWQlrKQya4pw2SsQOopfsuZ70a+Jcj LfkOxZWKd0NKcrM2j925SuXYAtKmzF/HhnkYsUKq6WRGSOzNoX9k+fRduoo3edZ9BW0m KLQ6VNwG64WviKwcsAAq/HBf8SHl6zIqfeLxjFRjEtfySLQjhllvySbGiU3aPv1aeoqI HtTw== 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=B5yfAq1VD/rszii0GYGsIeKeWI9x2svMOKzdiq9wvIIl6+4AAMhz8PTmgf9Fb3rswv xW+jMhtJk+WwvzwaufrqqIKRtXdyvIwlXKumNgr3jAcfSsOWdkLHzoqCBXUURHYahdNQ meqA3E4+IOtu8hpEn8fOy+Nq9IELyvPexabdNMlZXq8Nq1P0KnUoT79jfCeoyq3GByJB VpV6MBYBXkIP7QEnZFh86UbIfx4b0wtlamLyBWf2scpXSUSUoUNeB6JQmXHnnpFqNYCS v7BNJPRLd5jsbuPHUYduFw1h9oHYQzmMGsVFKM9xkn7218pEPqlwMsPCmw/YSJwl7V4I MYLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UJJVsV7J; 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 a8si2842969qvf.2.2020.04.11.05.26.12; Sat, 11 Apr 2020 05:26:26 -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=UJJVsV7J; 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 S1728593AbgDKMXs (ORCPT + 99 others); Sat, 11 Apr 2020 08:23:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:54104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728702AbgDKMS5 (ORCPT ); Sat, 11 Apr 2020 08:18:57 -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 B273F20644; Sat, 11 Apr 2020 12:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586607537; bh=gEa7ZsGQJJwe1Lbv3f9ZrcIEEZjZ69oRQJWfv5TR+Lc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UJJVsV7JRUE2Hwm7+P3Mw6bQbYE42uw5+QoxpT3YohBc+JkpsKYfqGEE7q7ZENNzH 842wt0i/6t7YgHyOAidKskRhqR03K7nZKoxYNE9DJ7KmxTxKgZj21vdae60mh6njWA jd2xHgHzBFKUHUljdWZkuCTr4Yp87tzwlfoQUv24= 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.5 19/44] uapi: rename ext2_swab() to swab() and share globally in swab.h Date: Sat, 11 Apr 2020 14:09:39 +0200 Message-Id: <20200411115458.679771748@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200411115456.934174282@linuxfoundation.org> References: <20200411115456.934174282@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