Skip to content

Commit 662a8de

Browse files
committed
hostmot2 bspi: sanity-check that channel echo enable matches receive buffer present
1 parent 44c1277 commit 662a8de

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

  • src/hal/drivers/mesa-hostmot2

src/hal/drivers/mesa-hostmot2/bspi.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,18 @@ int hm2_tram_add_bspi_frame(char *name, int chan, rtapi_u32 **wbuff, rtapi_u32 *
140140
} else {
141141
HM2_ERR("SPI frame must have a write entry for channel (%i) on %s.\n", chan, name);
142142
return -1;
143-
}
143+
}
144+
bool will_echo = !(hm2->bspi.instance[i].cd[chan] & 0x80000000);
145+
bool has_rbuff = rbuff != NULL;
146+
if (will_echo != has_rbuff) {
147+
HM2_ERR("SPI frame must have a read entry for channel (%i) on %s.\n", chan, name);
148+
return -1;
149+
}
144150
if (rbuff != NULL){
145-
// Don't add a read entry for a no-echo channel
146-
if(!(hm2->bspi.instance[i].cd[chan] & 0x80000000)) {
147-
r = hm2_register_tram_read_region(hm2,hm2->bspi.instance[i].addr[0], sizeof(rtapi_u32),rbuff);
148-
if (r < 0) {
149-
HM2_ERR( "Failed to add TRAM read entry for %s\n", name);
150-
return -1;
151-
}
151+
r = hm2_register_tram_read_region(hm2,hm2->bspi.instance[i].addr[0], sizeof(rtapi_u32),rbuff);
152+
if (r < 0) {
153+
HM2_ERR( "Failed to add TRAM read entry for %s\n", name);
154+
return -1;
152155
}
153156
}
154157

0 commit comments

Comments
 (0)