math: Make RATIONAL tristate
PATCH 1/1 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.
While at it, add support for compile-testing and provide a help text.
---
Exposed by commit b6c75c4afceb8bc0 ("lib/math/rational: add Kunit test cases") and CONFIG_KUNIT_ALL_TESTS=m.
I'm not so happy RATIONAL_KUNIT_TEST selects RATIONAL, as test code should depend on the presence of the feature to test. Else enabling a test may add unneeded code to a production kernel. Perhaps the "if COMPILE_TEST" should be dropped, making RATIONAL visible, so RATIONAL_KUNIT_TEST can depend on RATIONAL instead?
--- lib/math/Kconfig | 5 ++++- lib/math/rational.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-)
lib/math/Kconfig +4 -1
@@ -14,4 +14,7 @@ config PRIME_NUMBERS If unsure, say N. config RATIONAL - bool + tristate "Rational fractions support" if COMPILE_TEST + help + This option provides support for rational fractions. + This symbol should be selected automatically by drivers that need it.
lib/math/rational.c +3 -0
@@ -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
Quoted 5 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.
While at it, add support for compile-testing and provide a help text.
...
Quoted 8 lines
Exposed by commit
b6c75c4afceb8bc0("lib/math/rational: add Kunit test cases") andCONFIG_KUNIT_ALL_TESTS=m.I'm not so happy
RATIONAL_KUNIT_TESTselects RATIONAL, as test code should depend on the presence of the feature to test. Else enabling a test may add unneeded code to a production kernel. Perhaps the "ifCOMPILE_TEST" should be dropped, making RATIONAL visible, soRATIONAL_KUNIT_TESTcan depend on RATIONAL instead?
...
lib/math/Kconfig config PRIME_NUMBERS · line 17
Quoted 1 line
lib/math/Kconfig +1
-0+ tristate "Rational fractions support" if COMPILE_TEST
Making it tristate is okay, but visible (even for COMPILE_TEST)... why? Just on purpose to be dependent on for test case? I understand your justification above, but it will bring all hidden symbols to be unhidden (due to test cases) and this is not the right thing to do in my opinion.
Why not to complain to KUnit people to fix their infra to avoid tests that tries non-selected feature(s)?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi Andy,
Quoted 18 lines · Andy Shevchenko
Quoted 5 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.
While at it, add support for compile-testing and provide a help text.
...
Quoted 8 lines
Exposed by commit
b6c75c4afceb8bc0("lib/math/rational: add Kunit test cases") andCONFIG_KUNIT_ALL_TESTS=m.I'm not so happy
RATIONAL_KUNIT_TESTselects RATIONAL, as test code should depend on the presence of the feature to test. Else enabling a test may add unneeded code to a production kernel. Perhaps the "ifCOMPILE_TEST" should be dropped, making RATIONAL visible, soRATIONAL_KUNIT_TESTcan depend on RATIONAL instead?
Quoted 8 lines
...
Quoted 1 line
+ tristate "Rational fractions support" if
COMPILE_TESTMaking it tristate is okay, but visible (even for
COMPILE_TEST)... why? Just on purpose to be dependent on for test case? I understand your justification above, but it will bring all hidden symbols to be unhidden (due to test cases) and this is not the right thing to do in my opinion.
OK. Will drop in v2.
Quoted 2 lines
Why not to complain to KUnit people to fix their infra to avoid tests that tries non-selected feature(s)?
I guess the audience is listening...
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
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