mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
spi: cavium-thunderx: 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/20260429091333.165363-8-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
eab6ce9412
commit
fcca78c086
|
|
@ -24,7 +24,7 @@ static int thunderx_spi_probe(struct pci_dev *pdev,
|
|||
struct octeon_spi *p;
|
||||
int ret;
|
||||
|
||||
host = spi_alloc_host(dev, sizeof(struct octeon_spi));
|
||||
host = devm_spi_alloc_host(dev, sizeof(struct octeon_spi));
|
||||
if (!host)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -32,17 +32,15 @@ static int thunderx_spi_probe(struct pci_dev *pdev,
|
|||
|
||||
ret = pcim_enable_device(pdev);
|
||||
if (ret)
|
||||
goto error;
|
||||
return ret;
|
||||
|
||||
ret = pcim_request_all_regions(pdev, DRV_NAME);
|
||||
if (ret)
|
||||
goto error;
|
||||
return ret;
|
||||
|
||||
p->register_base = pcim_iomap(pdev, 0, pci_resource_len(pdev, 0));
|
||||
if (!p->register_base) {
|
||||
ret = -EINVAL;
|
||||
goto error;
|
||||
}
|
||||
if (!p->register_base)
|
||||
return -EINVAL;
|
||||
|
||||
p->regs.config = 0x1000;
|
||||
p->regs.status = 0x1008;
|
||||
|
|
@ -50,10 +48,8 @@ static int thunderx_spi_probe(struct pci_dev *pdev,
|
|||
p->regs.data = 0x1080;
|
||||
|
||||
p->clk = devm_clk_get_enabled(dev, NULL);
|
||||
if (IS_ERR(p->clk)) {
|
||||
ret = PTR_ERR(p->clk);
|
||||
goto error;
|
||||
}
|
||||
if (IS_ERR(p->clk))
|
||||
return PTR_ERR(p->clk);
|
||||
|
||||
p->sys_freq = clk_get_rate(p->clk);
|
||||
if (!p->sys_freq)
|
||||
|
|
@ -70,15 +66,7 @@ static int thunderx_spi_probe(struct pci_dev *pdev,
|
|||
|
||||
pci_set_drvdata(pdev, host);
|
||||
|
||||
ret = spi_register_controller(host);
|
||||
if (ret)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
spi_controller_put(host);
|
||||
return ret;
|
||||
return spi_register_controller(host);
|
||||
}
|
||||
|
||||
static void thunderx_spi_remove(struct pci_dev *pdev)
|
||||
|
|
@ -90,14 +78,10 @@ static void thunderx_spi_remove(struct pci_dev *pdev)
|
|||
if (!p)
|
||||
return;
|
||||
|
||||
spi_controller_get(host);
|
||||
|
||||
spi_unregister_controller(host);
|
||||
|
||||
/* Put everything in a known state. */
|
||||
writeq(0, p->register_base + OCTEON_SPI_CFG(p));
|
||||
|
||||
spi_controller_put(host);
|
||||
}
|
||||
|
||||
static const struct pci_device_id thunderx_spi_pci_id_table[] = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user