aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-17 16:34:25 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-17 16:34:25 -0400
commit3918c21eacb06e3d9d43f718354cbce6703f4812 (patch)
tree101470f8b302ef45644361a1b787b1d2f1df68e2
parentad3273d5f1b99d7319a986ab568dcbde2f9e53dd (diff)
parent5223c9c1cbfc0cd4d0a1b50758e0949af3290fa1 (diff)
Merge tag 'spi-fix-v4.19-rc4' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Mark writes: "spi: Fixes for v4.19 As well as one driver fix there's a couple of fixes here which address issues with the use of IDRs for allocation of dynamic bus numbers, ensuring that dynamic bus numbers interact well with static bus numbers assigned via DT and otherwise." * tag 'spi-fix-v4.19-rc4' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: spi-fsl-dspi: fix broken DSPI_EOQ_MODE spi: Fix double IDR allocation with DT aliases spi: fix IDR collision on systems with both fixed and dynamic SPI bus numbers
-rw-r--r--drivers/spi/spi-fsl-dspi.c6
-rw-r--r--drivers/spi/spi.c13
2 files changed, 17 insertions, 2 deletions
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 7cb3ab0a35a0..3082e72e4f6c 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -30,7 +30,11 @@
30 30
31#define DRIVER_NAME "fsl-dspi" 31#define DRIVER_NAME "fsl-dspi"
32 32
33#ifdef CONFIG_M5441x
34#define DSPI_FIFO_SIZE 16
35#else
33#define DSPI_FIFO_SIZE 4 36#define DSPI_FIFO_SIZE 4
37#endif
34#define DSPI_DMA_BUFSIZE (DSPI_FIFO_SIZE * 1024) 38#define DSPI_DMA_BUFSIZE (DSPI_FIFO_SIZE * 1024)
35 39
36#define SPI_MCR 0x00 40#define SPI_MCR 0x00
@@ -623,9 +627,11 @@ static void dspi_tcfq_read(struct fsl_dspi *dspi)
623static void dspi_eoq_write(struct fsl_dspi *dspi) 627static void dspi_eoq_write(struct fsl_dspi *dspi)
624{ 628{
625 int fifo_size = DSPI_FIFO_SIZE; 629 int fifo_size = DSPI_FIFO_SIZE;
630 u16 xfer_cmd = dspi->tx_cmd;
626 631
627 /* Fill TX FIFO with as many transfers as possible */ 632 /* Fill TX FIFO with as many transfers as possible */
628 while (dspi->len && fifo_size--) { 633 while (dspi->len && fifo_size--) {
634 dspi->tx_cmd = xfer_cmd;
629 /* Request EOQF for last transfer in FIFO */ 635 /* Request EOQF for last transfer in FIFO */
630 if (dspi->len == dspi->bytes_per_word || fifo_size == 0) 636 if (dspi->len == dspi->bytes_per_word || fifo_size == 0)
631 dspi->tx_cmd |= SPI_PUSHR_CMD_EOQ; 637 dspi->tx_cmd |= SPI_PUSHR_CMD_EOQ;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index ec395a6baf9c..9da0bc5a036c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2143,8 +2143,17 @@ int spi_register_controller(struct spi_controller *ctlr)
2143 */ 2143 */
2144 if (ctlr->num_chipselect == 0) 2144 if (ctlr->num_chipselect == 0)
2145 return -EINVAL; 2145 return -EINVAL;
2146 /* allocate dynamic bus number using Linux idr */ 2146 if (ctlr->bus_num >= 0) {
2147 if ((ctlr->bus_num < 0) && ctlr->dev.of_node) { 2147 /* devices with a fixed bus num must check-in with the num */
2148 mutex_lock(&board_lock);
2149 id = idr_alloc(&spi_master_idr, ctlr, ctlr->bus_num,
2150 ctlr->bus_num + 1, GFP_KERNEL);
2151 mutex_unlock(&board_lock);
2152 if (WARN(id < 0, "couldn't get idr"))
2153 return id == -ENOSPC ? -EBUSY : id;
2154 ctlr->bus_num = id;
2155 } else if (ctlr->dev.of_node) {
2156 /* allocate dynamic bus number using Linux idr */
2148 id = of_alias_get_id(ctlr->dev.of_node, "spi"); 2157 id = of_alias_get_id(ctlr->dev.of_node, "spi");
2149 if (id >= 0) { 2158 if (id >= 0) {
2150 ctlr->bus_num = id; 2159 ctlr->bus_num = id;