mbox series

[v1,0/4] ASoC: remove copy of intlog10()

Message ID 20230619172019.21457-1-andriy.shevchenko@linux.intel.com
Headers show
Series ASoC: remove copy of intlog10() | expand

Message

Andy Shevchenko June 19, 2023, 5:20 p.m. UTC
The first three patches moves intlog10() to be available in entire
kernel. The last one removes copy of it in one driver. Besides already
good Lines of Code (LoC) statistics the upcoming users, if any, can
utilize the exported functions.

The series can be routed either via ASoC tree or media tree.

Note, int_log.h is separated from math.h due to licensing.
I dunno if we can mix two in a single header file. In any
case we may do it later on.

Andy Shevchenko (4):
  lib/math: Move dvb_math.c into lib/math/int_log.c
  lib/math/int_log: Use ARRAY_SIZE(logtable) where makes sense
  lib/math/int_log: Replace LGPL-2.1-or-later boilerplate with SPDX
    identifier
  ASoC: nau8825: Replace copied'n'pasted intlog10()

 Documentation/driver-api/media/dtv-common.rst |  2 +-
 drivers/media/dvb-core/Makefile               |  2 +-
 drivers/media/dvb-frontends/af9013_priv.h     |  2 +-
 drivers/media/dvb-frontends/af9033_priv.h     |  2 +-
 drivers/media/dvb-frontends/cxd2820r_priv.h   |  2 +-
 drivers/media/dvb-frontends/cxd2841er.c       |  2 +-
 .../cxd2880/cxd2880_tnrdmd_dvbt2_mon.c        |  2 +-
 .../cxd2880/cxd2880_tnrdmd_dvbt_mon.c         |  2 +-
 .../media/dvb-frontends/cxd2880/cxd2880_top.c |  2 +-
 drivers/media/dvb-frontends/dib7000p.c        |  2 +-
 drivers/media/dvb-frontends/dib8000.c         |  2 +-
 drivers/media/dvb-frontends/dib9000.c         |  2 +-
 drivers/media/dvb-frontends/drxk_hard.c       |  2 +-
 drivers/media/dvb-frontends/lgdt3305.c        |  2 +-
 drivers/media/dvb-frontends/lgdt3306a.c       |  2 +-
 drivers/media/dvb-frontends/lgdt330x.c        |  2 +-
 drivers/media/dvb-frontends/m88ds3103_priv.h  |  2 +-
 drivers/media/dvb-frontends/mn88443x.c        |  2 +-
 drivers/media/dvb-frontends/mn88472_priv.h    |  2 +-
 drivers/media/dvb-frontends/mn88473_priv.h    |  2 +-
 drivers/media/dvb-frontends/or51132.c         |  2 +-
 drivers/media/dvb-frontends/or51211.c         |  2 +-
 drivers/media/dvb-frontends/rtl2830_priv.h    |  2 +-
 drivers/media/dvb-frontends/rtl2832_priv.h    |  2 +-
 drivers/media/dvb-frontends/si2165.c          |  2 +-
 drivers/media/dvb-frontends/stv0367.c         |  2 +-
 drivers/media/dvb-frontends/tc90522.c         |  2 +-
 drivers/media/dvb-frontends/tda10048.c        |  2 +-
 include/{media/dvb_math.h => linux/int_log.h} | 18 +---
 lib/math/Makefile                             |  2 +-
 .../dvb-core/dvb_math.c => lib/math/int_log.c | 26 ++----
 sound/soc/codecs/nau8825.c                    | 93 +------------------
 32 files changed, 45 insertions(+), 150 deletions(-)
 rename include/{media/dvb_math.h => linux/int_log.h} (63%)
 rename drivers/media/dvb-core/dvb_math.c => lib/math/int_log.c (84%)

Comments

Mauro Carvalho Chehab July 3, 2023, 6:15 a.m. UTC | #1
Em Mon, 19 Jun 2023 20:20:17 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> escreveu:

> Use ARRAY_SIZE(logtable) where makes sense.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>

