From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3F30C433EF for ; Mon, 22 Nov 2021 08:55:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238891AbhKVI6o (ORCPT ); Mon, 22 Nov 2021 03:58:44 -0500 Received: from mga17.intel.com ([192.55.52.151]:14195 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbhKVI6l (ORCPT ); Mon, 22 Nov 2021 03:58:41 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10175"; a="215462024" X-IronPort-AV: E=Sophos;i="5.87,254,1631602800"; d="scan'208";a="215462024" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2021 00:55:35 -0800 X-IronPort-AV: E=Sophos;i="5.87,254,1631602800"; d="scan'208";a="456212291" Received: from rmcdonax-mobl.ger.corp.intel.com (HELO localhost) ([10.252.19.217]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2021 00:55:31 -0800 From: Jani Nikula To: Arnd Bergmann , Alejandro Colomar Cc: LKML , Andy Shevchenko , Arnd Bergmann , Alexey Dobriyan , Rasmus Villemoes , Kees Cook , Joe Perches Subject: Re: [PATCH v2 18/20] linux/power_of_2.h: Add __IS_POWER_OF_2(n) and __IS_POWER_OF_2_OR_0(n) macros In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20211119113644.1600-1-alx.manpages@gmail.com> <20211120130104.185699-1-alx.manpages@gmail.com> <20211120130104.185699-20-alx.manpages@gmail.com> Date: Mon, 22 Nov 2021 10:55:28 +0200 Message-ID: <87r1b8o9hb.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 21 Nov 2021, Arnd Bergmann wrote: > On Sat, Nov 20, 2021 at 2:01 PM Alejandro Colomar > wrote: >> + >> +#define __IS_POWER_OF_2_OR_0(n) (((n) & ((n) - 1)) == 0) >> +#define __IS_POWER_OF_2(n) (__IS_POWER_OF_2_OR_0(n) && ((n) != 0)) >> + > > There is already is_power_of_2() in include/linux/log2.h, which would > be preferred > in most cases. If you need a macro version, put it in the same file > and explain why it's > needed. Also, the macro argument n is evaluated 2-3 times. Please use checkpatch.pl --strict argument on the patches, and it'll give you hints about this stuff too. BR, Jani. -- Jani Nikula, Intel Open Source Graphics Center