Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1935113rwl; Thu, 30 Mar 2023 03:45:47 -0700 (PDT) X-Google-Smtp-Source: AKy350bm+DNWjCLIM3KjOTDZ82rCzRNLHghDdApUblL65xVQzPKlXMalCwEssO5Jy4IVV5ydEt/U X-Received: by 2002:a17:906:297:b0:932:170:e07b with SMTP id 23-20020a170906029700b009320170e07bmr1386828ejf.7.1680173147689; Thu, 30 Mar 2023 03:45:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680173147; cv=none; d=google.com; s=arc-20160816; b=UJGOyyzW1gNlq2uhL1Zxx8tZxJm7WTFgqVoNFUX4oI1z43X2ZhPQFPKO/UVJpHD4dW fzbk3PjFsy8zm9PL619fByWzkF0elj2MRuOma2rbH4WPnGi5at94ZGuIJ0vJcGtBjEhz 2PZieta84Nsco/4sVYX9M5rRfbdUh4E2ky4TwMgFjcjdeanm9jobDJINACpHF3/WBpRs DnXBJb0HrX7hgLZ00SAbcmM02K28dIx7qfkvVwXjSlk3lBBgZejAtRje7ejYDk2Y6yxv 1hO910fiz3UWPw4ZDIqgHkBGRntPor1WfH3ozOUH/yPw3uLqMZKw8I8iiNWBwm8pMRCW zWSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8vtZr4PdFpIOpe7b33/e+92x/ecT0yfMcDTFq7fggbg=; b=xC/c1bjg0P5KJGARnCKEHSb8uGjCmxMoxY67+djqLvvJivTktKlMdPcfC60oeJN0k0 4nBILz+m+QvizHyRgGK9/qtbyyajDIv1RQoFubc9NJ+rkxV4w5iR5VH8bmK0Q8sCyEhS eT0cKelTF8zv+s7qTSFXC9Y9b3EMcrsF9KjhXNekqiSBZWoe18FvjR7z8YVOXGVFEbmH boiHQ/fWmn1EVRlhbcjfF+m3xDDIjJzYhmnZ9r4TCzEIHlFvAZNdLVOM45BwiYFQE93a i0OoJN253bQ02BomuROuRqNoPwx8URYpxgua3tTj86QzGfS/R0qVvWiERLAw0ad3z2cj lSBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Cw8NRigO; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20-20020a170906559400b0093e328cf51bsi89037ejp.519.2023.03.30.03.45.22; Thu, 30 Mar 2023 03:45:47 -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=@intel.com header.s=Intel header.b=Cw8NRigO; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230525AbjC3Knq (ORCPT + 99 others); Thu, 30 Mar 2023 06:43:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbjC3Knj (ORCPT ); Thu, 30 Mar 2023 06:43:39 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 036BD9026 for ; Thu, 30 Mar 2023 03:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680173014; x=1711709014; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iwNGwoGN+a9lCmnr/S987s6PbvaC/3YLfUXCi5FqKd8=; b=Cw8NRigOA7YqNN42FwH4y7P486xudgbazPqXXk5IHftV05+HkP8hQJc/ 2QLayJuSj3fq5t8eymsQJH7H4W5tnPpsPd4Za5cq4SlJkgnT2O1oLEu/L p0PqZKAQ8nd83PbNDzSHB6SQgA0snPsPWnjRp8T2hWVp8KbkCK/7xj/xP S5zyNgKUjxnjITxy8tIBVsZ1tznQsdRddc85BLzKJSjRaKLAuqJ0x5un9 gUDQYQ9AJa0lU1+iAAEO2HWBHC20XqzcZeSaJxgUgzgnQHyUkD2RtHOOx ikkaBsY8p+nszldAqL+WlE63WgSHfcTlQpGA/7Mk5ymOJeSlkqv2g251W g==; X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="321517761" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="321517761" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 03:43:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="661951481" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="661951481" Received: from unknown (HELO localhost) ([10.237.66.160]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 03:43:31 -0700 From: Jani Nikula To: linux-kernel@vger.kernel.org Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, jani.nikula@intel.com, Andrew Morton , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Gow Subject: [PATCH 3/4] log2: allow use of is_power_of_2() in constant expressions Date: Thu, 30 Mar 2023 13:42:42 +0300 Message-Id: <20230330104243.2120761-4-jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230330104243.2120761-1-jani.nikula@intel.com> References: <20230330104243.2120761-1-jani.nikula@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=unavailable 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 Even though the static inline functions are __attribute__((const)) you can't use them in constant expressions. Make is_power_of_2() a constant expression if possible. Cc: Andrew Morton Cc: Christian König Cc: David Gow Signed-off-by: Jani Nikula --- include/linux/log2.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/log2.h b/include/linux/log2.h index 4027d1eecd7f..447a85102de0 100644 --- a/include/linux/log2.h +++ b/include/linux/log2.h @@ -56,9 +56,11 @@ bool __is_power_of_2(unsigned long n) * Return: true if @n is a power of 2, otherwise false. */ #define is_power_of_2(n) \ - __builtin_choose_expr(sizeof(n) > sizeof(unsigned long), \ - __is_power_of_2_ull(n), \ - __is_power_of_2(n)) + __builtin_choose_expr(__is_constexpr(n), \ + __IS_POWER_OF_2(n), \ + __builtin_choose_expr(sizeof(n) > sizeof(unsigned long), \ + __is_power_of_2_ull(n), \ + __is_power_of_2(n))) /** * __roundup_pow_of_two() - round up to nearest power of two -- 2.39.2