> ---
>  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 */
Mauro Carvalho Chehab July 3, 2023, 6:18 a.m. UTC | #2
Em Mon, 19 Jun 2023 20:20:15 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> escreveu:

> The first three patches moves intlog10() to be available in entire
> kernel. The last one removes copy of it in one driver. Besides already
> good Lines of Code (LoC) statistics the upcoming users, if any, can
> utilize the exported functions.
> 
> The series can be routed either via ASoC tree or media tree.
> 
> Note, int_log.h is separated from math.h due to licensing.
> I dunno if we can mix two in a single header file. In any
> case we may do it later on.
> 
> Andy Shevchenko (4):
>   lib/math: Move dvb_math.c into lib/math/int_log.c
>   lib/math/int_log: Use ARRAY_SIZE(logtable) where makes sense
>   lib/math/int_log: Replace LGPL-2.1-or-later boilerplate with SPDX
>     identifier
>   ASoC: nau8825: Replace copied'n'pasted intlog10()

It probably makes sense to apply it at ASoC tree, as the relevant
change is there.

I have just one small nit on patch 1/4, which should be trivial to
solve. Once done, feel free to merge it with  my ack:

Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>

> 
>  Documentation/driver-api/media/dtv-common.rst |  2 +-
>  drivers/media/dvb-core/Makefile               |  2 +-
>  drivers/media/dvb-frontends/af9013_priv.h     |  2 +-
>  drivers/media/dvb-frontends/af9033_priv.h     |  2 +-
>  drivers/media/dvb-frontends/cxd2820r_priv.h   |  2 +-
>  drivers/media/dvb-frontends/cxd2841er.c       |  2 +-
>  .../cxd2880/cxd2880_tnrdmd_dvbt2_mon.c        |  2 +-
>  .../cxd2880/cxd2880_tnrdmd_dvbt_mon.c         |  2 +-
>  .../media/dvb-frontends/cxd2880/cxd2880_top.c |  2 +-
>  drivers/media/dvb-frontends/dib7000p.c        |  2 +-
>  drivers/media/dvb-frontends/dib8000.c         |  2 +-
>  drivers/media/dvb-frontends/dib9000.c         |  2 +-
>  drivers/media/dvb-frontends/drxk_hard.c       |  2 +-
>  drivers/media/dvb-frontends/lgdt3305.c        |  2 +-
>  drivers/media/dvb-frontends/lgdt3306a.c       |  2 +-
>  drivers/media/dvb-frontends/lgdt330x.c        |  2 +-
>  drivers/media/dvb-frontends/m88ds3103_priv.h  |  2 +-
>  drivers/media/dvb-frontends/mn88443x.c        |  2 +-
>  drivers/media/dvb-frontends/mn88472_priv.h    |  2 +-
>  drivers/media/dvb-frontends/mn88473_priv.h    |  2 +-
>  drivers/media/dvb-frontends/or51132.c         |  2 +-
>  drivers/media/dvb-frontends/or51211.c         |  2 +-
>  drivers/media/dvb-frontends/rtl2830_priv.h    |  2 +-
>  drivers/media/dvb-frontends/rtl2832_priv.h    |  2 +-
>  drivers/media/dvb-frontends/si2165.c          |  2 +-
>  drivers/media/dvb-frontends/stv0367.c         |  2 +-
>  drivers/media/dvb-frontends/tc90522.c         |  2 +-
>  drivers/media/dvb-frontends/tda10048.c        |  2 +-
>  include/{media/dvb_math.h => linux/int_log.h} | 18 +---
>  lib/math/Makefile                             |  2 +-
>  .../dvb-core/dvb_math.c => lib/math/int_log.c | 26 ++----
>  sound/soc/codecs/nau8825.c                    | 93 +------------------
>  32 files changed, 45 insertions(+), 150 deletions(-)
>  rename include/{media/dvb_math.h => linux/int_log.h} (63%)
>  rename drivers/media/dvb-core/dvb_math.c => lib/math/int_log.c (84%)
>