From efd85acb4f2118348fc3a7c831872d5e70c7bec0 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 23 Dec 2013 19:34:23 +0100 Subject: spi: rspi: Fix NULL pointer dereference on SH7757 SH7757 doesn't pass platform data, in which case spi-rspi uses default parameters. However, commit 5ce0ba88650f2606244a761d92e2b725f4ab3583 ("spi: rcar: add Renesas QSPI support on RSPI") added a new user of the platform data, but forgot to check for its validity first, causing a NULL pointer dereference on SH7757. Add the missing check to fix this. Signed-off-by: Geert Uytterhoeven Acked-by: Simon Horman Signed-off-by: Mark Brown --- drivers/spi/spi-rspi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index 58449ad4ad0d..b60862f58534 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c @@ -958,8 +958,9 @@ static int rspi_probe(struct platform_device *pdev) INIT_WORK(&rspi->ws, rspi_work); init_waitqueue_head(&rspi->wait); - master->num_chipselect = rspi_pd->num_chipselect; - if (!master->num_chipselect) + if (rspi_pd && rspi_pd->num_chipselect) + master->num_chipselect = rspi_pd->num_chipselect; + else master->num_chipselect = 2; /* default */ master->bus_num = pdev->id; -- cgit v1.2.2 From df900e678308d7fa1290681bfc336716b084b3c5 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 23 Dec 2013 19:34:24 +0100 Subject: spi: rspi: Fix typo when clearing SPSR_OVRF The overrun flag should be cleared in the SPI Status Register, not in the SPI Control Register, based on the SDK sample code. Signed-off-by: Geert Uytterhoeven Acked-by: Simon Horman Signed-off-by: Mark Brown --- drivers/spi/spi-rspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index b60862f58534..7a185bf431ed 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c @@ -517,7 +517,7 @@ static void rspi_receive_init(struct rspi_data *rspi) rspi_read16(rspi, RSPI_SPDR); /* dummy read */ if (spsr & SPSR_OVRF) rspi_write8(rspi, rspi_read8(rspi, RSPI_SPSR) & ~SPSR_OVRF, - RSPI_SPCR); + RSPI_SPSR); } static int rspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg, -- cgit v1.2.2