Skip to content

Commit 0341b76

Browse files
committed
Reverse logic for bus peripherals overlapping check.
1 parent 5acad2c commit 0341b76

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/ubus.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,9 @@ 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 = (base < slot->base && top <= slot->base) ||
49+
(base > slot->base && slot->top <= base);
50+
if (!ok)
5551
return false;
5652
}
5753

0 commit comments

Comments
 (0)