From 9e5f7b67975d1352ed9fcaf401f41a44c4e1f946 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 1 Feb 2021 11:12:56 +0100 Subject: [PATCH] drivers/periph_spi: make spi_acquire() return void There is no way to properly handle incorrect SPI parameters at run time, so just having an assertion blow up is the better choice here. As most instances of `spi_acquire()` don't check the return value anyway, this will improve debugging experience quite a bit. Some implementation of spi_acquire() don't even check parameters anyway. --- drivers/include/periph/spi.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/include/periph/spi.h b/drivers/include/periph/spi.h index 18f0d8e1ff..37ee32bd7e 100644 --- a/drivers/include/periph/spi.h +++ b/drivers/include/periph/spi.h @@ -340,22 +340,16 @@ int spi_init_with_gpio_mode(spi_t bus, spi_gpio_mode_t mode); * is active when this function is called, this function will block until the * other transaction is complete (spi_relase was called). * - * @note This function expects the @p bus and the @p cs parameters to be - * valid (they are checked in spi_init and spi_init_cs before) - * * @param[in] bus SPI device to access * @param[in] cs chip select pin/line to use, set to SPI_CS_UNDEF if chip * select should not be handled by the SPI driver * @param[in] mode mode to use for the new transaction * @param[in] clk bus clock speed to use for the transaction * - * @retval 0 success - * @retval -EINVAL Invalid mode in @p mode - * @retval -EINVAL Invalid clock in @p clock - * @retval -ENOTSUP Unsupported but valid mode in @p mode - * @retval -ENOTSUP Unsupported but valid clock in @p clock + * @pre All parameters are valid and supported, otherwise an assertion blows + * up (if assertions are enabled). */ -int spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk); +void spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk); /** * @brief Finish an ongoing SPI transaction by releasing the given SPI bus