Skip to content

Commit

Permalink
Return an error for non-existent ports to probe and empty spi_probe.
Browse files Browse the repository at this point in the history
  • Loading branch information
BsAtHome committed Dec 4, 2024
1 parent aaa4041 commit 85c7a2c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/hal/drivers/mesa-hostmot2/hm2_spix.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,16 @@ static int spix_setup(void)
LL_WARN("Setting spi_pull_{miso,mosi,sclk} has no effect in the hm2_spix driver.\n");
}

if(spi_probe > (1 << SPIX_MAX_BOARDS) - 1) {
LL_WARN("Probing with spi_probe must not have flags larger than %d included; truncating.\n", 1 << (SPIX_MAX_BOARDS - 1));
spi_probe &= (1 << SPIX_MAX_BOARDS) - 1;
}

if(!spi_probe) {
LL_ERR("No SPI ports to probe (spi_probe is zero).\n");
return -EINVAL;
}

// Set process-level message level if requested
if(spi_debug >= RTAPI_MSG_NONE && spi_debug <= RTAPI_MSG_ALL)
rtapi_set_msg_level(spi_debug);
Expand Down

0 comments on commit 85c7a2c

Please sign in to comment.