Skip to content

Commit c514f73

Browse files
committed
Merge tag 'spi-fix-v7.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fixes from Mark Brown: "A small collection of fixes, mostly probe/remove issues that are the result of Felix Gu going and auditing those areas, plus one error handling fix for the Cadence QSPI driver" * tag 'spi-fix-v7.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: cadence-qspi: Fix exec_mem_op error handling spi: amlogic: spifc-a4: unregister ECC engine on probe failure and remove() callback spi: stm32-ospi: Fix DMA channel leak on stm32_ospi_dma_setup() failure spi: stm32-ospi: Fix reset control leak on probe error spi: stm32-ospi: Fix resource leak in remove() callback
2 parents 1270605 + 59e1be1 commit c514f73

3 files changed

Lines changed: 27 additions & 14 deletions

File tree

drivers/spi/spi-amlogic-spifc-a4.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,13 @@ static const struct nand_ecc_engine_ops aml_sfc_ecc_engine_ops = {
10661066
.finish_io_req = aml_sfc_ecc_finish_io_req,
10671067
};
10681068

1069+
static void aml_sfc_unregister_ecc_engine(void *data)
1070+
{
1071+
struct nand_ecc_engine *eng = data;
1072+
1073+
nand_ecc_unregister_on_host_hw_engine(eng);
1074+
}
1075+
10691076
static int aml_sfc_clk_init(struct aml_sfc *sfc)
10701077
{
10711078
sfc->gate_clk = devm_clk_get_enabled(sfc->dev, "gate");
@@ -1149,6 +1156,11 @@ static int aml_sfc_probe(struct platform_device *pdev)
11491156
if (ret)
11501157
return dev_err_probe(&pdev->dev, ret, "failed to register Aml host ecc engine.\n");
11511158

1159+
ret = devm_add_action_or_reset(dev, aml_sfc_unregister_ecc_engine,
1160+
&sfc->ecc_eng);
1161+
if (ret)
1162+
return dev_err_probe(dev, ret, "failed to add ECC unregister action\n");
1163+
11521164
ret = of_property_read_u32(np, "amlogic,rx-adj", &val);
11531165
if (!ret)
11541166
sfc->rx_adj = val;

drivers/spi/spi-cadence-quadspi.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,14 +1483,6 @@ static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
14831483
if (refcount_read(&cqspi->inflight_ops) == 0)
14841484
return -ENODEV;
14851485

1486-
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
1487-
ret = pm_runtime_resume_and_get(dev);
1488-
if (ret) {
1489-
dev_err(&mem->spi->dev, "resume failed with %d\n", ret);
1490-
return ret;
1491-
}
1492-
}
1493-
14941486
if (!refcount_read(&cqspi->refcount))
14951487
return -EBUSY;
14961488

@@ -1502,6 +1494,14 @@ static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
15021494
return -EBUSY;
15031495
}
15041496

1497+
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
1498+
ret = pm_runtime_resume_and_get(dev);
1499+
if (ret) {
1500+
dev_err(&mem->spi->dev, "resume failed with %d\n", ret);
1501+
goto dec_inflight_refcount;
1502+
}
1503+
}
1504+
15051505
ret = cqspi_mem_process(mem, op);
15061506

15071507
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
@@ -1510,6 +1510,7 @@ static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
15101510
if (ret)
15111511
dev_err(&mem->spi->dev, "operation failed with %d\n", ret);
15121512

1513+
dec_inflight_refcount:
15131514
if (refcount_read(&cqspi->inflight_ops) > 1)
15141515
refcount_dec(&cqspi->inflight_ops);
15151516

drivers/spi/spi-stm32-ospi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ static int stm32_ospi_probe(struct platform_device *pdev)
928928
dma_cfg.dst_addr = ospi->regs_phys_base + OSPI_DR;
929929
ret = stm32_ospi_dma_setup(ospi, &dma_cfg);
930930
if (ret)
931-
return ret;
931+
goto err_dma_free;
932932

933933
mutex_init(&ospi->lock);
934934

@@ -965,19 +965,22 @@ static int stm32_ospi_probe(struct platform_device *pdev)
965965
if (ret) {
966966
/* Disable ospi */
967967
writel_relaxed(0, ospi->regs_base + OSPI_CR);
968-
goto err_pm_resume;
968+
goto err_reset_control;
969969
}
970970

971971
pm_runtime_put_autosuspend(ospi->dev);
972972

973973
return 0;
974974

975+
err_reset_control:
976+
reset_control_release(ospi->rstc);
975977
err_pm_resume:
976978
pm_runtime_put_sync_suspend(ospi->dev);
977979

978980
err_pm_enable:
979981
pm_runtime_force_suspend(ospi->dev);
980982
mutex_destroy(&ospi->lock);
983+
err_dma_free:
981984
if (ospi->dma_chtx)
982985
dma_release_channel(ospi->dma_chtx);
983986
if (ospi->dma_chrx)
@@ -989,11 +992,8 @@ static int stm32_ospi_probe(struct platform_device *pdev)
989992
static void stm32_ospi_remove(struct platform_device *pdev)
990993
{
991994
struct stm32_ospi *ospi = platform_get_drvdata(pdev);
992-
int ret;
993995

994-
ret = pm_runtime_resume_and_get(ospi->dev);
995-
if (ret < 0)
996-
return;
996+
pm_runtime_resume_and_get(ospi->dev);
997997

998998
spi_unregister_controller(ospi->ctrl);
999999
/* Disable ospi */

0 commit comments

Comments
 (0)