Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp294215ybs; Sun, 24 May 2020 05:40:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6MLaAT8T08PBl6H+/NYNX7qxcBvOgbzoowSFXJpnjYHG148RxNSTSrfq8zwEEzk3s23eD X-Received: by 2002:a17:906:2c03:: with SMTP id e3mr14797813ejh.206.1590324022328; Sun, 24 May 2020 05:40:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590324022; cv=none; d=google.com; s=arc-20160816; b=OwZ2b6JQYpcwwd+tswe7leg6uDr5E8QtM9HzUPbTjduGLw37zYdpXx2RJuERXwuiO0 +MhwksNZyCQpFuUYwOEu7uXqcgusvN5EoSStqDkTL29OLdejzUIErDkbycsyVlL1j/3R QWPWDh6Thcj6ATS+SRha781DTaYl2P9i8d23rf0CYfYE4arKyrj7hAkbtuElVXgW6Q1N jZv9s1PYPRNT5hj0Pbktz182fUfMoUTj9t08Vd1SE1ZOF7WSHiBL+6rrpSFLYrGUkxE8 8kDo8Y/wMSf9idpaXsf10AwhuQMAkw2HrSUko/+1KzFA3n6GZo6/q2MLMKC/lukEEfDY GlFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=XKDhsQ5sTY9fRZdUNyusZ0FDVI/AcG2vut+gn5kNrHM=; b=eOikiXQgixiC52GQayIbn4DORN49v6y6Xsj49gvAA78FtPb82gR021saBqSZJqVD4o zqJ3qNDvxNpa+pD4ck/vvgbc1SaSnnvggA1au+aRrP24p9n4kahGyqQt+yLtc3Ma0uwf mmWQi+zWSsWVXJrgOryWK7PRYc0HHLHJGs6P7cqCXvyeZElWyFjMwYytsT8W44OIpICR DC+fpUF8gQten2Y28Zy1WHugetOVKPMqXtWDeeIuq59QI4jJ6uZhmvvWcSnnsnCuXQb3 W4zuiYz5gDfXcsT6yt9AUJBTgIpET3gyZAEc6bHVxBFavO1IADiMmC23h8FO2X9vZc/r 7Kxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hbcF8bcl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si7862843ede.53.2020.05.24.05.39.59; Sun, 24 May 2020 05:40:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hbcF8bcl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387629AbgEXMgA (ORCPT + 99 others); Sun, 24 May 2020 08:36:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726734AbgEXMf7 (ORCPT ); Sun, 24 May 2020 08:35:59 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F339C061A0E for ; Sun, 24 May 2020 05:35:59 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id x20so17852284ejb.11 for ; Sun, 24 May 2020 05:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=XKDhsQ5sTY9fRZdUNyusZ0FDVI/AcG2vut+gn5kNrHM=; b=hbcF8bclIaz/TiOQjjoaTSqfCFG98h+14xlDBvAIVi69diKFdF98taSitLT+iakQLE MN2kKGjDdwqWvwByb9IsGy8fImecckucu0LD292qlbCxLLd47QaLZmZYZd4zOLLriraA xn9ixkfUaEpnrEeBxwMqYWvrR2SYsBEaqj/ZOF3sVTd64mlaImg+ABJakgNszPBXBZ8I mol3PPkVz5HvjCLW8yaiQRny3VtsTgPH9+7pquQUD9l/Bb5r694Awi0l8YAN8AOXLbiy Ykpc9v/VO8OP3SWhUrek8YiRjezFnt67V4gLocw8ROrh2miZeYZ/XEKNTaYm3UVGECnr 2MjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XKDhsQ5sTY9fRZdUNyusZ0FDVI/AcG2vut+gn5kNrHM=; b=q/7wl+wssp1wHRBN9n91WCaYCUQYfG2JrSOhy7NzqMp7gUK9ZladZFa4y3kqEcthEX uD1ldNRlVljwzvSKeCckBn0vzSVvldkuxTKFIZp/4NskEYQxAH7knuWhHtpgEspkODiI ty3I+AbAZuSImbsecwn9J+9NimQUlGmffLZ3Fm3EApNFdAsz8fjw9cQWuOJvge33Fc+w dkP/VGEy48+rooVZXczyr1+V9WrJuqR/1kG3pkDy2zKF8s/XpTRPdgZbpMF1f1ZHtVPe v/ocIRbi4TMrNakJ0RH4+1PMGU32Bn2eN27DoUEg70bCv/z0iA90niaWM5zFPddIJBKO sWjA== X-Gm-Message-State: AOAM533NbONKZdXoaw+QMo0l9SqahsrcpjZIyspSrLnlMKCbA4TPbFLz ioFoTVkmmg9BuivRwTIqK8w= X-Received: by 2002:a17:907:11cb:: with SMTP id va11mr16010089ejb.515.1590323758211; Sun, 24 May 2020 05:35:58 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id r13sm1842806edq.53.2020.05.24.05.35.57 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 May 2020 05:35:57 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, christian.brauner@ubuntu.com Cc: linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH] bitops: simplify get_count_order_long() Date: Sun, 24 May 2020 12:35:51 +0000 Message-Id: <20200524123551.9469-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These two cases could be unified into one. Signed-off-by: Wei Yang --- include/linux/bitops.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 9acf654f0b19..5b5609e81a84 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -206,10 +206,7 @@ static inline int get_count_order_long(unsigned long l) { if (l == 0UL) return -1; - else if (l & (l - 1UL)) - return (int)fls_long(l); - else - return (int)fls_long(l) - 1; + return (int)fls_long(--l); } /** -- 2.23.0