Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/drivers/spi/spi_error_cases/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,31 @@ ZTEST(spi_error_cases, test_spis_tx_buf_not_in_ram)
zassert_equal(slave_rv, -ENOTSUP, "Got %d instead", slave_rv);
}

ZTEST(spi_error_cases, test_no_configure_in_each_transceive)
{
int rv;
struct spi_dt_spec spim_valid = spim;
struct spi_dt_spec spim_invalid = spim;

/* configure device during first transceive with valid config */
rv = spi_transceive_dt(&spim_valid, tdata.stx_set, tdata.srx_set);
zassert_equal(rv, 0, "Got %d instead", rv);

/* change valid config frequency to invalid value */
spim_valid.config.frequency = 124999;

/* make sure device is not reconfigured because conf structure pointer is the same
Copy link
Contributor

@teburd teburd Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't quite look right to me, why would it not be reconfigured here? Each transceive should be viewed as unique, if you go changing the spi bus frequency between transceives this should be valid, not sure why this wouldn't change the frequency. That's highly confusing behavior.

* thus do not report error because of invalid frequency setting
*/
rv = spi_transceive_dt(&spim_valid, tdata.stx_set, tdata.srx_set);
zassert_equal(rv, 0, "Got %d instead", rv);

/* use different config structure - force reconfiguration and thus report error */
spim_invalid.config.frequency = 124999;
rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set);
zassert_equal(rv, -EINVAL, "Got %d instead", rv);
}

static void before(void *not_used)
{
ARG_UNUSED(not_used);
Expand Down