spi-topcliff-pch: Fix issue for transmitting over 4KByte
[zen-stable.git] / arch / sparc / mm / extable.c
bloba61c349448e1e12b28621b3590553593f2d3b799
1 /*
2 * linux/arch/sparc/mm/extable.c
3 */
5 #include <linux/module.h>
6 #include <asm/uaccess.h>
8 void sort_extable(struct exception_table_entry *start,
9 struct exception_table_entry *finish)
13 /* Caller knows they are in a range if ret->fixup == 0 */
14 const struct exception_table_entry *
15 search_extable(const struct exception_table_entry *start,
16 const struct exception_table_entry *last,
17 unsigned long value)
19 const struct exception_table_entry *walk;
21 /* Single insn entries are encoded as:
22 * word 1: insn address
23 * word 2: fixup code address
25 * Range entries are encoded as:
26 * word 1: first insn address
27 * word 2: 0
28 * word 3: last insn address + 4 bytes
29 * word 4: fixup code address
31 * Deleted entries are encoded as:
32 * word 1: unused
33 * word 2: -1
35 * See asm/uaccess.h for more details.
38 /* 1. Try to find an exact match. */
39 for (walk = start; walk <= last; walk++) {
40 if (walk->fixup == 0) {
41 /* A range entry, skip both parts. */
42 walk++;
43 continue;
46 /* A deleted entry; see trim_init_extable */
47 if (walk->fixup == -1)
48 continue;
50 if (walk->insn == value)
51 return walk;
54 /* 2. Try to find a range match. */
55 for (walk = start; walk <= (last - 1); walk++) {
56 if (walk->fixup)
57 continue;
59 if (walk[0].insn <= value && walk[1].insn > value)
60 return walk;
62 walk++;
65 return NULL;
68 #ifdef CONFIG_MODULES
69 /* We could memmove them around; easier to mark the trimmed ones. */
70 void trim_init_extable(struct module *m)
72 unsigned int i;
73 bool range;
75 for (i = 0; i < m->num_exentries; i += range ? 2 : 1) {
76 range = m->extable[i].fixup == 0;
78 if (within_module_init(m->extable[i].insn, m)) {
79 m->extable[i].fixup = -1;
80 if (range)
81 m->extable[i+1].fixup = -1;
83 if (range)
84 i++;
87 #endif /* CONFIG_MODULES */
89 /* Special extable search, which handles ranges. Returns fixup */
90 unsigned long search_extables_range(unsigned long addr, unsigned long *g2)
92 const struct exception_table_entry *entry;
94 entry = search_exception_tables(addr);
95 if (!entry)
96 return 0;
98 /* Inside range? Fix g2 and return correct fixup */
99 if (!entry->fixup) {
100 *g2 = (addr - entry->insn) / 4;
101 return (entry + 1)->fixup;
104 return entry->fixup;