Commit c514f733 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents 1270605f 59e1be12
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1066,6 +1066,13 @@ static const struct nand_ecc_engine_ops aml_sfc_ecc_engine_ops = {
	.finish_io_req = aml_sfc_ecc_finish_io_req,
};

static void aml_sfc_unregister_ecc_engine(void *data)
{
	struct nand_ecc_engine *eng = data;

	nand_ecc_unregister_on_host_hw_engine(eng);
}

static int aml_sfc_clk_init(struct aml_sfc *sfc)
{
	sfc->gate_clk = devm_clk_get_enabled(sfc->dev, "gate");
@@ -1149,6 +1156,11 @@ static int aml_sfc_probe(struct platform_device *pdev)
	if (ret)
		return dev_err_probe(&pdev->dev, ret, "failed to register Aml host ecc engine.\n");

	ret = devm_add_action_or_reset(dev, aml_sfc_unregister_ecc_engine,
				       &sfc->ecc_eng);
	if (ret)
		return dev_err_probe(dev, ret, "failed to add ECC unregister action\n");

	ret = of_property_read_u32(np, "amlogic,rx-adj", &val);
	if (!ret)
		sfc->rx_adj = val;
+9 −8
Original line number Diff line number Diff line
@@ -1483,14 +1483,6 @@ static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
	if (refcount_read(&cqspi->inflight_ops) == 0)
		return -ENODEV;

	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
		ret = pm_runtime_resume_and_get(dev);
		if (ret) {
			dev_err(&mem->spi->dev, "resume failed with %d\n", ret);
			return ret;
		}
	}

	if (!refcount_read(&cqspi->refcount))
		return -EBUSY;

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

	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
		ret = pm_runtime_resume_and_get(dev);
		if (ret) {
			dev_err(&mem->spi->dev, "resume failed with %d\n", ret);
			goto dec_inflight_refcount;
		}
	}

	ret = cqspi_mem_process(mem, op);

	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)
	if (ret)
		dev_err(&mem->spi->dev, "operation failed with %d\n", ret);

dec_inflight_refcount:
	if (refcount_read(&cqspi->inflight_ops) > 1)
		refcount_dec(&cqspi->inflight_ops);

+6 −6
Original line number Diff line number Diff line
@@ -928,7 +928,7 @@ static int stm32_ospi_probe(struct platform_device *pdev)
	dma_cfg.dst_addr = ospi->regs_phys_base + OSPI_DR;
	ret = stm32_ospi_dma_setup(ospi, &dma_cfg);
	if (ret)
		return ret;
		goto err_dma_free;

	mutex_init(&ospi->lock);

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

	pm_runtime_put_autosuspend(ospi->dev);

	return 0;

err_reset_control:
	reset_control_release(ospi->rstc);
err_pm_resume:
	pm_runtime_put_sync_suspend(ospi->dev);

err_pm_enable:
	pm_runtime_force_suspend(ospi->dev);
	mutex_destroy(&ospi->lock);
err_dma_free:
	if (ospi->dma_chtx)
		dma_release_channel(ospi->dma_chtx);
	if (ospi->dma_chrx)
@@ -989,11 +992,8 @@ static int stm32_ospi_probe(struct platform_device *pdev)
static void stm32_ospi_remove(struct platform_device *pdev)
{
	struct stm32_ospi *ospi = platform_get_drvdata(pdev);
	int ret;

	ret = pm_runtime_resume_and_get(ospi->dev);
	if (ret < 0)
		return;
	pm_runtime_resume_and_get(ospi->dev);

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