mirror of
https://github.com/torvalds/linux.git
synced 2025-01-01 15:51:46 +00:00
spi: axi-spi-engine: use devm action to reset hw on remove
This moves the reset of the hardware to a devm action in the AXI SPI Engine driver. This will allow us to use devm on later calls in the probe function while preserving the order during cleanup. Signed-off-by: David Lechner <dlechner@baylibre.com> Link: https://lore.kernel.org/r/20231117-axi-spi-engine-series-1-v1-5-cc59db999b87@baylibre.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
e12cd96e8e
commit
e094de13ae
@ -461,6 +461,15 @@ static int spi_engine_transfer_one_message(struct spi_controller *host,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void spi_engine_release_hw(void *p)
|
||||
{
|
||||
struct spi_engine *spi_engine = p;
|
||||
|
||||
writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
|
||||
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
|
||||
writel_relaxed(0x01, spi_engine->base + SPI_ENGINE_REG_RESET);
|
||||
}
|
||||
|
||||
static int spi_engine_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct spi_engine *spi_engine;
|
||||
@ -506,6 +515,11 @@ static int spi_engine_probe(struct platform_device *pdev)
|
||||
writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
|
||||
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
|
||||
|
||||
ret = devm_add_action_or_reset(&pdev->dev, spi_engine_release_hw,
|
||||
spi_engine);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = request_irq(irq, spi_engine_irq, 0, pdev->name, host);
|
||||
if (ret)
|
||||
return ret;
|
||||
@ -532,16 +546,11 @@ err_free_irq:
|
||||
static void spi_engine_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct spi_controller *host = platform_get_drvdata(pdev);
|
||||
struct spi_engine *spi_engine = spi_controller_get_devdata(host);
|
||||
int irq = platform_get_irq(pdev, 0);
|
||||
|
||||
spi_unregister_controller(host);
|
||||
|
||||
free_irq(irq, host);
|
||||
|
||||
writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
|
||||
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
|
||||
writel_relaxed(0x01, spi_engine->base + SPI_ENGINE_REG_RESET);
|
||||
}
|
||||
|
||||
static const struct of_device_id spi_engine_match_table[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user