Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6145301iog; Thu, 23 Jun 2022 12:16:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vNJMk1cVzjESryU9uB+2Tdou0sNsjTj36Wlx9Ts7CJ3RlqUDrgANmolLOc6Daep04FcVgK X-Received: by 2002:a17:903:247:b0:168:ecca:444 with SMTP id j7-20020a170903024700b00168ecca0444mr39703465plh.121.1656011809930; Thu, 23 Jun 2022 12:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011809; cv=none; d=google.com; s=arc-20160816; b=K2lC4OXamPZhf6QSom0/+yaPcklc8OAIL6VRjpAs/C7YRrVpgv5iUIPUXoN/hcfngQ syw8js/7AIgfJA4F8DaXhvZxAGjyTQAylmq8VDH/j8AMDMtO5yh3vVXxE5cnyok/vash D0ZkCpgek+zlO284TDiIUVMaGEy1nU1AuW9GWK2G59jN3hMfQM0q43HE4TBUcfnybRhr iI1KEjk04k8WO1G3q7hyu3vuT1vxegoR5YGmwI64Om3J/4E45p11WAuM/mkkX58bRmQo mtW9fvdpg+WimlWcn9rPSg7rXy6i8VU+IzRVR7d0CCa0bTI4gOBOBdkntgcDraoMVIO1 cgQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tXClrz99TyidR/YnyfqPriTqJC23tHwOblbAsmupbso=; b=K3qH5zEd+C9G2TlrfklFozRZnR7gYfwLarHCGS0zsVxS4P3wQWcC9hXfRVpQjsYGOC i9RSdK+Ajelf0wUxqCYEC6fTJc0HRFBU7ZcwjBA4Gl5FnVJyil9PTLV6FXmJJwBvBtgW tIDIkeNhqrp/k4MTy8Xp/4hM4xTaDAzQRuKl+lN6GvcVDM7lRTqr2JinOvXNWrD2VvO0 vi+g1v922gSPM9AwhHYkZ58NIdjFYJaaDXXOd0RjG39ZTD4WvWttisJNRxmisB5+00d6 egC6Wbu5FPVThHGOULFwj9QCgtrxsS4Rdyd1DquG8SogDYv0lI+truVSoGrG8OLBmk5K HO7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z7yt755r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t12-20020a170902e84c00b001637dbe1bc4si517631plg.44.2022.06.23.12.16.38; Thu, 23 Jun 2022 12:16:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z7yt755r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233066AbiFWRFR (ORCPT + 99 others); Thu, 23 Jun 2022 13:05:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233961AbiFWRDb (ORCPT ); Thu, 23 Jun 2022 13:03:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 908C950E02; Thu, 23 Jun 2022 09:55:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D56D2B82499; Thu, 23 Jun 2022 16:54:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8D31C3411B; Thu, 23 Jun 2022 16:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003295; bh=IrixH32uPNA8SrzjrToJPFG5vozAbai3k8bBrKhcugE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z7yt755rH96s4WMfiYQCfdf8q0jHKyoU+qrKW2fqvfDGZqgZ5wHKXXtRCagDoCqRI V429PBEzY9hwxxf/TxsUg7nFwdr6UbRK+8cU82cWWfpMkOEhAE68eBz9qEDGP1/bBU okMeQTBe0mIBKFPwu9HeX02o9JGdTnGPBJUNc1OE= 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 , Sasha Levin Subject: [PATCH 4.9 192/264] uapi: rename ext2_swab() to swab() and share globally in swab.h Date: Thu, 23 Jun 2022 18:43:05 +0200 Message-Id: <20220623164349.502210468@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yury Norov [ Upstream commit d5767057c9a76a29f073dad66b7fa12a90e8c748 ] 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: Sasha Levin 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 @@ -6,6 +6,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 @@ -3,6 +3,7 @@ #include #include +#include #include /* @@ -131,6 +132,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 @@ -133,18 +133,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 unsigned long _find_next_bit_le(const unsigned long *addr, unsigned long nbits, unsigned long start, unsigned long invert) @@ -157,7 +145,7 @@ static unsigned long _find_next_bit_le(c tmp = addr[start / BITS_PER_LONG] ^ 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) { @@ -168,7 +156,7 @@ static unsigned long _find_next_bit_le(c tmp = addr[start / BITS_PER_LONG] ^ invert; } - return min(start + __ffs(ext2_swab(tmp)), nbits); + return min(start + __ffs(swab(tmp)), nbits); } #endif