sparc: remove several unnecessary module.h include instances
[linux-2.6/libata-dev.git] / arch / sparc / mm / extable.c
blob7131eacc120f7d56bb1d30a0684db5c07e860b4a
1 /*
2 * linux/arch/sparc/mm/extable.c
3 */
5 #include <asm/uaccess.h>
7 void sort_extable(struct exception_table_entry *start,
8 struct exception_table_entry *finish)
12 /* Caller knows they are in a range if ret->fixup == 0 */
13 const struct exception_table_entry *
14 search_extable(const struct exception_table_entry *start,
15 const struct exception_table_entry *last,
16 unsigned long value)
18 const struct exception_table_entry *walk;
20 /* Single insn entries are encoded as:
21 * word 1: insn address
22 * word 2: fixup code address
24 * Range entries are encoded as:
25 * word 1: first insn address
26 * word 2: 0
27 * word 3: last insn address + 4 bytes
28 * word 4: fixup code address
30 * Deleted entries are encoded as:
31 * word 1: unused
32 * word 2: -1
34 * See asm/uaccess.h for more details.
37 /* 1. Try to find an exact match. */
38 for (walk = start; walk <= last; walk++) {
39 if (walk->fixup == 0) {
40 /* A range entry, skip both parts. */
41 walk++;
42 continue;
45 /* A deleted entry; see trim_init_extable */
46 if (walk->fixup == -1)
47 continue;
49 if (walk->insn == value)
50 return walk;
53 /* 2. Try to find a range match. */
54 for (walk = start; walk <= (last - 1); walk++) {
55 if (walk->fixup)
56 continue;
58 if (walk[0].insn <= value && walk[1].insn > value)
59 return walk;
61 walk++;
64 return NULL;
67 #ifdef CONFIG_MODULES
68 /* We could memmove them around; easier to mark the trimmed ones. */
69 void trim_init_extable(struct module *m)
71 unsigned int i;
72 bool range;
74 for (i = 0; i < m->num_exentries; i += range ? 2 : 1) {
75 range = m->extable[i].fixup == 0;
77 if (within_module_init(m->extable[i].insn, m)) {
78 m->extable[i].fixup = -1;
79 if (range)
80 m->extable[i+1].fixup = -1;
82 if (range)
83 i++;
86 #endif /* CONFIG_MODULES */
88 /* Special extable search, which handles ranges. Returns fixup */
89 unsigned long search_extables_range(unsigned long addr, unsigned long *g2)
91 const struct exception_table_entry *entry;
93 entry = search_exception_tables(addr);
94 if (!entry)
95 return 0;
97 /* Inside range? Fix g2 and return correct fixup */
98 if (!entry->fixup) {
99 *g2 = (addr - entry->insn) / 4;
100 return (entry + 1)->fixup;
103 return entry->fixup;