Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1390369ybs; Mon, 25 May 2020 15:02:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykOMY8EdVW6Ue4CVpEd6FjUrw8vF3jSHlqW6Xz+VFPRUo5iVB6Uzz4w7rAiUMZ5OVIFtHo X-Received: by 2002:a17:906:7a1c:: with SMTP id d28mr19713418ejo.10.1590444139594; Mon, 25 May 2020 15:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590444139; cv=none; d=google.com; s=arc-20160816; b=MOTuw8jhbeFoJ67aVcYE5KATfoX0PAG8aUlwrwunC8or769v2/SEzwxF2Y5nwYku1E xDqVbH+rMJO51PKwTCxSSUhchIAKPlFuI75aRM7IltkzUJR8D1hXmMwdBIPXQ5FthnPA zI8VlbxmwwC/1yfl9itvdJV89/1aGpcKUMaWrR5+PkGO0GMan1AGhLWRqDNKQV1Ln4Nj NN+5Z3X42dSg0MMO8d42U6K/E4nH0yB0UaWyT73CRIRJSYmjqya+DW13OVCVnkVxQ7vV 1tu1GsvvHf7rWG6+DReEVVHHX5qE2gusGGzHHrNxKR6oAqHTzf6MfvMZYS0uljv2PF1Z MKQQ== 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=O655F/SobHiBfw89KwZt4cdPafswvir9iAWsC16mmk4=; b=xQ1gY7zWWoYe4aMm7U/ggeH2NWBDTnk6iF2LEeEd7TSjI8JZw5mmJk4h+IE8g/Xh/m 1QgY0/AvvEmbSJ+wje9z0LKqJ+L8KYR+IyI6PLXCA1jlst6E7N/twTVnm9nPmK+RFuOA YL9Spevuyw+Y22UnjRuul6bwWbK88FqH/8R9DvULODu8Mgjs4CvSG+B+1gG0IiBfU5ec GPR9Vs6eI1ixl9uQZfXtTKhNJ/r6og3Y7tYFxT6twMwkUKNC3rO11B7vLVXAfkXtZiS4 pYgQijO65B+O8oTQhG2ZjewHAwuyk4MEl2Q4Z2or8yQbvwth/EjubBVbPuFPTzohTI2w gvGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ur5vYE+M; 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 p4si10115900ejr.36.2020.05.25.15.01.57; Mon, 25 May 2020 15:02:19 -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=Ur5vYE+M; 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 S1731296AbgEYWAW (ORCPT + 99 others); Mon, 25 May 2020 18:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727842AbgEYWAV (ORCPT ); Mon, 25 May 2020 18:00:21 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 228E2C061A0E for ; Mon, 25 May 2020 15:00:20 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id k19so16078492edv.9 for ; Mon, 25 May 2020 15:00:20 -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=O655F/SobHiBfw89KwZt4cdPafswvir9iAWsC16mmk4=; b=Ur5vYE+MTeBS1LfJ+Bssiq/4pJZ7hq6BjlwzZWAEJxTZKmvhKKR+7vRrPuuFIiiOC8 fgi/2+MM2Vs995z/jr6ybwwGcNfbzYYEC25G8zKmUAp4M0OJFMre7L+iSL9To5/sGN1B 6JuHZ4lRGG5ar1BsBxl+Ez2qmMnwHQtkLE6BVWiVCeR9Q3sWaK8pKO8eRTn8myH43VUz pI/u3T5NLN3KGS7v5MFevd+ma6b0IlH7UZeVeanLJtv/7jFWapEj4IMHuGkcBWTEzNmd Kcq33Cxg74UNkYWV2VYzxUTMX8PYUa0aRNmFkupCsxhVwjSmwo8qR3jBXlnkOcA9hzB1 EJig== 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=O655F/SobHiBfw89KwZt4cdPafswvir9iAWsC16mmk4=; b=KUdVtH6QtQJevsFjCr/Pjprj+lbNCLYSrWNBckHvqN0o9fNOYeJtYyldW9u/898Eza 8xMXFNiPH8oRxuisWRBeIVxMFiKRPG5srh7RC4vpfRcP6/Ghwov0f5Vm26OeIUhhlDaZ WFu3jNpbF6jXbhm33hQGvIV0/aMg8V4JHqV06+IybSm1ykQM9dZcIm8mrhKvCc9qWg2x xf28oUvi+xHt8TQ+bIIJAJlvvD4zSavCSakjVy36lXNcEcyXPp5vEcSK31NqEfbjjaEu lPlesFFdtT63mxgA0n6yQS3yQPZYPTq5SHa8/VJ8y9iWp46Y1cXtm2PzY6NpmlhEhbfE jIYw== X-Gm-Message-State: AOAM533ytoa3mvxX24wxtwJLMvfo0Pvfbe7Y0f9AMY1HH6kUpNl1C//B 4Gh/YYE/6Y4DHmZapOGV68C+gpcX X-Received: by 2002:a50:a693:: with SMTP id e19mr16485374edc.275.1590444018874; Mon, 25 May 2020 15:00:18 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id b13sm16935486edw.50.2020.05.25.15.00.18 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 May 2020 15:00:18 -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: use the same mechanism for get_count_order[_long] Date: Mon, 25 May 2020 21:59:58 +0000 Message-Id: <20200525215958.21653-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 functions share the same logic. Signed-off-by: Wei Yang --- include/linux/bitops.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 5b5609e81a84..80703ef27aee 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -188,12 +188,10 @@ static inline unsigned fls_long(unsigned long l) static inline int get_count_order(unsigned int count) { - int order; + if (count == 0) + return -1; - order = fls(count) - 1; - if (count & (count - 1)) - order++; - return order; + return fls(--count); } /** -- 2.23.0