Skip to content

Commit 4073195

Browse files
committed
Merge tag 'spi-fix-v6.9-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fixes from Mark Brown: "A small collection of fixes that came in since the merge window. Most of it is relatively minor driver specific fixes, there's also fixes for error handling with SPI flash devices and a fix restoring delay control functionality for non-GPIO chip selects managed by the core" * tag 'spi-fix-v6.9-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: spi-mt65xx: Fix NULL pointer access in interrupt handler spi: docs: spidev: fix echo command format spi: spi-imx: fix off-by-one in mx51 CPU mode burst length spi: lm70llp: fix links in doc and comments spi: Fix error code checking in spi_mem_exec_op() spi: Restore delays for non-GPIO chip select spi: lpspi: Avoid potential use-after-free in probe()
2 parents 8c826bd + a20ad45 commit 4073195

File tree

8 files changed

+38
-32
lines changed

8 files changed

+38
-32
lines changed

Documentation/spi/spi-lm70llp.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Supported board/chip:
66

77
* National Semiconductor LM70 LLP evaluation board
88

9-
Datasheet: http://www.national.com/pf/LM/LM70.html
9+
Datasheet: https://www.ti.com/lit/gpn/lm70
1010

1111
Author:
1212
Kaiwan N Billimoria <kaiwan@designergraphix.com>
@@ -28,7 +28,7 @@ Hardware Interfacing
2828
The schematic for this particular board (the LM70EVAL-LLP) is
2929
available (on page 4) here:
3030

31-
http://www.national.com/appinfo/tempsensors/files/LM70LLPEVALmanual.pdf
31+
https://download.datasheets.com/pdfs/documentation/nat/kit&board/lm70llpevalmanual.pdf
3232

3333
The hardware interfacing on the LM70 LLP eval board is as follows:
3434

Documentation/spi/spidev.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ the spidev driver failing to probe.
6161

6262
Sysfs also supports userspace driven binding/unbinding of drivers to
6363
devices that do not bind automatically using one of the tables above.
64-
To make the spidev driver bind to such a device, use the following:
64+
To make the spidev driver bind to such a device, use the following::
6565

6666
echo spidev > /sys/bus/spi/devices/spiB.C/driver_override
6767
echo spiB.C > /sys/bus/spi/drivers/spidev/bind

drivers/spi/spi-fsl-lpspi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -830,11 +830,11 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
830830

831831
is_target = of_property_read_bool((&pdev->dev)->of_node, "spi-slave");
832832
if (is_target)
833-
controller = spi_alloc_target(&pdev->dev,
834-
sizeof(struct fsl_lpspi_data));
833+
controller = devm_spi_alloc_target(&pdev->dev,
834+
sizeof(struct fsl_lpspi_data));
835835
else
836-
controller = spi_alloc_host(&pdev->dev,
837-
sizeof(struct fsl_lpspi_data));
836+
controller = devm_spi_alloc_host(&pdev->dev,
837+
sizeof(struct fsl_lpspi_data));
838838

839839
if (!controller)
840840
return -ENOMEM;

drivers/spi/spi-imx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,8 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx,
668668
ctrl |= (MX51_ECSPI_CTRL_MAX_BURST * BITS_PER_BYTE - 1)
669669
<< MX51_ECSPI_CTRL_BL_OFFSET;
670670
else
671-
ctrl |= spi_imx->count / DIV_ROUND_UP(spi_imx->bits_per_word,
672-
BITS_PER_BYTE) * spi_imx->bits_per_word
671+
ctrl |= (spi_imx->count / DIV_ROUND_UP(spi_imx->bits_per_word,
672+
BITS_PER_BYTE) * spi_imx->bits_per_word - 1)
673673
<< MX51_ECSPI_CTRL_BL_OFFSET;
674674
}
675675
}

drivers/spi/spi-lm70llp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
*
3030
* Datasheet and Schematic:
3131
* The LM70 is a temperature sensor chip from National Semiconductor; its
32-
* datasheet is available at http://www.national.com/pf/LM/LM70.html
32+
* datasheet is available at https://www.ti.com/lit/gpn/lm70
3333
* The schematic for this particular board (the LM70EVAL-LLP) is
3434
* available (on page 4) here:
35-
* http://www.national.com/appinfo/tempsensors/files/LM70LLPEVALmanual.pdf
35+
* https://download.datasheets.com/pdfs/documentation/nat/kit&board/lm70llpevalmanual.pdf
3636
*
3737
* Also see Documentation/spi/spi-lm70llp.rst. The SPI<->parport code here is
3838
* (heavily) based on spi-butterfly by David Brownell.

