ppc4xx: Fix bug with default GPIO output value
[oweals/u-boot.git] / lib_ppc / extable.c
index fe856ffbb527a4e5dd62d1925d39f0fe14fc8ada..8354411f01fd51cfd58ecf10585e1906368c3746 100644 (file)
@@ -52,30 +52,27 @@ search_one_table(const struct exception_table_entry *first,
                 const struct exception_table_entry *last,
                 unsigned long value)
 {
-       while (first <= last) {
-               const struct exception_table_entry *mid;
-               long diff;
-
-               mid = (last - first) / 2 + first;
-               if (mid > CFG_MONITOR_BASE) {
+       long diff;
+       if ((ulong) first > CFG_MONITOR_BASE) {
                /* exception occurs in FLASH, before u-boot relocation.
                 * No relocation offset is needed.
                 */
-                       diff = mid->insn - value;
+               while (first <= last) {
+                       diff = first->insn - value;
                        if (diff == 0)
-                               return mid->fixup;
-               } else {
+                               return first->fixup;
+                       first++;
+               }
+       } else {
                /* exception occurs in RAM, after u-boot relocation.
                 * A relocation offset should be added.
                 */
-                       diff = (mid->insn + gd->reloc_off) - value;
+               while (first <= last) {
+                       diff = (first->insn + gd->reloc_off) - value;
                        if (diff == 0)
-                               return (mid->fixup + gd->reloc_off);
+                               return (first->fixup + gd->reloc_off);
+                       first++;
                }
-               if (diff < 0)
-                       first = mid+1;
-               else
-                       last = mid-1;
        }
        return 0;
 }