[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <59e3532f43294252ff34468bbbf0444c589f0956.1280263065.git.jbaron@redhat.com>
Date: Tue, 27 Jul 2010 16:54:36 -0400
From: Jason Baron <jbaron@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: mingo@...e.hu, mathieu.desnoyers@...ymtl.ca, hpa@...or.com,
tglx@...utronix.de, rostedt@...dmis.org, andi@...stfloor.org,
roland@...hat.com, rth@...hat.com, mhiramat@...hat.com,
fweisbec@...il.com, avi@...hat.com, davem@...emloft.net,
vgoyal@...hat.com, sam@...nborg.org, tony@...eyournoodle.com
Subject: [PATCH 07/12] jump label v10: use lib/sort.c
Make use of the the kernel's generic sort routines.
Signed-off-by: Jason Baron <jbaron@...hat.com>
---
kernel/jump_label.c | 37 ++++++++++++++++---------------------
1 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 10fb17f..faef97e 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -12,6 +12,7 @@
#include <linux/jhash.h>
#include <linux/slab.h>
#include <linux/err.h>
+#include <linux/sort.h>
#ifdef HAVE_JUMP_LABEL
@@ -38,33 +39,27 @@ struct jump_label_module_entry {
struct module *mod;
};
-static void swap_jump_label_entries(struct jump_entry *previous, struct jump_entry *next)
+static int jump_label_cmp(const void *a, const void *b)
{
- struct jump_entry tmp;
+ const struct jump_entry *jea = a;
+ const struct jump_entry *jeb = b;
- tmp = *next;
- *next = *previous;
- *previous = tmp;
+ if (jea->key < jeb->key)
+ return -1;
+
+ if (jea->key > jeb->key)
+ return 1;
+
+ return 0;
}
static void sort_jump_label_entries(struct jump_entry *start, struct jump_entry *stop)
{
- int swapped = 0;
- struct jump_entry *iter;
- struct jump_entry *iter_next;
-
- do {
- swapped = 0;
- iter = start;
- iter_next = start;
- iter_next++;
- for (; iter_next < stop; iter++, iter_next++) {
- if (iter->key > iter_next->key) {
- swap_jump_label_entries(iter, iter_next);
- swapped = 1;
- }
- }
- } while (swapped == 1);
+ unsigned long size;
+
+ size = (((unsigned long)stop - (unsigned long)start)
+ / sizeof(struct jump_entry));
+ sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
}
static struct jump_label_entry *get_jump_label_entry(jump_label_t key)
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists