From 214e7d889e9f217a76522aad826a605febee6084 Mon Sep 17 00:00:00 2001 From: Amit Kumar Mahapatra Date: Tue, 2 May 2023 15:46:08 +0530 Subject: [PATCH] spi: cs gpio call trace fix --- drivers/spi/spi.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 63b9ac43f674..ab70baaf5fd4 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -662,8 +662,12 @@ static int __spi_add_device(struct spi_device *spi) } if (ctlr->cs_gpiods) { - for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) - spi_set_csgpiod(spi, idx, ctlr->cs_gpiods[spi_get_chipselect(spi, idx)]); + for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) { + if (!(idx != 0 && !spi_get_chipselect(spi, idx))) { + printk("%s( ) [%d] cs[%d] = [%d]\n", __func__, __LINE__, idx, spi_get_chipselect(spi, idx)); + spi_set_csgpiod(spi, idx, ctlr->cs_gpiods[spi_get_chipselect(spi, idx)]); + } + } } /* @@ -985,7 +989,7 @@ static void spi_res_release(struct spi_controller *ctlr, struct spi_message *mes static void spi_set_cs(struct spi_device *spi, bool enable, bool force) { bool activate = enable; - u32 cs_num = __ffs(spi->cs_index_mask); + u32 cs_num = 0; int idx; /* @@ -1040,6 +1044,12 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) spi_delay_exec(&spi->cs_inactive, NULL); } } else { + + if (spi->cs_index_mask) + cs_num = ffs(spi->cs_index_mask) - 1; + + printk("%s( ) [%d] spi->cs_index_mask == [%d]\n", __func__, __LINE__, spi->cs_index_mask); + printk("%s( ) [%d] cs_num == [%d]\n", __func__, __LINE__, cs_num); /* * Avoid calling into the driver (or doing delays) if the chip select * isn't actually changing from the last time this was called. -- 2.17.1