* [PATCH 01/20] spi: pic32: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
@ 2026-05-05 7:28 ` Johan Hovold
2026-05-05 7:28 ` [PATCH 02/20] spi: pic32-sqi: " Johan Hovold
` (19 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:28 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-pic32.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/spi-pic32.c b/drivers/spi/spi-pic32.c
index 70427e529945..972128271e4b 100644
--- a/drivers/spi/spi-pic32.c
+++ b/drivers/spi/spi-pic32.c
@@ -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[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 02/20] spi: pic32-sqi: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
2026-05-05 7:28 ` [PATCH 01/20] spi: pic32: switch to managed controller allocation Johan Hovold
@ 2026-05-05 7:28 ` Johan Hovold
2026-05-05 7:28 ` [PATCH 03/20] spi: pl022: " Johan Hovold
` (18 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:28 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-pic32-sqi.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/drivers/spi/spi-pic32-sqi.c b/drivers/spi/spi-pic32-sqi.c
index 41662992dbe5..5d3921e29461 100644
--- a/drivers/spi/spi-pic32-sqi.c
+++ b/drivers/spi/spi-pic32-sqi.c
@@ -572,7 +572,7 @@ static int pic32_sqi_probe(struct platform_device *pdev)
struct pic32_sqi *sqi;
int ret;
- host = spi_alloc_host(&pdev->dev, sizeof(*sqi));
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(*sqi));
if (!host)
return -ENOMEM;
@@ -580,31 +580,25 @@ static int pic32_sqi_probe(struct platform_device *pdev)
sqi->host = host;
sqi->regs = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(sqi->regs)) {
- ret = PTR_ERR(sqi->regs);
- goto err_free_host;
- }
+ if (IS_ERR(sqi->regs))
+ return PTR_ERR(sqi->regs);
/* irq */
sqi->irq = platform_get_irq(pdev, 0);
- if (sqi->irq < 0) {
- ret = sqi->irq;
- goto err_free_host;
- }
+ if (sqi->irq < 0)
+ return sqi->irq;
/* clocks */
sqi->sys_clk = devm_clk_get_enabled(&pdev->dev, "reg_ck");
if (IS_ERR(sqi->sys_clk)) {
- ret = PTR_ERR(sqi->sys_clk);
dev_err(&pdev->dev, "no sys_clk ?\n");
- goto err_free_host;
+ return PTR_ERR(sqi->sys_clk);
}
sqi->base_clk = devm_clk_get_enabled(&pdev->dev, "spi_ck");
if (IS_ERR(sqi->base_clk)) {
- ret = PTR_ERR(sqi->base_clk);
dev_err(&pdev->dev, "no base clk ?\n");
- goto err_free_host;
+ return PTR_ERR(sqi->base_clk);
}
init_completion(&sqi->xfer_done);
@@ -616,7 +610,7 @@ static int pic32_sqi_probe(struct platform_device *pdev)
ret = ring_desc_ring_alloc(sqi);
if (ret) {
dev_err(&pdev->dev, "ring alloc failed\n");
- goto err_free_host;
+ return ret;
}
/* install irq handlers */
@@ -656,8 +650,6 @@ static int pic32_sqi_probe(struct platform_device *pdev)
err_free_ring:
ring_desc_ring_free(sqi);
-err_free_host:
- spi_controller_put(host);
return ret;
}
@@ -665,15 +657,11 @@ static void pic32_sqi_remove(struct platform_device *pdev)
{
struct pic32_sqi *sqi = platform_get_drvdata(pdev);
- spi_controller_get(sqi->host);
-
spi_unregister_controller(sqi->host);
/* release resources */
free_irq(sqi->irq, sqi);
ring_desc_ring_free(sqi);
-
- spi_controller_put(sqi->host);
}
static const struct of_device_id pic32_sqi_of_ids[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 03/20] spi: pl022: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
2026-05-05 7:28 ` [PATCH 01/20] spi: pic32: switch to managed controller allocation Johan Hovold
2026-05-05 7:28 ` [PATCH 02/20] spi: pic32-sqi: " Johan Hovold
@ 2026-05-05 7:28 ` Johan Hovold
2026-05-05 9:12 ` Linus Walleij
2026-05-05 7:28 ` [PATCH 04/20] spi: qup: " Johan Hovold
` (17 subsequent siblings)
20 siblings, 1 reply; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:28 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-pl022.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 9c0211f94fd0..95652df5fd09 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1868,7 +1868,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
}
/* Allocate host with space for data */
- host = spi_alloc_host(dev, sizeof(struct pl022));
+ host = devm_spi_alloc_host(dev, sizeof(struct pl022));
if (host == NULL) {
dev_err(&adev->dev, "probe - cannot alloc SPI host\n");
return -ENOMEM;
@@ -1907,7 +1907,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
status = amba_request_regions(adev, NULL);
if (status)
- goto err_no_ioregion;
+ return status;
pl022->phybase = adev->res.start;
pl022->virtbase = devm_ioremap(dev, adev->res.start,
@@ -1984,8 +1984,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
err_no_clk:
err_no_ioremap:
amba_release_regions(adev);
- err_no_ioregion:
- spi_controller_put(host);
+
return status;
}
@@ -1997,8 +1996,6 @@ pl022_remove(struct amba_device *adev)
if (!pl022)
return;
- spi_controller_get(pl022->host);
-
spi_unregister_controller(pl022->host);
/*
@@ -2012,8 +2009,6 @@ pl022_remove(struct amba_device *adev)
pl022_dma_remove(pl022);
amba_release_regions(adev);
-
- spi_controller_put(pl022->host);
}
#ifdef CONFIG_PM_SLEEP
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 03/20] spi: pl022: switch to managed controller allocation
2026-05-05 7:28 ` [PATCH 03/20] spi: pl022: " Johan Hovold
@ 2026-05-05 9:12 ` Linus Walleij
0 siblings, 0 replies; 23+ messages in thread
From: Linus Walleij @ 2026-05-05 9:12 UTC (permalink / raw)
To: Johan Hovold
Cc: Mark Brown, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel
On Tue, May 5, 2026 at 9:29 AM Johan Hovold <johan@kernel.org> wrote:
> 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>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 04/20] spi: qup: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (2 preceding siblings ...)
2026-05-05 7:28 ` [PATCH 03/20] spi: pl022: " Johan Hovold
@ 2026-05-05 7:28 ` Johan Hovold
2026-05-05 7:28 ` [PATCH 05/20] spi: rspi: " Johan Hovold
` (16 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:28 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-qup.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
index 45d9b4cb75e4..4df01ef2e662 100644
--- a/drivers/spi/spi-qup.c
+++ b/drivers/spi/spi-qup.c
@@ -1071,11 +1071,9 @@ static int spi_qup_probe(struct platform_device *pdev)
if (ret && ret != -ENODEV)
return dev_err_probe(dev, ret, "invalid OPP table\n");
- host = spi_alloc_host(dev, sizeof(struct spi_qup));
- if (!host) {
- dev_err(dev, "cannot allocate host\n");
+ host = devm_spi_alloc_host(dev, sizeof(struct spi_qup));
+ if (!host)
return -ENOMEM;
- }
/* use num-cs unless not present or out of range */
if (of_property_read_u32(dev->of_node, "num-cs", &num_cs) ||
@@ -1108,7 +1106,7 @@ static int spi_qup_probe(struct platform_device *pdev)
ret = spi_qup_init_dma(host, res->start);
if (ret == -EPROBE_DEFER)
- goto error;
+ return ret;
else if (!ret)
host->can_dma = spi_qup_can_dma;
@@ -1206,8 +1204,7 @@ static int spi_qup_probe(struct platform_device *pdev)
clk_disable_unprepare(iclk);
error_dma:
spi_qup_release_dma(host);
-error:
- spi_controller_put(host);
+
return ret;
}
@@ -1320,8 +1317,6 @@ static void spi_qup_remove(struct platform_device *pdev)
struct spi_qup *controller = spi_controller_get_devdata(host);
int ret;
- spi_controller_get(host);
-
spi_unregister_controller(host);
ret = pm_runtime_get_sync(&pdev->dev);
@@ -1343,8 +1338,6 @@ static void spi_qup_remove(struct platform_device *pdev)
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
-
- spi_controller_put(host);
}
static const struct of_device_id spi_qup_dt_match[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 05/20] spi: rspi: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (3 preceding siblings ...)
2026-05-05 7:28 ` [PATCH 04/20] spi: qup: " Johan Hovold
@ 2026-05-05 7:28 ` Johan Hovold
2026-05-05 7:28 ` [PATCH 06/20] spi: sh-hspi: " Johan Hovold
` (15 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:28 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-rspi.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index a8180dece716..951e9a8af547 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -1171,14 +1171,10 @@ static void rspi_remove(struct platform_device *pdev)
{
struct rspi_data *rspi = platform_get_drvdata(pdev);
- spi_controller_get(rspi->ctlr);
-
spi_unregister_controller(rspi->ctlr);
rspi_release_dma(rspi->ctlr);
pm_runtime_disable(&pdev->dev);
-
- spi_controller_put(rspi->ctlr);
}
static const struct spi_ops rspi_ops = {
@@ -1294,7 +1290,7 @@ static int rspi_probe(struct platform_device *pdev)
const struct spi_ops *ops;
unsigned long clksrc;
- ctlr = spi_alloc_host(&pdev->dev, sizeof(struct rspi_data));
+ ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(struct rspi_data));
if (ctlr == NULL)
return -ENOMEM;
@@ -1302,7 +1298,7 @@ static int rspi_probe(struct platform_device *pdev)
if (ops) {
ret = rspi_parse_dt(&pdev->dev, ctlr);
if (ret)
- goto error1;
+ return ret;
} else {
ops = (struct spi_ops *)pdev->id_entry->driver_data;
ctlr->num_chipselect = 2; /* default */
@@ -1314,16 +1310,13 @@ static int rspi_probe(struct platform_device *pdev)
rspi->ctlr = ctlr;
rspi->addr = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
- if (IS_ERR(rspi->addr)) {
- ret = PTR_ERR(rspi->addr);
- goto error1;
- }
+ if (IS_ERR(rspi->addr))
+ return PTR_ERR(rspi->addr);
rspi->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(rspi->clk)) {
dev_err(&pdev->dev, "cannot get clock\n");
- ret = PTR_ERR(rspi->clk);
- goto error1;
+ return PTR_ERR(rspi->clk);
}
rspi->pdev = pdev;
@@ -1396,8 +1389,6 @@ static int rspi_probe(struct platform_device *pdev)
rspi_release_dma(ctlr);
error2:
pm_runtime_disable(&pdev->dev);
-error1:
- spi_controller_put(ctlr);
return ret;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 06/20] spi: sh-hspi: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (4 preceding siblings ...)
2026-05-05 7:28 ` [PATCH 05/20] spi: rspi: " Johan Hovold
@ 2026-05-05 7:28 ` Johan Hovold
2026-05-05 7:28 ` [PATCH 07/20] spi: sh-msiof: " Johan Hovold
` (14 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:28 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-sh-hspi.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/spi/spi-sh-hspi.c b/drivers/spi/spi-sh-hspi.c
index 1e3ca718ca73..f840467cfdb2 100644
--- a/drivers/spi/spi-sh-hspi.c
+++ b/drivers/spi/spi-sh-hspi.c
@@ -224,15 +224,14 @@ static int hspi_probe(struct platform_device *pdev)
return -EINVAL;
}
- ctlr = spi_alloc_host(&pdev->dev, sizeof(*hspi));
+ ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*hspi));
if (!ctlr)
return -ENOMEM;
clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(clk)) {
dev_err(&pdev->dev, "couldn't get clock\n");
- ret = -EINVAL;
- goto error0;
+ return PTR_ERR(clk);
}
hspi = spi_controller_get_devdata(ctlr);
@@ -269,8 +268,6 @@ static int hspi_probe(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
error1:
clk_put(clk);
- error0:
- spi_controller_put(ctlr);
return ret;
}
@@ -279,15 +276,11 @@ static void hspi_remove(struct platform_device *pdev)
{
struct hspi_priv *hspi = platform_get_drvdata(pdev);
- spi_controller_get(hspi->ctlr);
-
spi_unregister_controller(hspi->ctlr);
pm_runtime_disable(&pdev->dev);
clk_put(hspi->clk);
-
- spi_controller_put(hspi->ctlr);
}
static const struct of_device_id hspi_of_match[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 07/20] spi: sh-msiof: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (5 preceding siblings ...)
2026-05-05 7:28 ` [PATCH 06/20] spi: sh-hspi: " Johan Hovold
@ 2026-05-05 7:28 ` Johan Hovold
2026-05-05 7:28 ` [PATCH 08/20] spi: sifive: " Johan Hovold
` (13 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:28 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-sh-msiof.c | 28 +++++++++-------------------
1 file changed, 9 insertions(+), 19 deletions(-)
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index f114b6313f4f..070e16bc764f 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -1215,9 +1215,9 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
info->dtdl = 200;
if (info->mode == MSIOF_SPI_TARGET)
- ctlr = spi_alloc_target(dev, sizeof(struct sh_msiof_spi_priv));
+ ctlr = devm_spi_alloc_target(dev, sizeof(struct sh_msiof_spi_priv));
else
- ctlr = spi_alloc_host(dev, sizeof(struct sh_msiof_spi_priv));
+ ctlr = devm_spi_alloc_host(dev, sizeof(struct sh_msiof_spi_priv));
if (ctlr == NULL)
return -ENOMEM;
@@ -1234,26 +1234,21 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
p->clk = devm_clk_get(dev, NULL);
if (IS_ERR(p->clk)) {
dev_err(dev, "cannot get clock\n");
- ret = PTR_ERR(p->clk);
- goto err1;
+ return PTR_ERR(p->clk);
}
i = platform_get_irq(pdev, 0);
- if (i < 0) {
- ret = i;
- goto err1;
- }
+ if (i < 0)
+ return i;
p->mapbase = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(p->mapbase)) {
- ret = PTR_ERR(p->mapbase);
- goto err1;
- }
+ if (IS_ERR(p->mapbase))
+ return PTR_ERR(p->mapbase);
ret = devm_request_irq(dev, i, sh_msiof_spi_irq, 0, dev_name(dev), p);
if (ret) {
dev_err(dev, "unable to request irq\n");
- goto err1;
+ return ret;
}
p->pdev = pdev;
@@ -1300,8 +1295,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
err2:
sh_msiof_release_dma(p);
pm_runtime_disable(dev);
- err1:
- spi_controller_put(ctlr);
+
return ret;
}
@@ -1309,14 +1303,10 @@ static void sh_msiof_spi_remove(struct platform_device *pdev)
{
struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
- spi_controller_get(p->ctlr);
-
spi_unregister_controller(p->ctlr);
sh_msiof_release_dma(p);
pm_runtime_disable(&pdev->dev);
-
- spi_controller_put(p->ctlr);
}
static const struct platform_device_id spi_driver_ids[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 08/20] spi: sifive: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (6 preceding siblings ...)
2026-05-05 7:28 ` [PATCH 07/20] spi: sh-msiof: " Johan Hovold
@ 2026-05-05 7:28 ` Johan Hovold
2026-05-05 7:28 ` [PATCH 09/20] spi: slave-mt27xx: " Johan Hovold
` (12 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:28 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-sifive.c | 39 +++++++++++----------------------------
1 file changed, 11 insertions(+), 28 deletions(-)
diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c
index 74a3e32fd2b5..cee4d92e46f4 100644
--- a/drivers/spi/spi-sifive.c
+++ b/drivers/spi/spi-sifive.c
@@ -296,7 +296,7 @@ static int sifive_spi_probe(struct platform_device *pdev)
u32 cs_bits, max_bits_per_word;
struct spi_controller *host;
- host = spi_alloc_host(&pdev->dev, sizeof(struct sifive_spi));
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(struct sifive_spi));
if (!host) {
dev_err(&pdev->dev, "out of memory\n");
return -ENOMEM;
@@ -307,24 +307,19 @@ static int sifive_spi_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, host);
spi->regs = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(spi->regs)) {
- ret = PTR_ERR(spi->regs);
- goto put_host;
- }
+ if (IS_ERR(spi->regs))
+ return PTR_ERR(spi->regs);
/* Spin up the bus clock before hitting registers */
spi->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(spi->clk)) {
dev_err(&pdev->dev, "Unable to find bus clock\n");
- ret = PTR_ERR(spi->clk);
- goto put_host;
+ return PTR_ERR(spi->clk);
}
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- ret = irq;
- goto put_host;
- }
+ if (irq < 0)
+ return irq;
/* Optional parameters */
ret =
@@ -339,8 +334,7 @@ static int sifive_spi_probe(struct platform_device *pdev)
if (!ret && max_bits_per_word < 8) {
dev_err(&pdev->dev, "Only 8bit SPI words supported by the driver\n");
- ret = -EINVAL;
- goto put_host;
+ return -EINVAL;
}
/* probe the number of CS lines */
@@ -350,15 +344,13 @@ static int sifive_spi_probe(struct platform_device *pdev)
sifive_spi_write(spi, SIFIVE_SPI_REG_CSDEF, spi->cs_inactive);
if (!cs_bits) {
dev_err(&pdev->dev, "Could not auto probe CS lines\n");
- ret = -EINVAL;
- goto put_host;
+ return -EINVAL;
}
num_cs = ilog2(cs_bits) + 1;
if (num_cs > SIFIVE_SPI_MAX_CS) {
dev_err(&pdev->dev, "Invalid number of spi targets\n");
- ret = -EINVAL;
- goto put_host;
+ return -EINVAL;
}
/* Define our host */
@@ -386,7 +378,7 @@ static int sifive_spi_probe(struct platform_device *pdev)
dev_name(&pdev->dev), spi);
if (ret) {
dev_err(&pdev->dev, "Unable to bind to interrupt\n");
- goto put_host;
+ return ret;
}
dev_info(&pdev->dev, "mapped; irq=%d, cs=%d\n",
@@ -395,15 +387,10 @@ static int sifive_spi_probe(struct platform_device *pdev)
ret = spi_register_controller(host);
if (ret < 0) {
dev_err(&pdev->dev, "spi_register_host failed\n");
- goto put_host;
+ return ret;
}
return 0;
-
-put_host:
- spi_controller_put(host);
-
- return ret;
}
static void sifive_spi_remove(struct platform_device *pdev)
@@ -411,14 +398,10 @@ static void sifive_spi_remove(struct platform_device *pdev)
struct spi_controller *host = platform_get_drvdata(pdev);
struct sifive_spi *spi = spi_controller_get_devdata(host);
- spi_controller_get(host);
-
spi_unregister_controller(host);
/* Disable all the interrupts just in case */
sifive_spi_write(spi, SIFIVE_SPI_REG_IE, 0);
-
- spi_controller_put(host);
}
static int sifive_spi_suspend(struct device *dev)
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 09/20] spi: slave-mt27xx: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (7 preceding siblings ...)
2026-05-05 7:28 ` [PATCH 08/20] spi: sifive: " Johan Hovold
@ 2026-05-05 7:28 ` Johan Hovold
2026-05-05 7:28 ` [PATCH 10/20] spi: sprd: " Johan Hovold
` (11 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:28 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-slave-mt27xx.c | 33 ++++++++++-----------------------
1 file changed, 10 insertions(+), 23 deletions(-)
diff --git a/drivers/spi/spi-slave-mt27xx.c b/drivers/spi/spi-slave-mt27xx.c
index 7aedeaa5889d..e60ab4c18bed 100644
--- a/drivers/spi/spi-slave-mt27xx.c
+++ b/drivers/spi/spi-slave-mt27xx.c
@@ -388,11 +388,9 @@ static int mtk_spi_slave_probe(struct platform_device *pdev)
int irq, ret;
const struct of_device_id *of_id;
- ctlr = spi_alloc_target(&pdev->dev, sizeof(*mdata));
- if (!ctlr) {
- dev_err(&pdev->dev, "failed to alloc spi target\n");
+ ctlr = devm_spi_alloc_target(&pdev->dev, sizeof(*mdata));
+ if (!ctlr)
return -ENOMEM;
- }
ctlr->auto_runtime_pm = true;
ctlr->mode_bits = SPI_CPOL | SPI_CPHA;
@@ -406,8 +404,7 @@ static int mtk_spi_slave_probe(struct platform_device *pdev)
of_id = of_match_node(mtk_spi_slave_of_match, pdev->dev.of_node);
if (!of_id) {
dev_err(&pdev->dev, "failed to probe of_node\n");
- ret = -EINVAL;
- goto err_put_ctlr;
+ return -EINVAL;
}
mdata = spi_controller_get_devdata(ctlr);
mdata->dev_comp = of_id->data;
@@ -420,35 +417,31 @@ static int mtk_spi_slave_probe(struct platform_device *pdev)
init_completion(&mdata->xfer_done);
mdata->dev = &pdev->dev;
mdata->base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(mdata->base)) {
- ret = PTR_ERR(mdata->base);
- goto err_put_ctlr;
- }
+ if (IS_ERR(mdata->base))
+ return PTR_ERR(mdata->base);
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- ret = irq;
- goto err_put_ctlr;
- }
+ if (irq < 0)
+ return irq;
ret = devm_request_irq(&pdev->dev, irq, mtk_spi_slave_interrupt,
IRQF_TRIGGER_NONE, dev_name(&pdev->dev), ctlr);
if (ret) {
dev_err(&pdev->dev, "failed to register irq (%d)\n", ret);
- goto err_put_ctlr;
+ return ret;
}
mdata->spi_clk = devm_clk_get(&pdev->dev, "spi");
if (IS_ERR(mdata->spi_clk)) {
ret = PTR_ERR(mdata->spi_clk);
dev_err(&pdev->dev, "failed to get spi-clk: %d\n", ret);
- goto err_put_ctlr;
+ return ret;
}
ret = clk_prepare_enable(mdata->spi_clk);
if (ret < 0) {
dev_err(&pdev->dev, "failed to enable spi_clk (%d)\n", ret);
- goto err_put_ctlr;
+ return ret;
}
pm_runtime_enable(&pdev->dev);
@@ -465,8 +458,6 @@ static int mtk_spi_slave_probe(struct platform_device *pdev)
err_disable_runtime_pm:
pm_runtime_disable(&pdev->dev);
-err_put_ctlr:
- spi_controller_put(ctlr);
return ret;
}
@@ -475,13 +466,9 @@ static void mtk_spi_slave_remove(struct platform_device *pdev)
{
struct spi_controller *ctlr = platform_get_drvdata(pdev);
- spi_controller_get(ctlr);
-
spi_unregister_controller(ctlr);
pm_runtime_disable(&pdev->dev);
-
- spi_controller_put(ctlr);
}
#ifdef CONFIG_PM_SLEEP
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 10/20] spi: sprd: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (8 preceding siblings ...)
2026-05-05 7:28 ` [PATCH 09/20] spi: slave-mt27xx: " Johan Hovold
@ 2026-05-05 7:28 ` Johan Hovold
2026-05-05 7:29 ` [PATCH 11/20] spi: st-ssc4: " Johan Hovold
` (10 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:28 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-sprd.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/drivers/spi/spi-sprd.c b/drivers/spi/spi-sprd.c
index fd3fd0ce122c..d27b51698dbd 100644
--- a/drivers/spi/spi-sprd.c
+++ b/drivers/spi/spi-sprd.c
@@ -923,16 +923,14 @@ static int sprd_spi_probe(struct platform_device *pdev)
int ret;
pdev->id = of_alias_get_id(pdev->dev.of_node, "spi");
- sctlr = spi_alloc_host(&pdev->dev, sizeof(*ss));
+ sctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*ss));
if (!sctlr)
return -ENOMEM;
ss = spi_controller_get_devdata(sctlr);
ss->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
- if (IS_ERR(ss->base)) {
- ret = PTR_ERR(ss->base);
- goto free_controller;
- }
+ if (IS_ERR(ss->base))
+ return PTR_ERR(ss->base);
ss->phy_base = res->start;
ss->dev = &pdev->dev;
@@ -949,15 +947,15 @@ static int sprd_spi_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, sctlr);
ret = sprd_spi_clk_init(pdev, ss);
if (ret)
- goto free_controller;
+ return ret;
ret = sprd_spi_irq_init(pdev, ss);
if (ret)
- goto free_controller;
+ return ret;
ret = sprd_spi_dma_init(pdev, ss);
if (ret)
- goto free_controller;
+ return ret;
ret = clk_prepare_enable(ss->clk);
if (ret)
@@ -992,8 +990,6 @@ static int sprd_spi_probe(struct platform_device *pdev)
clk_disable_unprepare(ss->clk);
release_dma:
sprd_spi_dma_release(ss);
-free_controller:
- spi_controller_put(sctlr);
return ret;
}
@@ -1008,8 +1004,6 @@ static void sprd_spi_remove(struct platform_device *pdev)
if (ret < 0)
dev_err(ss->dev, "failed to resume SPI controller\n");
- spi_controller_get(sctlr);
-
spi_unregister_controller(sctlr);
if (ret >= 0) {
@@ -1019,8 +1013,6 @@ static void sprd_spi_remove(struct platform_device *pdev)
}
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
-
- spi_controller_put(sctlr);
}
static int __maybe_unused sprd_spi_runtime_suspend(struct device *dev)
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 11/20] spi: st-ssc4: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (9 preceding siblings ...)
2026-05-05 7:28 ` [PATCH 10/20] spi: sprd: " Johan Hovold
@ 2026-05-05 7:29 ` Johan Hovold
2026-05-05 7:29 ` [PATCH 12/20] spi: sun4i: " Johan Hovold
` (9 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:29 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-st-ssc4.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/spi/spi-st-ssc4.c b/drivers/spi/spi-st-ssc4.c
index 9c8099fe6e19..df61094fc444 100644
--- a/drivers/spi/spi-st-ssc4.c
+++ b/drivers/spi/spi-st-ssc4.c
@@ -279,7 +279,7 @@ static int spi_st_probe(struct platform_device *pdev)
int irq, ret = 0;
u32 var;
- host = spi_alloc_host(&pdev->dev, sizeof(*spi_st));
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(*spi_st));
if (!host)
return -ENOMEM;
@@ -296,13 +296,12 @@ static int spi_st_probe(struct platform_device *pdev)
spi_st->clk = devm_clk_get(&pdev->dev, "ssc");
if (IS_ERR(spi_st->clk)) {
dev_err(&pdev->dev, "Unable to request clock\n");
- ret = PTR_ERR(spi_st->clk);
- goto put_host;
+ return PTR_ERR(spi_st->clk);
}
ret = clk_prepare_enable(spi_st->clk);
if (ret)
- goto put_host;
+ return ret;
init_completion(&spi_st->done);
@@ -361,8 +360,7 @@ static int spi_st_probe(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
clk_disable:
clk_disable_unprepare(spi_st->clk);
-put_host:
- spi_controller_put(host);
+
return ret;
}
@@ -371,16 +369,12 @@ static void spi_st_remove(struct platform_device *pdev)
struct spi_controller *host = platform_get_drvdata(pdev);
struct spi_st *spi_st = spi_controller_get_devdata(host);
- spi_controller_get(host);
-
spi_unregister_controller(host);
pm_runtime_disable(&pdev->dev);
clk_disable_unprepare(spi_st->clk);
- spi_controller_put(host);
-
pinctrl_pm_select_sleep_state(&pdev->dev);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 12/20] spi: sun4i: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (10 preceding siblings ...)
2026-05-05 7:29 ` [PATCH 11/20] spi: st-ssc4: " Johan Hovold
@ 2026-05-05 7:29 ` Johan Hovold
2026-05-05 7:29 ` [PATCH 13/20] spi: sun6i: " Johan Hovold
` (8 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:29 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-sun4i.c | 35 +++++++++++------------------------
1 file changed, 11 insertions(+), 24 deletions(-)
diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c
index b7fbb5270edb..d5c16392cd4d 100644
--- a/drivers/spi/spi-sun4i.c
+++ b/drivers/spi/spi-sun4i.c
@@ -434,32 +434,26 @@ static int sun4i_spi_probe(struct platform_device *pdev)
struct sun4i_spi *sspi;
int ret = 0, irq;
- host = spi_alloc_host(&pdev->dev, sizeof(struct sun4i_spi));
- if (!host) {
- dev_err(&pdev->dev, "Unable to allocate SPI Host\n");
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(struct sun4i_spi));
+ if (!host)
return -ENOMEM;
- }
platform_set_drvdata(pdev, host);
sspi = spi_controller_get_devdata(host);
sspi->base_addr = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(sspi->base_addr)) {
- ret = PTR_ERR(sspi->base_addr);
- goto err_free_host;
- }
+ if (IS_ERR(sspi->base_addr))
+ return PTR_ERR(sspi->base_addr);
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- ret = -ENXIO;
- goto err_free_host;
- }
+ if (irq < 0)
+ return -ENXIO;
ret = devm_request_irq(&pdev->dev, irq, sun4i_spi_handler,
0, "sun4i-spi", sspi);
if (ret) {
dev_err(&pdev->dev, "Cannot request IRQ\n");
- goto err_free_host;
+ return ret;
}
sspi->host = host;
@@ -477,15 +471,13 @@ static int sun4i_spi_probe(struct platform_device *pdev)
sspi->hclk = devm_clk_get(&pdev->dev, "ahb");
if (IS_ERR(sspi->hclk)) {
dev_err(&pdev->dev, "Unable to acquire AHB clock\n");
- ret = PTR_ERR(sspi->hclk);
- goto err_free_host;
+ return PTR_ERR(sspi->hclk);
}
sspi->mclk = devm_clk_get(&pdev->dev, "mod");
if (IS_ERR(sspi->mclk)) {
dev_err(&pdev->dev, "Unable to acquire module clock\n");
- ret = PTR_ERR(sspi->mclk);
- goto err_free_host;
+ return PTR_ERR(sspi->mclk);
}
init_completion(&sspi->done);
@@ -497,7 +489,7 @@ static int sun4i_spi_probe(struct platform_device *pdev)
ret = sun4i_spi_runtime_resume(&pdev->dev);
if (ret) {
dev_err(&pdev->dev, "Couldn't resume the device\n");
- goto err_free_host;
+ return ret;
}
pm_runtime_set_active(&pdev->dev);
@@ -515,8 +507,7 @@ static int sun4i_spi_probe(struct platform_device *pdev)
err_pm_disable:
pm_runtime_disable(&pdev->dev);
sun4i_spi_runtime_suspend(&pdev->dev);
-err_free_host:
- spi_controller_put(host);
+
return ret;
}
@@ -524,13 +515,9 @@ static void sun4i_spi_remove(struct platform_device *pdev)
{
struct spi_controller *host = platform_get_drvdata(pdev);
- spi_controller_get(host);
-
spi_unregister_controller(host);
pm_runtime_force_suspend(&pdev->dev);
-
- spi_controller_put(host);
}
static const struct of_device_id sun4i_spi_match[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 13/20] spi: sun6i: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (11 preceding siblings ...)
2026-05-05 7:29 ` [PATCH 12/20] spi: sun4i: " Johan Hovold
@ 2026-05-05 7:29 ` Johan Hovold
2026-05-05 7:29 ` [PATCH 14/20] spi: syncuacer: " Johan Hovold
` (7 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:29 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-sun6i.c | 38 ++++++++++++--------------------------
1 file changed, 12 insertions(+), 26 deletions(-)
diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
index 5ac73d324d06..4631e9c7ca1d 100644
--- a/drivers/spi/spi-sun6i.c
+++ b/drivers/spi/spi-sun6i.c
@@ -633,7 +633,7 @@ static int sun6i_spi_probe(struct platform_device *pdev)
struct resource *mem;
int ret = 0, irq;
- host = spi_alloc_host(&pdev->dev, sizeof(struct sun6i_spi));
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(struct sun6i_spi));
if (!host) {
dev_err(&pdev->dev, "Unable to allocate SPI Host\n");
return -ENOMEM;
@@ -643,22 +643,18 @@ static int sun6i_spi_probe(struct platform_device *pdev)
sspi = spi_controller_get_devdata(host);
sspi->base_addr = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
- if (IS_ERR(sspi->base_addr)) {
- ret = PTR_ERR(sspi->base_addr);
- goto err_free_host;
- }
+ if (IS_ERR(sspi->base_addr))
+ return PTR_ERR(sspi->base_addr);
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- ret = -ENXIO;
- goto err_free_host;
- }
+ if (irq < 0)
+ return -ENXIO;
ret = devm_request_irq(&pdev->dev, irq, sun6i_spi_handler,
0, "sun6i-spi", sspi);
if (ret) {
dev_err(&pdev->dev, "Cannot request IRQ\n");
- goto err_free_host;
+ return ret;
}
sspi->host = host;
@@ -679,15 +675,13 @@ static int sun6i_spi_probe(struct platform_device *pdev)
sspi->hclk = devm_clk_get(&pdev->dev, "ahb");
if (IS_ERR(sspi->hclk)) {
dev_err(&pdev->dev, "Unable to acquire AHB clock\n");
- ret = PTR_ERR(sspi->hclk);
- goto err_free_host;
+ return PTR_ERR(sspi->hclk);
}
sspi->mclk = devm_clk_get(&pdev->dev, "mod");
if (IS_ERR(sspi->mclk)) {
dev_err(&pdev->dev, "Unable to acquire module clock\n");
- ret = PTR_ERR(sspi->mclk);
- goto err_free_host;
+ return PTR_ERR(sspi->mclk);
}
init_completion(&sspi->done);
@@ -696,17 +690,14 @@ static int sun6i_spi_probe(struct platform_device *pdev)
sspi->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(sspi->rstc)) {
dev_err(&pdev->dev, "Couldn't get reset controller\n");
- ret = PTR_ERR(sspi->rstc);
- goto err_free_host;
+ return PTR_ERR(sspi->rstc);
}
host->dma_tx = dma_request_chan(&pdev->dev, "tx");
if (IS_ERR(host->dma_tx)) {
/* Check tx to see if we need defer probing driver */
- if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER) {
- ret = -EPROBE_DEFER;
- goto err_free_host;
- }
+ if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
dev_warn(&pdev->dev, "Failed to request TX DMA channel\n");
host->dma_tx = NULL;
}
@@ -759,8 +750,7 @@ static int sun6i_spi_probe(struct platform_device *pdev)
err_free_dma_tx:
if (host->dma_tx)
dma_release_channel(host->dma_tx);
-err_free_host:
- spi_controller_put(host);
+
return ret;
}
@@ -768,8 +758,6 @@ static void sun6i_spi_remove(struct platform_device *pdev)
{
struct spi_controller *host = platform_get_drvdata(pdev);
- spi_controller_get(host);
-
spi_unregister_controller(host);
pm_runtime_force_suspend(&pdev->dev);
@@ -778,8 +766,6 @@ static void sun6i_spi_remove(struct platform_device *pdev)
dma_release_channel(host->dma_tx);
if (host->dma_rx)
dma_release_channel(host->dma_rx);
-
- spi_controller_put(host);
}
static const struct sun6i_spi_cfg sun6i_a31_spi_cfg = {
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 14/20] spi: syncuacer: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (12 preceding siblings ...)
2026-05-05 7:29 ` [PATCH 13/20] spi: sun6i: " Johan Hovold
@ 2026-05-05 7:29 ` Johan Hovold
2026-05-05 7:29 ` [PATCH 15/20] spi: tegra114: " Johan Hovold
` (6 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:29 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-synquacer.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/drivers/spi/spi-synquacer.c b/drivers/spi/spi-synquacer.c
index 290c439897c4..c14225e39fd1 100644
--- a/drivers/spi/spi-synquacer.c
+++ b/drivers/spi/spi-synquacer.c
@@ -605,7 +605,7 @@ static int synquacer_spi_probe(struct platform_device *pdev)
int ret;
int rx_irq, tx_irq;
- host = spi_alloc_host(&pdev->dev, sizeof(*sspi));
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(*sspi));
if (!host)
return -ENOMEM;
@@ -617,10 +617,8 @@ static int synquacer_spi_probe(struct platform_device *pdev)
init_completion(&sspi->transfer_done);
sspi->regs = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(sspi->regs)) {
- ret = PTR_ERR(sspi->regs);
- goto put_spi;
- }
+ if (IS_ERR(sspi->regs))
+ return PTR_ERR(sspi->regs);
sspi->clk_src_type = SYNQUACER_HSSPI_CLOCK_SRC_IHCLK; /* Default */
device_property_read_u32(&pdev->dev, "socionext,ihclk-rate",
@@ -637,21 +635,19 @@ static int synquacer_spi_probe(struct platform_device *pdev)
sspi->clk = devm_clk_get(sspi->dev, "iPCLK");
} else {
dev_err(&pdev->dev, "specified wrong clock source\n");
- ret = -EINVAL;
- goto put_spi;
+ return -EINVAL;
}
if (IS_ERR(sspi->clk)) {
- ret = dev_err_probe(&pdev->dev, PTR_ERR(sspi->clk),
- "clock not found\n");
- goto put_spi;
+ return dev_err_probe(&pdev->dev, PTR_ERR(sspi->clk),
+ "clock not found\n");
}
ret = clk_prepare_enable(sspi->clk);
if (ret) {
dev_err(&pdev->dev, "failed to enable clock (%d)\n",
ret);
- goto put_spi;
+ return ret;
}
host->max_speed_hz = clk_get_rate(sspi->clk);
@@ -726,8 +722,6 @@ static int synquacer_spi_probe(struct platform_device *pdev)
pm_runtime_disable(sspi->dev);
disable_clk:
clk_disable_unprepare(sspi->clk);
-put_spi:
- spi_controller_put(host);
return ret;
}
@@ -737,15 +731,11 @@ static void synquacer_spi_remove(struct platform_device *pdev)
struct spi_controller *host = platform_get_drvdata(pdev);
struct synquacer_spi *sspi = spi_controller_get_devdata(host);
- spi_controller_get(host);
-
spi_unregister_controller(host);
pm_runtime_disable(sspi->dev);
clk_disable_unprepare(sspi->clk);
-
- spi_controller_put(host);
}
static int __maybe_unused synquacer_spi_suspend(struct device *dev)
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 15/20] spi: tegra114: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (13 preceding siblings ...)
2026-05-05 7:29 ` [PATCH 14/20] spi: syncuacer: " Johan Hovold
@ 2026-05-05 7:29 ` Johan Hovold
2026-05-05 7:29 ` [PATCH 16/20] spi: tegra20-sflash: " Johan Hovold
` (5 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:29 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-tegra114.c | 34 ++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)
diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
index b8b0ebe0fe93..aa44ffd09e61 100644
--- a/drivers/spi/spi-tegra114.c
+++ b/drivers/spi/spi-tegra114.c
@@ -1302,7 +1302,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
int ret, spi_irq;
int bus_num;
- host = spi_alloc_host(&pdev->dev, sizeof(*tspi));
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(*tspi));
if (!host) {
dev_err(&pdev->dev, "host allocation failed\n");
return -ENOMEM;
@@ -1336,36 +1336,31 @@ static int tegra_spi_probe(struct platform_device *pdev)
tspi->soc_data = of_device_get_match_data(&pdev->dev);
if (!tspi->soc_data) {
dev_err(&pdev->dev, "unsupported tegra\n");
- ret = -ENODEV;
- goto exit_free_host;
+ return -ENODEV;
}
tspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
- if (IS_ERR(tspi->base)) {
- ret = PTR_ERR(tspi->base);
- goto exit_free_host;
- }
+ if (IS_ERR(tspi->base))
+ return PTR_ERR(tspi->base);
+
tspi->phys = r->start;
spi_irq = platform_get_irq(pdev, 0);
- if (spi_irq < 0) {
- ret = spi_irq;
- goto exit_free_host;
- }
+ if (spi_irq < 0)
+ return spi_irq;
+
tspi->irq = spi_irq;
tspi->clk = devm_clk_get(&pdev->dev, "spi");
if (IS_ERR(tspi->clk)) {
dev_err(&pdev->dev, "can not get clock\n");
- ret = PTR_ERR(tspi->clk);
- goto exit_free_host;
+ return PTR_ERR(tspi->clk);
}
tspi->rst = devm_reset_control_get_exclusive(&pdev->dev, "spi");
if (IS_ERR(tspi->rst)) {
dev_err(&pdev->dev, "can not get reset\n");
- ret = PTR_ERR(tspi->rst);
- goto exit_free_host;
+ return PTR_ERR(tspi->rst);
}
tspi->max_buf_size = SPI_FIFO_DEPTH << 2;
@@ -1373,7 +1368,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
ret = tegra_spi_init_dma_param(tspi, true);
if (ret < 0)
- goto exit_free_host;
+ return ret;
ret = tegra_spi_init_dma_param(tspi, false);
if (ret < 0)
goto exit_rx_dma_free;
@@ -1431,8 +1426,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
tegra_spi_deinit_dma_param(tspi, false);
exit_rx_dma_free:
tegra_spi_deinit_dma_param(tspi, true);
-exit_free_host:
- spi_controller_put(host);
+
return ret;
}
@@ -1441,8 +1435,6 @@ static void tegra_spi_remove(struct platform_device *pdev)
struct spi_controller *host = platform_get_drvdata(pdev);
struct tegra_spi_data *tspi = spi_controller_get_devdata(host);
- spi_controller_get(host);
-
spi_unregister_controller(host);
free_irq(tspi->irq, tspi);
@@ -1456,8 +1448,6 @@ static void tegra_spi_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
if (!pm_runtime_status_suspended(&pdev->dev))
tegra_spi_runtime_suspend(&pdev->dev);
-
- spi_controller_put(host);
}
#ifdef CONFIG_PM_SLEEP
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 16/20] spi: tegra20-sflash: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (14 preceding siblings ...)
2026-05-05 7:29 ` [PATCH 15/20] spi: tegra114: " Johan Hovold
@ 2026-05-05 7:29 ` Johan Hovold
2026-05-05 7:29 ` [PATCH 17/20] spi: ti-qspi: " Johan Hovold
` (4 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:29 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-tegra20-sflash.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c
index 9256729f2d49..2caa33f0a52c 100644
--- a/drivers/spi/spi-tegra20-sflash.c
+++ b/drivers/spi/spi-tegra20-sflash.c
@@ -427,11 +427,9 @@ static int tegra_sflash_probe(struct platform_device *pdev)
return -ENODEV;
}
- host = spi_alloc_host(&pdev->dev, sizeof(*tsd));
- if (!host) {
- dev_err(&pdev->dev, "host allocation failed\n");
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(*tsd));
+ if (!host)
return -ENOMEM;
- }
/* the spi->mode bits understood by this driver: */
host->mode_bits = SPI_CPOL | SPI_CPHA;
@@ -450,14 +448,13 @@ static int tegra_sflash_probe(struct platform_device *pdev)
host->max_speed_hz = 25000000; /* 25MHz */
tsd->base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(tsd->base)) {
- ret = PTR_ERR(tsd->base);
- goto exit_free_host;
- }
+ if (IS_ERR(tsd->base))
+ return PTR_ERR(tsd->base);
ret = platform_get_irq(pdev, 0);
if (ret < 0)
- goto exit_free_host;
+ return ret;
+
tsd->irq = ret;
ret = request_irq(tsd->irq, tegra_sflash_isr, 0,
@@ -465,7 +462,7 @@ static int tegra_sflash_probe(struct platform_device *pdev)
if (ret < 0) {
dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n",
tsd->irq);
- goto exit_free_host;
+ return ret;
}
tsd->clk = devm_clk_get(&pdev->dev, NULL);
@@ -518,8 +515,7 @@ static int tegra_sflash_probe(struct platform_device *pdev)
tegra_sflash_runtime_suspend(&pdev->dev);
exit_free_irq:
free_irq(tsd->irq, tsd);
-exit_free_host:
- spi_controller_put(host);
+
return ret;
}
@@ -528,8 +524,6 @@ static void tegra_sflash_remove(struct platform_device *pdev)
struct spi_controller *host = platform_get_drvdata(pdev);
struct tegra_sflash_data *tsd = spi_controller_get_devdata(host);
- spi_controller_get(host);
-
spi_unregister_controller(host);
free_irq(tsd->irq, tsd);
@@ -537,8 +531,6 @@ static void tegra_sflash_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
if (!pm_runtime_status_suspended(&pdev->dev))
tegra_sflash_runtime_suspend(&pdev->dev);
-
- spi_controller_put(host);
}
#ifdef CONFIG_PM_SLEEP
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 17/20] spi: ti-qspi: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (15 preceding siblings ...)
2026-05-05 7:29 ` [PATCH 16/20] spi: tegra20-sflash: " Johan Hovold
@ 2026-05-05 7:29 ` Johan Hovold
2026-05-05 7:29 ` [PATCH 18/20] spi: ti-qspi: cleanup registration error path Johan Hovold
` (3 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:29 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-ti-qspi.c | 30 +++++++++---------------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
index 1fbd710d616f..2a8548810f84 100644
--- a/drivers/spi/spi-ti-qspi.c
+++ b/drivers/spi/spi-ti-qspi.c
@@ -765,7 +765,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
int ret = 0, num_cs, irq;
dma_cap_mask_t mask;
- host = spi_alloc_host(&pdev->dev, sizeof(*qspi));
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(*qspi));
if (!host)
return -ENOMEM;
@@ -793,8 +793,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (r == NULL) {
dev_err(&pdev->dev, "missing platform data\n");
- ret = -ENODEV;
- goto free_host;
+ return -ENODEV;
}
}
@@ -812,28 +811,22 @@ static int ti_qspi_probe(struct platform_device *pdev)
qspi->mmap_size = resource_size(res_mmap);
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- ret = irq;
- goto free_host;
- }
+ if (irq < 0)
+ return irq;
mutex_init(&qspi->list_lock);
qspi->base = devm_ioremap_resource(&pdev->dev, r);
- if (IS_ERR(qspi->base)) {
- ret = PTR_ERR(qspi->base);
- goto free_host;
- }
+ if (IS_ERR(qspi->base))
+ return PTR_ERR(qspi->base);
if (of_property_present(np, "syscon-chipselects")) {
qspi->ctrl_base =
syscon_regmap_lookup_by_phandle_args(np, "syscon-chipselects",
1, &qspi->ctrl_reg);
- if (IS_ERR(qspi->ctrl_base)) {
- ret = PTR_ERR(qspi->ctrl_base);
- goto free_host;
- }
+ if (IS_ERR(qspi->ctrl_base))
+ return PTR_ERR(qspi->ctrl_base);
}
qspi->fclk = devm_clk_get(&pdev->dev, "fck");
@@ -895,8 +888,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
ti_qspi_dma_cleanup(qspi);
pm_runtime_disable(&pdev->dev);
-free_host:
- spi_controller_put(host);
+
return ret;
}
@@ -904,16 +896,12 @@ static void ti_qspi_remove(struct platform_device *pdev)
{
struct ti_qspi *qspi = platform_get_drvdata(pdev);
- spi_controller_get(qspi->host);
-
spi_unregister_controller(qspi->host);
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
ti_qspi_dma_cleanup(qspi);
-
- spi_controller_put(qspi->host);
}
static const struct dev_pm_ops ti_qspi_pm_ops = {
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 18/20] spi: ti-qspi: cleanup registration error path
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (16 preceding siblings ...)
2026-05-05 7:29 ` [PATCH 17/20] spi: ti-qspi: " Johan Hovold
@ 2026-05-05 7:29 ` Johan Hovold
2026-05-05 7:29 ` [PATCH 19/20] spi: uniphier: switch to managed controller allocation Johan Hovold
` (2 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:29 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
Add a proper error path for when registration fails so that the probe
tests for errors consistently.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/spi/spi-ti-qspi.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
index 2a8548810f84..6b407c7b5d33 100644
--- a/drivers/spi/spi-ti-qspi.c
+++ b/drivers/spi/spi-ti-qspi.c
@@ -882,9 +882,12 @@ static int ti_qspi_probe(struct platform_device *pdev)
qspi->current_cs = -1;
ret = spi_register_controller(host);
- if (!ret)
- return 0;
+ if (ret)
+ goto err_free_dma;
+
+ return 0;
+err_free_dma:
ti_qspi_dma_cleanup(qspi);
pm_runtime_disable(&pdev->dev);
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 19/20] spi: uniphier: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (17 preceding siblings ...)
2026-05-05 7:29 ` [PATCH 18/20] spi: ti-qspi: cleanup registration error path Johan Hovold
@ 2026-05-05 7:29 ` Johan Hovold
2026-05-05 7:29 ` [PATCH 20/20] spi: zync-qspi: " Johan Hovold
2026-05-11 0:56 ` [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Mark Brown
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:29 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-uniphier.c | 33 +++++++++++----------------------
1 file changed, 11 insertions(+), 22 deletions(-)
diff --git a/drivers/spi/spi-uniphier.c b/drivers/spi/spi-uniphier.c
index eac6c3e8908b..5f0abc59b716 100644
--- a/drivers/spi/spi-uniphier.c
+++ b/drivers/spi/spi-uniphier.c
@@ -649,7 +649,7 @@ static int uniphier_spi_probe(struct platform_device *pdev)
int irq;
int ret;
- host = spi_alloc_host(&pdev->dev, sizeof(*priv));
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(*priv));
if (!host)
return -ENOMEM;
@@ -660,30 +660,26 @@ static int uniphier_spi_probe(struct platform_device *pdev)
priv->is_save_param = false;
priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
- if (IS_ERR(priv->base)) {
- ret = PTR_ERR(priv->base);
- goto out_host_put;
- }
+ if (IS_ERR(priv->base))
+ return PTR_ERR(priv->base);
+
priv->base_dma_addr = res->start;
priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(&pdev->dev, "failed to get clock\n");
- ret = PTR_ERR(priv->clk);
- goto out_host_put;
+ return PTR_ERR(priv->clk);
}
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- ret = irq;
- goto out_host_put;
- }
+ if (irq < 0)
+ return irq;
ret = devm_request_irq(&pdev->dev, irq, uniphier_spi_handler,
0, "uniphier-spi", priv);
if (ret) {
dev_err(&pdev->dev, "failed to request IRQ\n");
- goto out_host_put;
+ return ret;
}
init_completion(&priv->xfer_done);
@@ -710,10 +706,9 @@ static int uniphier_spi_probe(struct platform_device *pdev)
host->dma_tx = dma_request_chan(&pdev->dev, "tx");
if (IS_ERR_OR_NULL(host->dma_tx)) {
- if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER) {
- ret = -EPROBE_DEFER;
- goto out_host_put;
- }
+ if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+
host->dma_tx = NULL;
dma_tx_burst = INT_MAX;
} else {
@@ -762,8 +757,6 @@ static int uniphier_spi_probe(struct platform_device *pdev)
host->dma_tx = NULL;
}
-out_host_put:
- spi_controller_put(host);
return ret;
}
@@ -771,16 +764,12 @@ static void uniphier_spi_remove(struct platform_device *pdev)
{
struct spi_controller *host = platform_get_drvdata(pdev);
- spi_controller_get(host);
-
spi_unregister_controller(host);
if (host->dma_tx)
dma_release_channel(host->dma_tx);
if (host->dma_rx)
dma_release_channel(host->dma_rx);
-
- spi_controller_put(host);
}
static const struct of_device_id uniphier_spi_match[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 20/20] spi: zync-qspi: switch to managed controller allocation
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (18 preceding siblings ...)
2026-05-05 7:29 ` [PATCH 19/20] spi: uniphier: switch to managed controller allocation Johan Hovold
@ 2026-05-05 7:29 ` Johan Hovold
2026-05-11 0:56 ` [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Mark Brown
20 siblings, 0 replies; 23+ messages in thread
From: Johan Hovold @ 2026-05-05 7:29 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel, Johan Hovold
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>
---
drivers/spi/spi-zynq-qspi.c | 40 +++++++++++--------------------------
1 file changed, 12 insertions(+), 28 deletions(-)
diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c
index 406fd9d5337e..d762aaf452af 100644
--- a/drivers/spi/spi-zynq-qspi.c
+++ b/drivers/spi/spi-zynq-qspi.c
@@ -637,7 +637,7 @@ static int zynq_qspi_probe(struct platform_device *pdev)
struct zynq_qspi *xqspi;
u32 num_cs;
- ctlr = spi_alloc_host(&pdev->dev, sizeof(*xqspi));
+ ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*xqspi));
if (!ctlr)
return -ENOMEM;
@@ -645,16 +645,13 @@ static int zynq_qspi_probe(struct platform_device *pdev)
xqspi->dev = dev;
platform_set_drvdata(pdev, ctlr);
xqspi->regs = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(xqspi->regs)) {
- ret = PTR_ERR(xqspi->regs);
- goto remove_ctlr;
- }
+ if (IS_ERR(xqspi->regs))
+ return PTR_ERR(xqspi->regs);
xqspi->pclk = devm_clk_get_enabled(&pdev->dev, "pclk");
if (IS_ERR(xqspi->pclk)) {
dev_err(&pdev->dev, "pclk clock not found.\n");
- ret = PTR_ERR(xqspi->pclk);
- goto remove_ctlr;
+ return PTR_ERR(xqspi->pclk);
}
init_completion(&xqspi->data_completion);
@@ -662,21 +659,18 @@ static int zynq_qspi_probe(struct platform_device *pdev)
xqspi->refclk = devm_clk_get_enabled(&pdev->dev, "ref_clk");
if (IS_ERR(xqspi->refclk)) {
dev_err(&pdev->dev, "ref_clk clock not found.\n");
- ret = PTR_ERR(xqspi->refclk);
- goto remove_ctlr;
+ return PTR_ERR(xqspi->refclk);
}
xqspi->irq = platform_get_irq(pdev, 0);
- if (xqspi->irq < 0) {
- ret = xqspi->irq;
- goto remove_ctlr;
- }
+ if (xqspi->irq < 0)
+ return xqspi->irq;
+
ret = devm_request_irq(&pdev->dev, xqspi->irq, zynq_qspi_irq,
0, pdev->name, xqspi);
if (ret != 0) {
- ret = -ENXIO;
dev_err(&pdev->dev, "request_irq failed\n");
- goto remove_ctlr;
+ return -ENXIO;
}
ret = of_property_read_u32(np, "num-cs",
@@ -684,9 +678,8 @@ static int zynq_qspi_probe(struct platform_device *pdev)
if (ret < 0) {
ctlr->num_chipselect = 1;
} else if (num_cs > ZYNQ_QSPI_MAX_NUM_CS) {
- ret = -EINVAL;
dev_err(&pdev->dev, "only 2 chip selects are available\n");
- goto remove_ctlr;
+ return -EINVAL;
} else {
ctlr->num_chipselect = num_cs;
}
@@ -705,15 +698,10 @@ static int zynq_qspi_probe(struct platform_device *pdev)
ret = spi_register_controller(ctlr);
if (ret) {
dev_err(&pdev->dev, "failed to register controller\n");
- goto remove_ctlr;
+ return ret;
}
- return ret;
-
-remove_ctlr:
- spi_controller_put(ctlr);
-
- return ret;
+ return 0;
}
/**
@@ -731,13 +719,9 @@ static void zynq_qspi_remove(struct platform_device *pdev)
struct spi_controller *ctlr = platform_get_drvdata(pdev);
struct zynq_qspi *xqspi = spi_controller_get_devdata(ctlr);
- spi_controller_get(ctlr);
-
spi_unregister_controller(ctlr);
zynq_qspi_write(xqspi, ZYNQ_QSPI_ENABLE_OFFSET, 0);
-
- spi_controller_put(ctlr);
}
static const struct of_device_id zynq_qspi_of_match[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 00/20] spi: switch to managed controller allocation (part 2/3)
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
` (19 preceding siblings ...)
2026-05-05 7:29 ` [PATCH 20/20] spi: zync-qspi: " Johan Hovold
@ 2026-05-11 0:56 ` Mark Brown
20 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2026-05-11 0:56 UTC (permalink / raw)
To: Johan Hovold
Cc: Linus Walleij, Masahisa Kojima, Jassi Brar, Laxman Dewangan,
linux-spi, linux-kernel
On Tue, 05 May 2026 09:28:49 +0200, Johan Hovold wrote:
> spi: switch to managed controller allocation (part 2/3)
>
> In preparation for fixing the SPI controller API so that it no longer
> drops a reference when deregistering (non-managed) controllers (cf.
> [1]), this series converts drivers using non-managed registration to use
> managed allocation.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.2
Thanks!
[01/20] spi: pic32: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/4af89d7d8552
[02/20] spi: pic32-sqi: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/dda3a77e1a32
[03/20] spi: pl022: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/02efc5557c8e
[04/20] spi: qup: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/86e8160240af
[05/20] spi: rspi: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/368d0e6c6f82
[06/20] spi: sh-hspi: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/042414e4da73
[07/20] spi: sh-msiof: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/354b0a4ad4eb
[08/20] spi: sifive: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/fd260013577d
[09/20] spi: slave-mt27xx: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/cd1cd2ff56bf
[10/20] spi: sprd: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/d68627cc76cd
[11/20] spi: st-ssc4: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/d3cf5ebdf1c9
[12/20] spi: sun4i: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/02b36d644ded
[13/20] spi: sun6i: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/9864636b1cd9
[14/20] spi: syncuacer: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/5d5bbf177d18
[15/20] spi: tegra114: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/3068e7063cc4
[16/20] spi: tegra20-sflash: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/3a14bf4f5453
[17/20] spi: ti-qspi: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/76a24627b98c
[18/20] spi: ti-qspi: cleanup registration error path
https://git.kernel.org/broonie/spi/c/f8689d5a9ee4
[19/20] spi: uniphier: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/789986b14564
[20/20] spi: zync-qspi: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/be552efa43ee
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 23+ messages in thread