Message ID | 20170604081123.19462-33-alexander.levin@verizon.com |
---|---|
State | New |
Headers | show
Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp439844qgd; Sun, 4 Jun 2017 01:13:31 -0700 (PDT) X-Received: by 10.84.231.16 with SMTP id f16mr8465374plk.259.1496564011140; Sun, 04 Jun 2017 01:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496564011; cv=none; d=google.com; s=arc-20160816; b=t7HdeqSAMOCnMCQbyz48pzCtj6mXH2JKhLeFGb7prBAPmoIDpk+4dKEVdU/bona96S BPjfhAwP5Ka0TAszkFDhGYc6jovzkMjipRXsx+cBf4P5YqNVyFRzZNBT91AJHHRJhcCY Hz3tqSlRwCqZK+ohFo7PH0ZXK04jw0s2thcWeYmaYmhTTBxlZRO3sVINiwUYXXSimy4r yVf+4B34ufAVNTaCnUd90j3IKS7nRh8Mh9cIlFNL0TaObbLa3s+X0uRDUtRmXrZhLe+Q h/k4DismMUNYWOPF+K5f6I0v3hilv6j2m9l6GfEaKfR6y/LOzyb+PtBKwRw4MgHbiv/z 6JAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:dkim-signature:cc:from :dkim-signature:arc-authentication-results; bh=FecJ+OBXfirWyUjNX/yMTspJ9cTYxYijisTOjh97bl4=; b=tU4mpyqZdUK/wQn96Otp16JYNmHsfYUwe/jTwiUxbFuuzq01CaHbCvK1xKeaYp9bj9 Zt8qXNn26iG1WjP6Fkc69ibdQigOnt6cba7X+A4v0jOFnjGH+XkEH1jClRb4nmEBRLsl kHplyIij5MqUl3Doo7ADRzTm85fc9CPRasdSLJwVXOt05c23EnVz0BzW+4o6Ffr5D67b f73RUwb1gMmePw78u9GCjNHyGjORCs3FqdeOWmzNOjwkm4Uh2MUKB+S0mvslvEN4u0Nu hzENSHjkgr8xy0K/MZHcZ5HGK8xnNEVPGCbWmgYLGKOB6olCYO9VL1B7GIxb9QNICptP ORDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verizon.com; dkim=fail header.i=@verizon.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Return-Path: <stable-owner@vger.kernel.org> Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j17si27669684pfj.239.2017.06.04.01.13.30; Sun, 04 Jun 2017 01:13:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@verizon.com; dkim=fail header.i=@verizon.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751258AbdFDINa (ORCPT <rfc822;sumit.semwal@linaro.org> + 6 others); Sun, 4 Jun 2017 04:13:30 -0400 Received: from omzsmtpe02.verizonbusiness.com ([199.249.25.209]:40917 "EHLO omzsmtpe02.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751213AbdFDINM (ORCPT <rfc822;stable@vger.kernel.org>); Sun, 4 Jun 2017 04:13:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1496563992; x=1528099992; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=U6PeU6FB2gA2USq6uChQHLsZd5iTk8wVh8RLiQFW5Dk=; b=n9uGVeqeykyYLq7OPdxgrZRhRqGd/NANHIYeErMvJBNYlSkI0MBJ/eY7 S27aj+tF0t0BY/dWV9Sq89UZRFkpl3sL5OPW5qEcs6dzTszK6ck3O3Zqa uH9syEqjIpLFvQUKBsAKugEy3daaNvqq0Lexn4kqNARGXbB/O0ywjVuxh g=; X-IronPort-Anti-Spam-Filtered: false Received: from unknown (HELO fldsmtpi03.verizon.com) ([166.68.71.145]) by omzsmtpe02.verizonbusiness.com with ESMTP; 04 Jun 2017 08:13:00 +0000 From: "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>, Linus Torvalds <torvalds@linux-foundation.org>, "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com> X-IronPort-AV: E=Sophos;i="5.39,295,1493683200"; d="scan'208";a="364211578" Received: from nord.tdc.vzwcorp.com (HELO Nord.verizonwireless.com) ([10.254.88.187]) by fldsmtpi03.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 04 Jun 2017 08:12:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1496563961; x=1528099961; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=U6PeU6FB2gA2USq6uChQHLsZd5iTk8wVh8RLiQFW5Dk=; b=ogZGBcB4V+39YcM/OYE/AyerryU1/NwRzgIT1dqK8t1+QsChsrXOeqYf Oduko25sevhLGAcpQBfhuH2FYAJzo+RY0rdzT2nJJ83j8T4KIiDgc7R49 l0pfemXN/Vp3BtEaSxJsVcDC6atrH4oIrEPmpxWkI1/WijGSRoI845fuF E=; Received: from gaalpexhub4.uswin.ad.vzwcorp.com ([10.191.138.113]) by Nord.verizonwireless.com with ESMTP/TLS/AES256-SHA; 04 Jun 2017 04:12:40 -0400 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by gaalpexhub4.uswin.ad.vzwcorp.com (10.191.138.113) with Microsoft SMTP Server (TLS) id 8.3.406.0; Sun, 4 Jun 2017 04:12:40 -0400 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Sun, 4 Jun 2017 03:12:38 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Sun, 4 Jun 2017 03:12:38 -0500 To: "stable@vger.kernel.org" <stable@vger.kernel.org> Subject: [PATCH for v4.9 LTS 033/111] log2: make order_base_2() behave correctly on const input value zero Thread-Topic: [PATCH for v4.9 LTS 033/111] log2: make order_base_2() behave correctly on const input value zero Thread-Index: AQHS3QpCM7uDYJwyBE6gckDfYqKQkA== Date: Sun, 4 Jun 2017 08:12:08 +0000 Message-ID: <20170604081123.19462-33-alexander.levin@verizon.com> References: <20170604081123.19462-1-alexander.levin@verizon.com> In-Reply-To: <20170604081123.19462-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: <stable.vger.kernel.org> X-Mailing-List: stable@vger.kernel.org |
Series |
None
|
expand
|
diff --git a/include/linux/log2.h b/include/linux/log2.h index f38fae23bdac..c373295f359f 100644 --- a/include/linux/log2.h +++ b/include/linux/log2.h @@ -194,6 +194,17 @@ unsigned long __rounddown_pow_of_two(unsigned long n) * ... and so on. */ -#define order_base_2(n) ilog2(roundup_pow_of_two(n)) +static inline __attribute_const__ +int __order_base_2(unsigned long n) +{ + return n > 1 ? ilog2(n - 1) + 1 : 0; +} +#define order_base_2(n) \ +( \ + __builtin_constant_p(n) ? ( \ + ((n) == 0 || (n) == 1) ? 0 : \ + ilog2((n) - 1) + 1) : \ + __order_base_2(n) \ +) #endif /* _LINUX_LOG2_H */