From patchwork Mon Jul 3 13:52:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 699148 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 98322C001E0 for ; Mon, 3 Jul 2023 13:52:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231434AbjGCNwi (ORCPT ); Mon, 3 Jul 2023 09:52:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231509AbjGCNwg (ORCPT ); Mon, 3 Jul 2023 09:52:36 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B7D4E69; Mon, 3 Jul 2023 06:52:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688392354; x=1719928354; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yiDh5WIcW2KT2120kFMdLbZdsriKf6EVEQj+JVu7p4Q=; b=ZeUGsoQqoY1NDxeoI7D1N0FbIbu3vBG3FcmCGST+pV33wUDoFo5DW1UD dK2wFRWkEwVLGbQmBrvUtKf7dcEoND3sNmxX6ZD+MY5BwMRfipgcERnkA GtSOhukNxOO1mybwEphBeJKmEdMozWZuSxhxo0veFPwesdhRdXY6RWLS6 chzsRt988eEDZksgWGtM1laVIplzwNoTYswWxDAspWw5weLdKkr0fznmB hJTUAtnpTFx3ISXZVHuzIo3lYUE25hoZN2kPSescorj4o8BNhV2aQNOzG oBv//TCEoVop9AGKmPfBym1+tRxqx39wU6BCzwtFEUrcPTTM6eWaV4cBd Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="347673035" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="347673035" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 06:52:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="863093278" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="863093278" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 03 Jul 2023 06:52:26 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E5C3C177; Mon, 3 Jul 2023 16:52:29 +0300 (EEST) From: Andy Shevchenko To: Mauro Carvalho Chehab , Andy Shevchenko , Hans Verkuil , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Mark Brown , David Lin , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, alsa-devel@alsa-project.org Cc: Jonathan Corbet , Antti Palosaari , Sergey Kozlov , Abylay Ospan , Yasunari Takiguchi , Michael Krufky , Matthias Schwarzott , Akihiro Tsukada , Liam Girdwood , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v2 2/4] lib/math/int_log: Use ARRAY_SIZE(logtable) where makes sense Date: Mon, 3 Jul 2023 16:52:09 +0300 Message-Id: <20230703135211.87416-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703135211.87416-1-andriy.shevchenko@linux.intel.com> References: <20230703135211.87416-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use ARRAY_SIZE(logtable) where makes sense. Reviewed-by: Mauro Carvalho Chehab Acked-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/20230619172019.21457-3-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko --- lib/math/int_log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/math/int_log.c b/lib/math/int_log.c index 322df25a22d6..ea98fc0b3fe2 100644 --- a/lib/math/int_log.c +++ b/lib/math/int_log.c @@ -91,7 +91,7 @@ unsigned int intlog2(u32 value) * so we would use the entry 0x18 */ significand = value << (31 - msb); - logentry = (significand >> 23) & 0xff; + logentry = (significand >> 23) % ARRAY_SIZE(logtable); /** * last step we do is interpolation because of the @@ -109,7 +109,7 @@ unsigned int intlog2(u32 value) * logtable_next is 256 */ interpolation = ((significand & 0x7fffff) * - ((logtable[(logentry + 1) & 0xff] - + ((logtable[(logentry + 1) % ARRAY_SIZE(logtable)] - logtable[logentry]) & 0xffff)) >> 15; /* now we return the result */