mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/2] lib: drop separate int_sqrt.h header
Date: Tue, 10 Sep 2024 10:52:52 +0200	[thread overview]
Message-ID: <20240910085253.46286-1-a.fatoum@pengutronix.de> (raw)

Linux defines int_sqrt in linux/math.h and has the implementations in
lib/math. We have both these locations, so move the existing code over
to simplify future sync of math functions.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 commands/fbtest.c         | 2 +-
 include/int_sqrt.h        | 8 --------
 include/linux/math.h      | 2 ++
 lib/Makefile              | 1 -
 lib/math/Makefile         | 1 +
 lib/{ => math}/int_sqrt.c | 4 ++--
 6 files changed, 6 insertions(+), 12 deletions(-)
 delete mode 100644 include/int_sqrt.h
 rename lib/{ => math}/int_sqrt.c (94%)

diff --git a/commands/fbtest.c b/commands/fbtest.c
index be1540d3d170..cee72b039371 100644
--- a/commands/fbtest.c
+++ b/commands/fbtest.c
@@ -9,7 +9,7 @@
 #include <gui/graphic_utils.h>
 #include <gui/2d-primitives.h>
 #include <linux/gcd.h>
-#include <int_sqrt.h>
+#include <linux/math.h>
 
 static void fbtest_pattern_solid(struct screen *sc, u32 color)
 {
diff --git a/include/int_sqrt.h b/include/int_sqrt.h
deleted file mode 100644
index d5dfd29ca088..000000000000
--- a/include/int_sqrt.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-#ifndef __INT_SQRT__
-#define __INT_SQRT__
-
-unsigned long int_sqrt(unsigned long x);
-
-#endif
diff --git a/include/linux/math.h b/include/linux/math.h
index f5d5cc714c4e..48417aca7635 100644
--- a/include/linux/math.h
+++ b/include/linux/math.h
@@ -81,4 +81,6 @@
 		(__x < 0) ? -__x : __x;         \
 	})
 
+unsigned long int_sqrt(unsigned long);
+
 #endif
diff --git a/lib/Makefile b/lib/Makefile
index 19d3a235dda5..41aed121267c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -76,7 +76,6 @@ obj-$(CONFIG_RATP)	+= ratp.o
 obj-$(CONFIG_DEBUG_LIST) += list_debug.o
 obj-y			+= list_sort.o
 obj-y			+= refcount.o
-obj-y			+= int_sqrt.o
 obj-y			+= parseopt.o
 obj-y			+= clz_ctz.o
 obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o
diff --git a/lib/math/Makefile b/lib/math/Makefile
index 2830dedb2ff9..71ab2b108689 100644
--- a/lib/math/Makefile
+++ b/lib/math/Makefile
@@ -3,3 +3,4 @@
 obj-y += div64.o
 pbl-y += div64.o
 obj-y += rational.o
+obj-y += int_sqrt.o
diff --git a/lib/int_sqrt.c b/lib/math/int_sqrt.c
similarity index 94%
rename from lib/int_sqrt.c
rename to lib/math/int_sqrt.c
index 24b3d5078299..105656d04661 100644
--- a/lib/int_sqrt.c
+++ b/lib/math/int_sqrt.c
@@ -11,8 +11,8 @@
  *
  */
 
-#include <common.h>
-#include <int_sqrt.h>
+#include <linux/math.h>
+#include <linux/export.h>
 
 /**
  * int_sqrt - rough approximation to sqrt
-- 
2.39.2




             reply	other threads:[~2024-09-10  8:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-10  8:52 Ahmad Fatoum [this message]
2024-09-10  8:52 ` [PATCH 2/2] include: linux/math.h: sync with linux Ahmad Fatoum
2024-09-11  8:40 ` [PATCH 1/2] lib: drop separate int_sqrt.h header Sascha Hauer

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=20240910085253.46286-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox