[v3,3/9] test: spi: add sandbox_spi_get_wordlen interface

Message ID 20260225161851.2475274-4-dario.binacchi@amarulasolutions.com
State New
Headers show
Series
  • video: support Rocktech RK050HR345-CT106A panel
Related show

Commit Message

Dario Binacchi Feb. 25, 2026, 4:16 p.m. UTC
Add the sandbox_spi_get_wordlen() public interface to retrieve the
internal word length state of the sandbox SPI device.

This is intended for use in sandbox SPI test cases to verify that
the word length is correctly propagated from the SPI uclass to
the driver.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Reviewed-by: Simon Glass <simon.glass@canonical.com>

---

Changes in v3:
- Add Reviewed-by tag of Simon Glass
- Get from struct spi_slave data.

 arch/sandbox/include/asm/test.h | 8 ++++++++
 drivers/spi/sandbox_spi.c       | 7 +++++++
 2 files changed, 15 insertions(+)

Patch

diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index 0e8d19ce2325..0438790028b9 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -243,6 +243,14 @@  uint sandbox_spi_get_speed(struct udevice *dev);
  */
 uint sandbox_spi_get_mode(struct udevice *dev);
 
+/**
+ * sandbox_spi_get_wordlen() - Get current wordlen setting of a sandbox spi slave
+ *
+ * @dev: Device to check
+ * Return: current wordlen
+ */
+uint sandbox_spi_get_wordlen(struct udevice *dev);
+
 /**
  * sandbox_get_pch_spi_protect() - Get the PCI SPI protection status
  *
diff --git a/drivers/spi/sandbox_spi.c b/drivers/spi/sandbox_spi.c
index 7c237ac8d371..3ee97d67f4a0 100644
--- a/drivers/spi/sandbox_spi.c
+++ b/drivers/spi/sandbox_spi.c
@@ -61,6 +61,13 @@  uint sandbox_spi_get_mode(struct udevice *dev)
 	return priv->mode;
 }
 
+uint sandbox_spi_get_wordlen(struct udevice *dev)
+{
+	struct spi_slave *slave = dev_get_parent_priv(dev);
+
+	return slave->wordlen;
+}
+
 static int sandbox_spi_set_wordlen(struct udevice *dev, unsigned int wordlen)
 {
 	struct spi_slave *slave = dev_get_parent_priv(dev);