public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Hans Verkuil" <hverkuil-cisco@xs4all.nl>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Mark Brown" <broonie@kernel.org>,
	"David Lin" <CTLIN0@nuvoton.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-media@vger.kernel.org, alsa-devel@alsa-project.org
Cc: Jonathan Corbet <corbet@lwn.net>, Antti Palosaari <crope@iki.fi>,
	Sergey Kozlov <serjk@netup.ru>, Abylay Ospan <aospan@netup.ru>,
	Yasunari Takiguchi <Yasunari.Takiguchi@sony.com>,
	Michael Krufky <mkrufky@linuxtv.org>,
	Matthias Schwarzott <zzam@gentoo.org>,
	Akihiro Tsukada <tskd08@gmail.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
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	[thread overview]
Message-ID: <20230703135211.87416-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20230703135211.87416-1-andriy.shevchenko@linux.intel.com>

Use ARRAY_SIZE(logtable) where makes sense.

Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Link: https://lore.kernel.org/r/20230619172019.21457-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 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 */
-- 
2.40.0.1.gaa8946217a0b


  parent reply	other threads:[~2023-07-03 13:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-03 13:52 [PATCH v2 0/4] ASoC: remove copy of intlog10() Andy Shevchenko
2023-07-03 13:52 ` [PATCH v2 1/4] lib/math: Move dvb_math.c into lib/math/int_log.c Andy Shevchenko
2023-07-03 22:31   ` Randy Dunlap
2023-07-03 13:52 ` Andy Shevchenko [this message]
2023-07-03 13:52 ` [PATCH v2 3/4] lib/math/int_log: Replace LGPL-2.1-or-later boilerplate with SPDX identifier Andy Shevchenko
2023-07-03 13:52 ` [PATCH v2 4/4] ASoC: nau8825: Replace copied'n'pasted intlog10() Andy Shevchenko
2023-07-12 11:47 ` [PATCH v2 0/4] ASoC: remove copy of intlog10() Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230703135211.87416-3-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=CTLIN0@nuvoton.com \
    --cc=Yasunari.Takiguchi@sony.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=aospan@netup.ru \
    --cc=broonie@kernel.org \
    --cc=corbet@lwn.net \
    --cc=crope@iki.fi \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=lgirdwood@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mkrufky@linuxtv.org \
    --cc=perex@perex.cz \
    --cc=serjk@netup.ru \
    --cc=tiwai@suse.com \
    --cc=tskd08@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=zzam@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox