All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"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-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	alsa-devel@alsa-project.org
Cc: 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 v1 2/4] lib/math/int_log: Use ARRAY_SIZE(logtable) where makes sense
Date: Mon, 19 Jun 2023 20:20:17 +0300	[thread overview]
Message-ID: <20230619172019.21457-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20230619172019.21457-1-andriy.shevchenko@linux.intel.com>

Use ARRAY_SIZE(logtable) where makes sense.

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-06-19 17:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 17:20 [PATCH v1 0/4] ASoC: remove copy of intlog10() Andy Shevchenko
2023-06-19 17:20 ` [PATCH v1 1/4] lib/math: Move dvb_math.c into lib/math/int_log.c Andy Shevchenko
2023-07-03  6:14   ` Mauro Carvalho Chehab
2023-06-19 17:20 ` Andy Shevchenko [this message]
2023-07-03  6:15   ` [PATCH v1 2/4] lib/math/int_log: Use ARRAY_SIZE(logtable) where makes sense Mauro Carvalho Chehab
2023-06-19 17:20 ` [PATCH v1 3/4] lib/math/int_log: Replace LGPL-2.1-or-later boilerplate with SPDX identifier Andy Shevchenko
2023-07-03  6:16   ` Mauro Carvalho Chehab
2023-06-19 17:20 ` [PATCH v1 4/4] ASoC: nau8825: Replace copied'n'pasted intlog10() Andy Shevchenko
2023-06-19 17:43   ` Mark Brown
2023-07-03  6:18 ` [PATCH v1 0/4] ASoC: remove copy of intlog10() Mauro Carvalho Chehab

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=20230619172019.21457-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=crope@iki.fi \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=lgirdwood@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.