summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2010-04-02 10:43:33 +0400
committerJens Axboe <jens.axboe@oracle.com>2010-04-02 10:43:33 +0400
commited6b6dc7c142bfb5840d201a9b4a465c9e56ce33 (patch)
tree538a3ec7ba62f5e668be7f0bd681857c1bd73da2 /lib
parent2eaa9cfdf33b8d7fb7aff27792192e0019ae8fc6 (diff)
parenta506aedc51093544ff0f9610af6066d18cb6abbe (diff)
downloadlinux-ed6b6dc7c142bfb5840d201a9b4a465c9e56ce33.tar.xz
Merge branch 'for-linus' into for-2.6.35
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile2
-rw-r--r--lib/lcm.c15
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 2e152aed7198..0d4015205c64 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -21,7 +21,7 @@ lib-y += kobject.o kref.o klist.o
obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
- string_helpers.o gcd.o list_sort.o
+ string_helpers.o gcd.o lcm.o list_sort.o
ifeq ($(CONFIG_DEBUG_KOBJECT),y)
CFLAGS_kobject.o += -DDEBUG
diff --git a/lib/lcm.c b/lib/lcm.c
new file mode 100644
index 000000000000..157cd88a6ffc
--- /dev/null
+++ b/lib/lcm.c
@@ -0,0 +1,15 @@
+#include <linux/kernel.h>
+#include <linux/gcd.h>
+#include <linux/module.h>
+
+/* Lowest common multiple */
+unsigned long lcm(unsigned long a, unsigned long b)
+{
+ if (a && b)
+ return (a * b) / gcd(a, b);
+ else if (b)
+ return b;
+
+ return a;
+}
+EXPORT_SYMBOL_GPL(lcm);