Skip to content

Commit ac82f9b

Browse files
committed
Reverse logic for bus peripherals overlapping check.
1 parent 6c4cb8b commit ac82f9b

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/ubus.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,8 @@ bool ubus_register(ceda_ioaddr_t base, uint32_t top, ubus_io_read_t read,
4545
// check if peripherals are overlapping
4646
for (size_t i = 0; i < ubus_used; ++i) {
4747
struct ubus_io_slot *slot = &ubus_slots[i];
48-
if (slot->base >= base && slot->base < top)
49-
return false;
50-
if (slot->top <= top && slot->top > base)
51-
return false;
52-
if (slot->base < base && slot->top > top)
53-
return false;
54-
if (slot->base > base && slot->top < top)
48+
bool ok = (top <= slot->base) || (base >= slot->top);
49+
if (!ok)
5550
return false;
5651
}
5752

0 commit comments

Comments
 (0)