Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lib/math: Move dvb_math.c into lib/math/int_log.c

Some existing and new users may benefit from the intlog2() and
intlog10() APIs, make them wide available.

Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Link: https://lore.kernel.org/r/20230619172019.21457-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20230703135211.87416-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Andy Shevchenko and committed by
Mark Brown
f97fa3dc 3d74f42c

+42 -48
+5 -2
Documentation/core-api/kernel-api.rst
··· 162 162 .. kernel-doc:: include/linux/log2.h 163 163 :internal: 164 164 165 - Integer power Functions 166 - ----------------------- 165 + Integer log and power Functions 166 + ------------------------------- 167 + 168 + .. kernel-doc:: include/linux/int_log.h 169 + :export: 167 170 168 171 .. kernel-doc:: lib/math/int_pow.c 169 172 :export:
-9
Documentation/driver-api/media/dtv-common.rst
··· 3 3 Digital TV Common functions 4 4 --------------------------- 5 5 6 - Math functions 7 - ~~~~~~~~~~~~~~ 8 - 9 - Provide some commonly-used math functions, usually required in order to 10 - estimate signal strength and signal to noise measurements in dB. 11 - 12 - .. kernel-doc:: include/media/dvb_math.h 13 - 14 - 15 6 DVB devices 16 7 ~~~~~~~~~~~ 17 8
+1 -1
drivers/media/dvb-core/Makefile
··· 8 8 9 9 dvb-core-objs := dvbdev.o dmxdev.o dvb_demux.o \ 10 10 dvb_ca_en50221.o dvb_frontend.o \ 11 - $(dvb-net-y) dvb_ringbuffer.o $(dvb-vb2-y) dvb_math.o 11 + $(dvb-net-y) dvb_ringbuffer.o $(dvb-vb2-y) 12 12 13 13 obj-$(CONFIG_DVB_CORE) += dvb-core.o
+6 -5
drivers/media/dvb-core/dvb_math.c lib/math/int_log.c
··· 1 1 /* 2 - * dvb-math provides some complex fixed-point math 3 - * operations shared between the dvb related stuff 2 + * Provides fixed-point logarithm operations. 4 3 * 5 4 * Copyright (C) 2006 Christoph Pfister (christophpfister@gmail.com) 6 5 * ··· 15 16 */ 16 17 17 18 #include <linux/bitops.h> 19 + #include <linux/export.h> 20 + #include <linux/int_log.h> 18 21 #include <linux/kernel.h> 19 - #include <linux/module.h> 22 + #include <linux/types.h> 23 + 20 24 #include <asm/bug.h> 21 - #include <media/dvb_math.h> 22 25 23 26 static const unsigned short logtable[256] = { 24 27 0x0000, 0x0171, 0x02e0, 0x044e, 0x05ba, 0x0725, 0x088e, 0x09f7, ··· 54 53 0xe82a, 0xe8ef, 0xe9b3, 0xea77, 0xeb3b, 0xebfe, 0xecc1, 0xed83, 55 54 0xee45, 0xef06, 0xefc8, 0xf088, 0xf149, 0xf209, 0xf2c8, 0xf387, 56 55 0xf446, 0xf505, 0xf5c3, 0xf680, 0xf73e, 0xf7fb, 0xf8b7, 0xf973, 57 - 0xfa2f, 0xfaea, 0xfba5, 0xfc60, 0xfd1a, 0xfdd4, 0xfe8e, 0xff47 56 + 0xfa2f, 0xfaea, 0xfba5, 0xfc60, 0xfd1a, 0xfdd4, 0xfe8e, 0xff47, 58 57 }; 59 58 60 59 unsigned int intlog2(u32 value)
+1 -1
drivers/media/dvb-frontends/af9013_priv.h
··· 12 12 #define AF9013_PRIV_H 13 13 14 14 #include <media/dvb_frontend.h> 15 - #include <media/dvb_math.h> 15 + #include <linux/int_log.h> 16 16 #include "af9013.h" 17 17 #include <linux/firmware.h> 18 18 #include <linux/i2c-mux.h>
+1 -1
drivers/media/dvb-frontends/af9033_priv.h
··· 14 14 #include <linux/math64.h> 15 15 #include <linux/regmap.h> 16 16 #include <linux/kernel.h> 17 - #include <media/dvb_math.h> 17 + #include <linux/int_log.h> 18 18 19 19 struct reg_val { 20 20 u32 reg;
+1 -1
drivers/media/dvb-frontends/cxd2820r_priv.h
··· 11 11 12 12 #include <linux/dvb/version.h> 13 13 #include <media/dvb_frontend.h> 14 - #include <media/dvb_math.h> 14 + #include <linux/int_log.h> 15 15 #include "cxd2820r.h" 16 16 #include <linux/gpio/driver.h> /* For gpio_chip */ 17 17 #include <linux/math64.h>
+1 -1
drivers/media/dvb-frontends/cxd2841er.c
··· 22 22 #include <linux/dynamic_debug.h> 23 23 #include <linux/kernel.h> 24 24 25 - #include <media/dvb_math.h> 25 + #include <linux/int_log.h> 26 26 #include <media/dvb_frontend.h> 27 27 #include "cxd2841er.h" 28 28 #include "cxd2841er_priv.h"
+1 -1
drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.c
··· 11 11 #include "cxd2880_tnrdmd_dvbt2.h" 12 12 #include "cxd2880_tnrdmd_dvbt2_mon.h" 13 13 14 - #include <media/dvb_math.h> 14 + #include <linux/int_log.h> 15 15 16 16 static const int ref_dbm_1000[4][8] = { 17 17 {-96000, -95000, -94000, -93000, -92000, -92000, -98000, -97000},
+1 -1
drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.c
··· 11 11 #include "cxd2880_tnrdmd_dvbt.h" 12 12 #include "cxd2880_tnrdmd_dvbt_mon.h" 13 13 14 - #include <media/dvb_math.h> 14 + #include <linux/int_log.h> 15 15 16 16 static const int ref_dbm_1000[3][5] = { 17 17 {-93000, -91000, -90000, -89000, -88000},
+1 -1
drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
··· 11 11 #include <linux/spi/spi.h> 12 12 13 13 #include <media/dvb_frontend.h> 14 - #include <media/dvb_math.h> 14 + #include <linux/int_log.h> 15 15 16 16 #include "cxd2880.h" 17 17 #include "cxd2880_tnrdmd_mon.h"
+1 -1
drivers/media/dvb-frontends/dib7000p.c
··· 13 13 #include <linux/mutex.h> 14 14 #include <asm/div64.h> 15 15 16 - #include <media/dvb_math.h> 16 + #include <linux/int_log.h> 17 17 #include <media/dvb_frontend.h> 18 18 19 19 #include "dib7000p.h"
+1 -1
drivers/media/dvb-frontends/dib8000.c
··· 13 13 #include <linux/mutex.h> 14 14 #include <asm/div64.h> 15 15 16 - #include <media/dvb_math.h> 16 + #include <linux/int_log.h> 17 17 18 18 #include <media/dvb_frontend.h> 19 19
+1 -1
drivers/media/dvb-frontends/dib9000.c
··· 11 11 #include <linux/i2c.h> 12 12 #include <linux/mutex.h> 13 13 14 - #include <media/dvb_math.h> 14 + #include <linux/int_log.h> 15 15 #include <media/dvb_frontend.h> 16 16 17 17 #include "dib9000.h"
+1 -1
drivers/media/dvb-frontends/drxk_hard.c
··· 20 20 #include <media/dvb_frontend.h> 21 21 #include "drxk.h" 22 22 #include "drxk_hard.h" 23 - #include <media/dvb_math.h> 23 + #include <linux/int_log.h> 24 24 25 25 static int power_down_dvbt(struct drxk_state *state, bool set_power_mode); 26 26 static int power_down_qam(struct drxk_state *state);
+1 -1
drivers/media/dvb-frontends/lgdt3305.c
··· 10 10 #include <asm/div64.h> 11 11 #include <linux/dvb/frontend.h> 12 12 #include <linux/slab.h> 13 - #include <media/dvb_math.h> 13 + #include <linux/int_log.h> 14 14 #include "lgdt3305.h" 15 15 16 16 static int debug;
+1 -1
drivers/media/dvb-frontends/lgdt3306a.c
··· 12 12 #include <asm/div64.h> 13 13 #include <linux/kernel.h> 14 14 #include <linux/dvb/frontend.h> 15 - #include <media/dvb_math.h> 15 + #include <linux/int_log.h> 16 16 #include "lgdt3306a.h" 17 17 #include <linux/i2c-mux.h> 18 18
+1 -1
drivers/media/dvb-frontends/lgdt330x.c
··· 28 28 #include <asm/byteorder.h> 29 29 30 30 #include <media/dvb_frontend.h> 31 - #include <media/dvb_math.h> 31 + #include <linux/int_log.h> 32 32 #include "lgdt330x_priv.h" 33 33 #include "lgdt330x.h" 34 34
+1 -1
drivers/media/dvb-frontends/m88ds3103_priv.h
··· 10 10 11 11 #include <media/dvb_frontend.h> 12 12 #include "m88ds3103.h" 13 - #include <media/dvb_math.h> 13 + #include <linux/int_log.h> 14 14 #include <linux/firmware.h> 15 15 #include <linux/i2c-mux.h> 16 16 #include <linux/regmap.h>
+1 -1
drivers/media/dvb-frontends/mn88443x.c
··· 10 10 #include <linux/gpio/consumer.h> 11 11 #include <linux/of_device.h> 12 12 #include <linux/regmap.h> 13 - #include <media/dvb_math.h> 13 + #include <linux/int_log.h> 14 14 15 15 #include "mn88443x.h" 16 16
+1 -1
drivers/media/dvb-frontends/mn88472_priv.h
··· 9 9 #define MN88472_PRIV_H 10 10 11 11 #include <media/dvb_frontend.h> 12 - #include <media/dvb_math.h> 12 + #include <linux/int_log.h> 13 13 #include "mn88472.h" 14 14 #include <linux/firmware.h> 15 15 #include <linux/regmap.h>
+1 -1
drivers/media/dvb-frontends/mn88473_priv.h
··· 9 9 #define MN88473_PRIV_H 10 10 11 11 #include <media/dvb_frontend.h> 12 - #include <media/dvb_math.h> 12 + #include <linux/int_log.h> 13 13 #include "mn88473.h" 14 14 #include <linux/math64.h> 15 15 #include <linux/firmware.h>
+1 -1
drivers/media/dvb-frontends/or51132.c
··· 27 27 #include <linux/slab.h> 28 28 #include <asm/byteorder.h> 29 29 30 - #include <media/dvb_math.h> 30 + #include <linux/int_log.h> 31 31 #include <media/dvb_frontend.h> 32 32 #include "or51132.h" 33 33
+1 -1
drivers/media/dvb-frontends/or51211.c
··· 26 26 #include <linux/slab.h> 27 27 #include <asm/byteorder.h> 28 28 29 - #include <media/dvb_math.h> 29 + #include <linux/int_log.h> 30 30 #include <media/dvb_frontend.h> 31 31 #include "or51211.h" 32 32
+1 -1
drivers/media/dvb-frontends/rtl2830_priv.h
··· 9 9 #define RTL2830_PRIV_H 10 10 11 11 #include <media/dvb_frontend.h> 12 - #include <media/dvb_math.h> 12 + #include <linux/int_log.h> 13 13 #include "rtl2830.h" 14 14 #include <linux/i2c-mux.h> 15 15 #include <linux/math64.h>
+1 -1
drivers/media/dvb-frontends/rtl2832_priv.h
··· 14 14 #include <linux/bitops.h> 15 15 16 16 #include <media/dvb_frontend.h> 17 - #include <media/dvb_math.h> 17 + #include <linux/int_log.h> 18 18 #include "rtl2832.h" 19 19 20 20 struct rtl2832_dev {
+1 -1
drivers/media/dvb-frontends/si2165.c
··· 19 19 #include <linux/regmap.h> 20 20 21 21 #include <media/dvb_frontend.h> 22 - #include <media/dvb_math.h> 22 + #include <linux/int_log.h> 23 23 #include "si2165_priv.h" 24 24 #include "si2165.h" 25 25
+1 -1
drivers/media/dvb-frontends/stv0367.c
··· 15 15 #include <linux/slab.h> 16 16 #include <linux/i2c.h> 17 17 18 - #include <media/dvb_math.h> 18 + #include <linux/int_log.h> 19 19 20 20 #include "stv0367.h" 21 21 #include "stv0367_defs.h"
+1 -1
drivers/media/dvb-frontends/tc90522.c
··· 21 21 #include <linux/kernel.h> 22 22 #include <linux/math64.h> 23 23 #include <linux/dvb/frontend.h> 24 - #include <media/dvb_math.h> 24 + #include <linux/int_log.h> 25 25 #include "tc90522.h" 26 26 27 27 #define TC90522_I2C_THRU_REG 0xfe
+1 -1
drivers/media/dvb-frontends/tda10048.c
··· 16 16 #include <linux/math64.h> 17 17 #include <asm/div64.h> 18 18 #include <media/dvb_frontend.h> 19 - #include <media/dvb_math.h> 19 + #include <linux/int_log.h> 20 20 #include "tda10048.h" 21 21 22 22 #define TDA10048_DEFAULT_FIRMWARE "dvb-fe-tda10048-1.0.fw"
+3 -4
include/media/dvb_math.h include/linux/int_log.h
··· 1 1 /* 2 - * dvb-math provides some complex fixed-point math 3 - * operations shared between the dvb related stuff 2 + * Provides fixed-point logarithm operations. 4 3 * 5 4 * Copyright (C) 2006 Christoph Pfister (christophpfister@gmail.com) 6 5 * ··· 14 15 * GNU Lesser General Public License for more details. 15 16 */ 16 17 17 - #ifndef __DVB_MATH_H 18 - #define __DVB_MATH_H 18 + #ifndef __LINUX_INT_LOG_H 19 + #define __LINUX_INT_LOG_H 19 20 20 21 #include <linux/types.h> 21 22
+1 -1
lib/math/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 - obj-y += div64.o gcd.o lcm.o int_pow.o int_sqrt.o reciprocal_div.o 2 + obj-y += div64.o gcd.o lcm.o int_log.o int_pow.o int_sqrt.o reciprocal_div.o 3 3 4 4 obj-$(CONFIG_CORDIC) += cordic.o 5 5 obj-$(CONFIG_PRIME_NUMBERS) += prime_numbers.o