spi: pic32: switch to managed controller allocation

Switch to device managed controller allocation to simplify error
handling and to avoid having to take another reference during
deregistration.

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260505072909.618363-2-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Johan Hovold
2026-05-05 09:28:50 +02:00
committed by Mark Brown
parent 5d6919055d
commit 4af89d7d85

View File

@@ -752,7 +752,7 @@ static int pic32_spi_probe(struct platform_device *pdev)
struct pic32_spi *pic32s;
int ret;
host = spi_alloc_host(&pdev->dev, sizeof(*pic32s));
host = devm_spi_alloc_host(&pdev->dev, sizeof(*pic32s));
if (!host)
return -ENOMEM;
@@ -761,7 +761,7 @@ static int pic32_spi_probe(struct platform_device *pdev)
ret = pic32_spi_hw_probe(pdev, pic32s);
if (ret)
goto err_host;
return ret;
host->dev.of_node = pdev->dev.of_node;
host->mode_bits = SPI_MODE_3 | SPI_MODE_0 | SPI_CS_HIGH;
@@ -833,8 +833,7 @@ static int pic32_spi_probe(struct platform_device *pdev)
err_bailout:
pic32_spi_dma_unprep(pic32s);
err_host:
spi_controller_put(host);
return ret;
}
@@ -842,14 +841,10 @@ static void pic32_spi_remove(struct platform_device *pdev)
{
struct pic32_spi *pic32s = platform_get_drvdata(pdev);
spi_controller_get(pic32s->host);
spi_unregister_controller(pic32s->host);
pic32_spi_disable(pic32s);
pic32_spi_dma_unprep(pic32s);
spi_controller_put(pic32s->host);
}
static const struct of_device_id pic32_spi_of_match[] = {