mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
spi: armada-3700: switch to managed controller allocation
Switch to device managed controller allocation for consistency and to simplify error handling. Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20260511150408.796155-3-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
a7a24f0eaa
commit
5b4a0450fe
|
|
@ -818,17 +818,13 @@ static int a3700_spi_probe(struct platform_device *pdev)
|
|||
u32 num_cs = 0;
|
||||
int irq, ret = 0;
|
||||
|
||||
host = spi_alloc_host(dev, sizeof(*spi));
|
||||
if (!host) {
|
||||
dev_err(dev, "host allocation failed\n");
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
host = devm_spi_alloc_host(dev, sizeof(*spi));
|
||||
if (!host)
|
||||
return -ENOMEM;
|
||||
|
||||
if (of_property_read_u32(dev->of_node, "num-cs", &num_cs)) {
|
||||
dev_err(dev, "could not find num-cs\n");
|
||||
ret = -ENXIO;
|
||||
goto error;
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
host->bus_num = pdev->id;
|
||||
|
|
@ -849,25 +845,20 @@ static int a3700_spi_probe(struct platform_device *pdev)
|
|||
spi->host = host;
|
||||
|
||||
spi->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(spi->base)) {
|
||||
ret = PTR_ERR(spi->base);
|
||||
goto error;
|
||||
}
|
||||
if (IS_ERR(spi->base))
|
||||
return PTR_ERR(spi->base);
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0) {
|
||||
ret = -ENXIO;
|
||||
goto error;
|
||||
}
|
||||
if (irq < 0)
|
||||
return -ENXIO;
|
||||
|
||||
spi->irq = irq;
|
||||
|
||||
init_completion(&spi->done);
|
||||
|
||||
spi->clk = devm_clk_get_prepared(dev, NULL);
|
||||
if (IS_ERR(spi->clk)) {
|
||||
dev_err(dev, "could not find clk: %ld\n", PTR_ERR(spi->clk));
|
||||
goto error;
|
||||
}
|
||||
if (IS_ERR(spi->clk))
|
||||
return dev_err_probe(dev, PTR_ERR(spi->clk), "could not find clk\n");
|
||||
|
||||
host->max_speed_hz = min_t(unsigned long, A3700_SPI_MAX_SPEED_HZ,
|
||||
clk_get_rate(spi->clk));
|
||||
|
|
@ -878,23 +869,16 @@ static int a3700_spi_probe(struct platform_device *pdev)
|
|||
|
||||
ret = devm_request_irq(dev, spi->irq, a3700_spi_interrupt, 0,
|
||||
dev_name(dev), host);
|
||||
if (ret) {
|
||||
dev_err(dev, "could not request IRQ: %d\n", ret);
|
||||
goto error;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "could not request IRQ\n");
|
||||
|
||||
ret = devm_spi_register_controller(dev, host);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to register host\n");
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
spi_controller_put(host);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct platform_driver a3700_spi_driver = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user