Skip to content

Commit 606e5d4

Browse files
vaishnavachathbroonie
authored andcommitted
spi: cadence-quadspi: Handle spi_unregister_master() in remove()
Currently devres managed removal of the spi_controller happens after removing the power domain of the host platform_device.While this does not affect the clean removal of the controller, but affects graceful removal of the child devices if the child device removal requires issuing commands over SPI. Eg. flash device being soft reset to 1S-1S-1S mode before removal so that on next probe operations in 1S-1S-1S mode is successful. Failure is seen when `rmmod spi-cadence-quadspi` is performed: root@j7-evm:~# rmmod spi_cadence_quadspi [ 49.230996] cadence-qspi 47050000.spi: QSPI is still busy after 500ms timeout. [ 49.238209] spi-nor spi1.0: operation failed with -110 [ 49.244457] spi-nor spi1.0: Software reset failed: -110 and on subsequent modprobe the OSPI flash probe fails as it is in 8D-8D-8D mode since the previous soft reset did not happen. root@j7-evm:~# modprobe spi_cadence_quadspi [ 73.253536] spi-nor spi0.0: unrecognized JEDEC id bytes: ff ff ff ff ff ff [ 73.260476] spi-nor: probe of spi0.0 failed with error -2 This commit adds necessary changes to perform spi_unregister_master() in the host device remove() so that the child devices are gracefully removed before the power domain is removed. changes tested on J721E with mt35xu512aba flash. Signed-off-by: Vaishnav Achath <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent d5efbfc commit 606e5d4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/spi/spi-cadence-quadspi.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct cqspi_flash_pdata {
6060

6161
struct cqspi_st {
6262
struct platform_device *pdev;
63-
63+
struct spi_master *master;
6464
struct clk *clk;
6565
unsigned int sclk;
6666

@@ -1558,7 +1558,7 @@ static int cqspi_probe(struct platform_device *pdev)
15581558
int ret;
15591559
int irq;
15601560

1561-
master = spi_alloc_master(&pdev->dev, sizeof(*cqspi));
1561+
master = devm_spi_alloc_master(&pdev->dev, sizeof(*cqspi));
15621562
if (!master) {
15631563
dev_err(&pdev->dev, "spi_alloc_master failed\n");
15641564
return -ENOMEM;
@@ -1571,6 +1571,7 @@ static int cqspi_probe(struct platform_device *pdev)
15711571
cqspi = spi_master_get_devdata(master);
15721572

15731573
cqspi->pdev = pdev;
1574+
cqspi->master = master;
15741575
platform_set_drvdata(pdev, cqspi);
15751576

15761577
/* Obtain configuration from OF. */
@@ -1701,7 +1702,7 @@ static int cqspi_probe(struct platform_device *pdev)
17011702
goto probe_setup_failed;
17021703
}
17031704

1704-
ret = devm_spi_register_master(dev, master);
1705+
ret = spi_register_master(master);
17051706
if (ret) {
17061707
dev_err(&pdev->dev, "failed to register SPI ctlr %d\n", ret);
17071708
goto probe_setup_failed;
@@ -1724,6 +1725,7 @@ static int cqspi_remove(struct platform_device *pdev)
17241725
{
17251726
struct cqspi_st *cqspi = platform_get_drvdata(pdev);
17261727

1728+
spi_unregister_master(cqspi->master);
17271729
cqspi_controller_enable(cqspi, 0);
17281730

17291731
if (cqspi->rx_chan)

0 commit comments

Comments
 (0)