Skip to contentSkip to conversation

math: RATIONAL and RATIONAL_KUNIT_TEST improvements

PATCH Applied Geert Uytterhoeven 2 participants 4 messages Jul 6, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover math: RATIONAL and RATIONAL_KUNIT_TEST improvements

Hi all,

This patch series makes the RATIONAL symbol tristate, so it is not forced builtin if all users are modular, and makes the RATIONAL_KUNIT_TEST depend on RATIONAL, to avoid enabling RATIONAL if there are no real users.

Changes compared to v1:
- Drop compile-testing and help text for RATIONAL.
- Make RATIONAL_KUNIT_TEST depend on RATIONAL.

Thanks for your comments!

[1] https://lore.kernel.org/r/[email protected]/

Geert Uytterhoeven (2):
math: Make RATIONAL tristate
math: RATIONAL_KUNIT_TEST should depend on RATIONAL instead of
selecting it

 lib/Kconfig.debug   | 3 +--
 lib/math/Kconfig    | 2 +-
 lib/math/rational.c | 3 +++
 3 files changed, 5 insertions(+), 3 deletions(-)
Signature · 12 lines
2.25.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
#1 lore raw

PATCH 1/2 math: Make RATIONAL tristate

All but one symbols that select RATIONAL are tristate, but RATIONAL itself is bool. Change it to tristate, so the rational fractions support code can be modular if no builtin code relies on it.

---
Exposed by commit b6c75c4afceb8bc0 ("lib/math/rational: add Kunit test cases") and CONFIG_KUNIT_ALL_TESTS=m.

v2:
- Drop compile-testing and help text.

---
 lib/math/Kconfig    | 2 +-
 lib/math/rational.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
lib/math/Kconfig +1 -1
index f19bc9734fa7cc4b..0634b428d0cb7f86 100644
@@ -14,4 +14,4 @@ config PRIME_NUMBERS
 	  If unsure, say N.
 
 config RATIONAL
-	bool
+	tristate
lib/math/rational.c +3 -0
index c0ab51d8fbb98d17..ec59d426ea638b0f 100644
@@ -13,6 +13,7 @@
 #include <linux/export.h>
 #include <linux/minmax.h>
 #include <linux/limits.h>
+#include <linux/module.h>
 
 /*
  * calculate best rational approximation for a given fraction
@@ -106,3 +107,5 @@ void rational_best_approximation(
 }
 
 EXPORT_SYMBOL(rational_best_approximation);
+
+MODULE_LICENSE("GPL v2");
Signature · 1 line
2.25.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] math: Make RATIONAL tristate

Quoted 3 lines · Geert Uytterhoeven

All but one symbols that select RATIONAL are tristate, but RATIONAL itself is bool. Change it to tristate, so the rational fractions support code can be modular if no builtin code relies on it.

Works for me,

Quoted 43 lines

---
Exposed by commit b6c75c4afceb8bc0 ("lib/math/rational: add Kunit test cases") and CONFIG_KUNIT_ALL_TESTS=m.

v2:
- Drop compile-testing and help text.

---
 lib/math/Kconfig    | 2 +-
 lib/math/rational.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
lib/math/Kconfig +1 -1
index f19bc9734fa7cc4b..0634b428d0cb7f86 100644
@@ -14,4 +14,4 @@ config PRIME_NUMBERS
 	  If unsure, say N.
 
 config RATIONAL
-	bool
+	tristate
lib/math/rational.c +3 -0
index c0ab51d8fbb98d17..ec59d426ea638b0f 100644
@@ -13,6 +13,7 @@
 #include <linux/export.h>
 #include <linux/minmax.h>
 #include <linux/limits.h>
+#include <linux/module.h>
 
 /*
  * calculate best rational approximation for a given fraction
@@ -106,3 +107,5 @@ void rational_best_approximation(
 }
 
 EXPORT_SYMBOL(rational_best_approximation);
+
+MODULE_LICENSE("GPL v2");
Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

PATCH 2/2 math: RATIONAL_KUNIT_TEST should depend on RATIONAL instead of selecting it

In reply to Geert Uytterhoeven

RATIONAL_KUNIT_TEST selects RATIONAL, thus enabling an optional feature the user may not want to have enabled. Fix this by making the test depend on RATIONAL instead.

Fixes b6c75c4afceb8bc0 ("lib/math/rational: add Kunit test cases")

---
The RATIONAL config symbol is not visible, which means that this test can only be enabled when there is a user of RATIONAL.

v2:
- New.

---
 lib/Kconfig.debug | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
lib/Kconfig.debug +1 -2
index 8acc01d7d816518c..f368764ff4a91f4a 100644
@@ -2449,8 +2449,7 @@ config SLUB_KUNIT_TEST
 
 config RATIONAL_KUNIT_TEST
 	tristate "KUnit test for rational.c" if !KUNIT_ALL_TESTS
-	depends on KUNIT
-	select RATIONAL
+	depends on KUNIT && RATIONAL
 	default KUNIT_ALL_TESTS
 	help
 	  This builds the rational math unit test.
Signature · 1 line
2.25.1