diff mbox series

mtd: devices: m25p80: Use spi_mem_set_drvdata() instead of spi_set_drvdata()

Message ID 20180522105514.8145-1-boris.brezillon@bootlin.com
State Accepted
Headers show
Series mtd: devices: m25p80: Use spi_mem_set_drvdata() instead of spi_set_drvdata() | expand

Commit Message

Boris Brezillon May 22, 2018, 10:55 a.m. UTC
SPI mem drivers should use spi_mem_set_drvdata() not spi_set_drvdata()
to store their private data. Using spi_set_drvdata() will mess the
spi -> spi-mem link up and cause a kernel panic at shutdown or
device removal time.

Fixes: 4120f8d158ef ("mtd: spi-nor: Use the spi_mem_xx() API")
Reported-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Marek Vasut <marek.vasut+renesas@gmail.com> on R8A7791 Porter
---
Hi Mark,

Could you take this patch through the SPI tree? The bug has been
introduced by 4120f8d158ef ("mtd: spi-nor: Use the spi_mem_xx() API")
which is in the spi/for-4.18 branch (I didn't pull these changes in the
MTD tree yet, and if possible I'd like to avoid doing that unless we
end up with a conflict between the MTD and SPI tree).

Let me know if that's not possible and I'll find another solution (wait
-rc1 or merge the spi/for-4.18 branch into the MTD tree).

Thanks,

Boris
---
 drivers/mtd/devices/m25p80.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 3dc022d3b53e..e84563d2067f 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -182,7 +182,7 @@  static int m25p_probe(struct spi_mem *spimem)
 	spi_nor_set_flash_node(nor, spi->dev.of_node);
 	nor->priv = flash;
 
-	spi_set_drvdata(spi, flash);
+	spi_mem_set_drvdata(spimem, flash);
 	flash->spimem = spimem;
 
 	if (spi->mode & SPI_RX_QUAD) {