drivers/spi/spi-mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
382382
* read path) and expect the core to use the regular SPI
383383
* interface in other cases.
384384
*/
385-
if (!ret || ret != -ENOTSUPP || ret != -EOPNOTSUPP) {
385+
if (!ret || (ret != -ENOTSUPP && ret != -EOPNOTSUPP)) {
386386
spi_mem_add_op_stats(ctlr->pcpu_statistics, op, ret);
387387
spi_mem_add_op_stats(mem->spi->pcpu_statistics, op, ret);
388388

drivers/spi/spi-mt65xx.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -788,17 +788,19 @@ static irqreturn_t mtk_spi_interrupt(int irq, void *dev_id)
788788
mdata->xfer_len = min(MTK_SPI_MAX_FIFO_SIZE, len);
789789
mtk_spi_setup_packet(host);
790790

791-
cnt = mdata->xfer_len / 4;
792-
iowrite32_rep(mdata->base + SPI_TX_DATA_REG,
793-
trans->tx_buf + mdata->num_xfered, cnt);
791+
if (trans->tx_buf) {
792+
cnt = mdata->xfer_len / 4;
793+
iowrite32_rep(mdata->base + SPI_TX_DATA_REG,
794+
trans->tx_buf + mdata->num_xfered, cnt);
794795

795-
remainder = mdata->xfer_len % 4;
796-
if (remainder > 0) {
797-
reg_val = 0;
798-
memcpy(&reg_val,
799-
trans->tx_buf + (cnt * 4) + mdata->num_xfered,
800-
remainder);
801-
writel(reg_val, mdata->base + SPI_TX_DATA_REG);
796+
remainder = mdata->xfer_len % 4;
797+
if (remainder > 0) {
798+
reg_val = 0;
799+
memcpy(&reg_val,
800+
trans->tx_buf + (cnt * 4) + mdata->num_xfered,
801+
remainder);
802+
writel(reg_val, mdata->base + SPI_TX_DATA_REG);
803+
}
802804
}
803805

804806
mtk_spi_enable_transfer(host);

drivers/spi/spi.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,10 +1063,14 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
10631063
if (spi->mode & SPI_CS_HIGH)
10641064
enable = !enable;
10651065

1066-
if (spi_is_csgpiod(spi)) {
1067-
if (!spi->controller->set_cs_timing && !activate)
1068-
spi_delay_exec(&spi->cs_hold, NULL);
1066+
/*
1067+
* Handle chip select delays for GPIO based CS or controllers without
1068+
* programmable chip select timing.
1069+
*/
1070+
if ((spi_is_csgpiod(spi) || !spi->controller->set_cs_timing) && !activate)
1071+
spi_delay_exec(&spi->cs_hold, NULL);
10691072

1073+
if (spi_is_csgpiod(spi)) {
10701074
if (!(spi->mode & SPI_NO_CS)) {
10711075
/*
10721076
* Historically ACPI has no means of the GPIO polarity and
@@ -1099,16 +1103,16 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
10991103
if ((spi->controller->flags & SPI_CONTROLLER_GPIO_SS) &&
11001104
spi->controller->set_cs)
11011105
spi->controller->set_cs(spi, !enable);
1102-
1103-
if (!spi->controller->set_cs_timing) {
1104-
if (activate)
1105-
spi_delay_exec(&spi->cs_setup, NULL);
1106-
else
1107-
spi_delay_exec(&spi->cs_inactive, NULL);
1108-
}
11091106
} else if (spi->controller->set_cs) {
11101107
spi->controller->set_cs(spi, !enable);
11111108
}
1109+
1110+
if (spi_is_csgpiod(spi) || !spi->controller->set_cs_timing) {
1111+
if (activate)
1112+
spi_delay_exec(&spi->cs_setup, NULL);
1113+
else
1114+
spi_delay_exec(&spi->cs_inactive, NULL);
1115+
}
11121116
}
11131117

11141118
#ifdef CONFIG_HAS_DMA

0 commit comments

Comments
 (0)