diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2023-09-08 15:11:16 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-09-12 11:31:55 +0200 |
commit | a2ec76d9c75edd83b0ce9043d0d15a60cbb36dcf (patch) | |
tree | 4b301104ad59fe81759af62c2ac62df7b572e4ef /drivers/spi/spi.c | |
parent | 51ae3151381b4406f140cbe53c39fe4fe9d2385f (diff) | |
download | barebox-a2ec76d9c75edd83b0ce9043d0d15a60cbb36dcf.tar.gz barebox-a2ec76d9c75edd83b0ce9043d0d15a60cbb36dcf.tar.xz |
spi: Add slices for SPI controllers
Add a slice for SPI controllers so that devices using SPI in the background
can check if a SPI bus is busy.
Tested-by: Gerald Loacker <gerald.loacker@wolfvision.net>
Link: https://lore.barebox.org/20230908131117.1769957-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 584d4ab777..83f2b0ee1b 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -12,6 +12,7 @@ #include <spi/spi.h> #include <xfuncs.h> #include <malloc.h> +#include <slice.h> #include <errno.h> #include <init.h> #include <of.h> @@ -269,6 +270,8 @@ int spi_register_controller(struct spi_controller *ctrl) if (status) return status; + slice_init(&ctrl->slice, dev_name(ctrl->dev)); + /* even if it's just one always-selected device, there must * be at least one chipselect */ @@ -352,12 +355,19 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) int spi_sync(struct spi_device *spi, struct spi_message *message) { int status; + int ret; status = __spi_validate(spi, message); if (status != 0) return status; - return spi->controller->transfer(spi, message); + slice_acquire(&spi->controller->slice); + + ret = spi->controller->transfer(spi, message); + + slice_release(&spi->controller->slice); + + return ret; } /** |