All of
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <>
To: Trent Piepho <>,
	Colin Ian King <>,
	Andy Shevchenko <>,
	Andrew Morton <>,
	Brendan Higgins <>
	Geert Uytterhoeven <>
Subject: [PATCH] math: Make RATIONAL tristate
Date: Mon,  5 Jul 2021 13:46:33 +0200	[thread overview]
Message-ID: <> (raw)

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.

Signed-off-by: Geert Uytterhoeven <>
Exposed by commit b6c75c4afceb8bc0 ("lib/math/rational: add Kunit test

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(-)

diff --git a/lib/math/Kconfig b/lib/math/Kconfig
index f19bc9734fa7cc4b..14def252ea7db6e0 100644
--- a/lib/math/Kconfig
+++ b/lib/math/Kconfig
@@ -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.
diff --git a/lib/math/rational.c b/lib/math/rational.c
index c0ab51d8fbb98d17..ec59d426ea638b0f 100644
--- a/lib/math/rational.c
+++ b/lib/math/rational.c
@@ -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(

             reply	other threads:[~2021-07-05 11:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05 11:46 Geert Uytterhoeven [this message]
2021-07-05 14:53 ` [PATCH] math: Make RATIONAL tristate Andy Shevchenko
2021-07-06  7:14   ` Geert Uytterhoeven

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \

* 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.