From 33336e78f626623fbcf0646d96040b6ead291fb0 Mon Sep 17 00:00:00 2001 From: Maksim Masalski Date: Wed, 25 Dec 2019 14:13:36 +0800 Subject: [PATCH] drivers: spi: Support PM busy state where relevant in DW Need to set device busy when enter into transceive function in SPI DW driver. In current SPI DW driver the transceive function don't set busy state, but that is important for PM busy state. This will lead to unexpected behaviors when system calls this function and enter into idle state. Signed-off-by: Maksim Masalski Signed-off-by: Anas Nashif --- drivers/spi/spi_dw.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/spi/spi_dw.c b/drivers/spi/spi_dw.c index 65e24f8d608..58fb119476f 100644 --- a/drivers/spi/spi_dw.c +++ b/drivers/spi/spi_dw.c @@ -342,6 +342,12 @@ static int transceive(struct device *dev, spi_context_lock(&spi->ctx, asynchronous, signal); +#ifdef CONFIG_DEVICE_POWER_MANAGEMENT + if (device_busy_check(dev) != (-EBUSY)) { + device_busy_set(dev); + } +#endif /* CONFIG_DEVICE_POWER_MANAGEMENT */ + /* Configure */ ret = spi_dw_configure(info, spi, config); if (ret) { @@ -427,6 +433,8 @@ static int transceive(struct device *dev, out: spi_context_release(&spi->ctx, ret); + device_busy_clear(dev); + return ret; }