Skip to contentSkip to conversation

spi: switch to managed controller allocation (part 3/3)

PATCH In review Johan Hovold 2 participants 14 messages May 11 – May 18

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover spi: switch to managed controller allocation (part 3/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 managed registration to also use managed allocation.

Included is also a related cleanup of a lp8841-rtc.

This leaves us with 18 drivers using non-managed allocation, which is few enough to be able to fix the API in tree-wide change.

Johan

[1] https://lore.kernel.org/lkml/[email protected]/

Johan Hovold (12):
spi: altera-platform: switch to managed controller allocation
spi: armada-3700: switch to managed controller allocation
spi: clps711x: switch to managed controller allocation
spi: falcon: switch to managed controller allocation
spi: fsi: switch to managed controller allocation
spi: hisi-sfc-v3xx: switch to managed controller allocation
spi: jcore: switch to managed controller allocation
spi: lp8841-rtc: switch to managed controller allocation
spi: lp8841-rtc: drop unused ifdef
spi: meson-spifc: switch to managed controller allocation
spi: mux: switch to managed controller allocation
spi: xlp: switch to managed controller allocation

 drivers/spi/spi-altera-platform.c | 27 +++++++------------
 drivers/spi/spi-armada-3700.c     | 44 ++++++++++---------------------
 drivers/spi/spi-clps711x.c        | 31 +++++++---------------
 drivers/spi/spi-falcon.c          |  8 ++----
 drivers/spi/spi-fsi.c             |  8 +++---
 drivers/spi/spi-hisi-sfc-v3xx.c   | 20 +++++---------
 drivers/spi/spi-jcore.c           | 23 +++++-----------
 drivers/spi/spi-lp8841-rtc.c      | 16 +++--------
 drivers/spi/spi-meson-spifc.c     | 22 ++++++----------
 drivers/spi/spi-mux.c             | 19 +++----------
 drivers/spi/spi-xlp.c             |  3 +--
 11 files changed, 68 insertions(+), 153 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/12 spi: altera-platform: switch to managed controller allocation

Switch to device managed controller allocation for consistency and to simplify error handling.

---
 drivers/spi/spi-altera-platform.c | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)
drivers/spi/spi-altera-platform.c +10 -17
index fc81de2610ef..3ee5d3480bb4 100644
@@ -39,12 +39,12 @@ static int altera_spi_probe(struct platform_device *pdev)
 	enum altera_spi_type type = ALTERA_SPI_TYPE_UNKNOWN;
 	struct altera_spi *hw;
 	struct spi_controller *host;
-	int err = -ENODEV;
+	int err;
 	u16 i;
 
-	host = spi_alloc_host(&pdev->dev, sizeof(struct altera_spi));
+	host = devm_spi_alloc_host(&pdev->dev, sizeof(struct altera_spi));
 	if (!host)
-		return err;
+		return -ENOMEM;
 
 	/* setup the host state. */
 	host->bus_num = -1;
@@ -54,8 +54,7 @@ static int altera_spi_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev,
 				"Invalid number of chipselect: %u\n",
 				pdata->num_chipselect);
-			err = -EINVAL;
-			goto exit;
+			return -EINVAL;
 		}
 
 		host->num_chipselect = pdata->num_chipselect;
@@ -80,7 +79,7 @@ static int altera_spi_probe(struct platform_device *pdev)
 		hw->regmap = dev_get_regmap(pdev->dev.parent, NULL);
 		if (!hw->regmap) {
 			dev_err(&pdev->dev, "get regmap failed\n");
-			goto exit;
+			return -ENODEV;
 		}
 
 		regoff = platform_get_resource(pdev, IORESOURCE_REG, 0);
@@ -90,17 +89,14 @@ static int altera_spi_probe(struct platform_device *pdev)
 		void __iomem *res;
 
 		res = devm_platform_ioremap_resource(pdev, 0);
-		if (IS_ERR(res)) {
-			err = PTR_ERR(res);
-			goto exit;
-		}
+		if (IS_ERR(res))
+			return PTR_ERR(res);
 
 		hw->regmap = devm_regmap_init_mmio(&pdev->dev, res,
 						   &spi_altera_config);
 		if (IS_ERR(hw->regmap)) {
 			dev_err(&pdev->dev, "regmap mmio init failed\n");
-			err = PTR_ERR(hw->regmap);
-			goto exit;
+			return PTR_ERR(hw->regmap);
 		}
 	}
 
@@ -112,12 +108,12 @@ static int altera_spi_probe(struct platform_device *pdev)
 		err = devm_request_irq(&pdev->dev, hw->irq, altera_spi_irq, 0,
 				       pdev->name, host);
 		if (err)
-			goto exit;
+			return err;
 	}
 
 	err = devm_spi_register_controller(&pdev->dev, host);
 	if (err)
-		goto exit;
+		return err;
 
 	if (pdata) {
 		for (i = 0; i < pdata->num_devices; i++) {
@@ -131,9 +127,6 @@ static int altera_spi_probe(struct platform_device *pdev)
 	dev_info(&pdev->dev, "regoff %u, irq %d\n", hw->regoff, hw->irq);
 
 	return 0;
-exit:
-	spi_controller_put(host);
-	return err;
 }
 
 #ifdef CONFIG_OF
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/12 spi: armada-3700: switch to managed controller allocation

In reply to Johan Hovold

Switch to device managed controller allocation for consistency and to simplify error handling.

---
 drivers/spi/spi-armada-3700.c | 44 +++++++++++------------------------
 1 file changed, 14 insertions(+), 30 deletions(-)
drivers/spi/spi-armada-3700.c +14 -30
index 78248729d3e9..ca2faa265ca0 100644
@@ -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 = {
Signature · 1 line
2.53.0
#3 lore raw

PATCH 3/12 spi: clps711x: switch to managed controller allocation

In reply to Johan Hovold

Switch to device managed controller allocation for consistency and to simplify error handling.

---
 drivers/spi/spi-clps711x.c | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)
drivers/spi/spi-clps711x.c +9 -22
index d6458e59d41b..382c3c81c4b9 100644
@@ -99,7 +99,7 @@ static int spi_clps711x_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	host = spi_alloc_host(&pdev->dev, sizeof(*hw));
+	host = devm_spi_alloc_host(&pdev->dev, sizeof(*hw));
 	if (!host)
 		return -ENOMEM;
 
@@ -113,22 +113,16 @@ static int spi_clps711x_probe(struct platform_device *pdev)
 	hw = spi_controller_get_devdata(host);
 
 	hw->spi_clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(hw->spi_clk)) {
-		ret = PTR_ERR(hw->spi_clk);
-		goto err_out;
-	}
+	if (IS_ERR(hw->spi_clk))
+		return PTR_ERR(hw->spi_clk);
 
 	hw->syscon = syscon_regmap_lookup_by_phandle(np, "syscon");
-	if (IS_ERR(hw->syscon)) {
-		ret = PTR_ERR(hw->syscon);
-		goto err_out;
-	}
+	if (IS_ERR(hw->syscon))
+		return PTR_ERR(hw->syscon);
 
 	hw->syncio = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(hw->syncio)) {
-		ret = PTR_ERR(hw->syncio);
-		goto err_out;
-	}
+	if (IS_ERR(hw->syncio))
+		return PTR_ERR(hw->syncio);
 
 	/* Disable extended mode due hardware problems */
 	regmap_update_bits(hw->syscon, SYSCON_OFFSET, SYSCON3_ADCCON, 0);
@@ -139,16 +133,9 @@ static int spi_clps711x_probe(struct platform_device *pdev)
 	ret = devm_request_irq(&pdev->dev, irq, spi_clps711x_isr, 0,
 			       dev_name(&pdev->dev), host);
 	if (ret)
-		goto err_out;
+		return ret;
 
-	ret = devm_spi_register_controller(&pdev->dev, host);
-	if (!ret)
-		return 0;
-
-err_out:
-	spi_controller_put(host);
-
-	return ret;
+	return devm_spi_register_controller(&pdev->dev, host);
 }
 
 static const struct of_device_id clps711x_spi_dt_ids[] = {
Signature · 1 line
2.53.0
#4 lore raw

PATCH 4/12 spi: falcon: switch to managed controller allocation

In reply to Johan Hovold

Switch to device managed controller allocation for consistency and to simplify error handling.

---
 drivers/spi/spi-falcon.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/spi/spi-falcon.c +2 -6
index cb15faabd88f..e00e808eafee 100644
@@ -392,9 +392,8 @@ static int falcon_sflash_probe(struct platform_device *pdev)
 {
 	struct falcon_sflash *priv;
 	struct spi_controller *host;
-	int ret;
 
-	host = spi_alloc_host(&pdev->dev, sizeof(*priv));
+	host = devm_spi_alloc_host(&pdev->dev, sizeof(*priv));
 	if (!host)
 		return -ENOMEM;
 
@@ -406,10 +405,7 @@ static int falcon_sflash_probe(struct platform_device *pdev)
 	host->setup = falcon_sflash_setup;
 	host->transfer_one_message = falcon_sflash_xfer_one;
 
-	ret = devm_spi_register_controller(&pdev->dev, host);
-	if (ret)
-		spi_controller_put(host);
-	return ret;
+	return devm_spi_register_controller(&pdev->dev, host);
 }
 
 static const struct of_device_id falcon_sflash_match[] = {
Signature · 1 line
2.53.0
#5 lore raw

PATCH 5/12 spi: fsi: switch to managed controller allocation

In reply to Johan Hovold

Switch to device managed controller allocation for consistency and to simplify error handling.

---
 drivers/spi/spi-fsi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/spi/spi-fsi.c +4 -4
index f6a75f0184c4..451cb4cfdb9c 100644
@@ -554,7 +554,7 @@ static int fsi_spi_probe(struct fsi_device *fsi)
 		if (of_property_read_u32(np, "reg", &base))
 			continue;
 
-		ctlr = spi_alloc_host(dev, sizeof(*ctx));
+		ctlr = devm_spi_alloc_host(dev, sizeof(*ctx));
 		if (!ctlr)
 			break;
 
@@ -571,9 +571,9 @@ static int fsi_spi_probe(struct fsi_device *fsi)
 
 		rc = devm_spi_register_controller(dev, ctlr);
 		if (rc)
-			spi_controller_put(ctlr);
-		else
-			num_controllers_registered++;
+			continue;
+
+		num_controllers_registered++;
 	}
 
 	if (!num_controllers_registered)
Signature · 1 line
2.53.0
#6 lore raw

PATCH 6/12 spi: hisi-sfc-v3xx: switch to managed controller allocation

In reply to Johan Hovold

Switch to device managed controller allocation for consistency and to simplify error handling.

---
 drivers/spi/spi-hisi-sfc-v3xx.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/spi/spi-hisi-sfc-v3xx.c +6 -14
index b2af2eed197f..eeeb86381862 100644
@@ -436,7 +436,7 @@ static int hisi_sfc_v3xx_probe(struct platform_device *pdev)
 	u32 version, glb_config;
 	int ret;
 
-	ctlr = spi_alloc_host(&pdev->dev, sizeof(*host));
+	ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*host));
 	if (!ctlr)
 		return -ENOMEM;
 
@@ -451,16 +451,12 @@ static int hisi_sfc_v3xx_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, host);
 
 	host->regbase = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(host->regbase)) {
-		ret = PTR_ERR(host->regbase);
-		goto err_put_host;
-	}
+	if (IS_ERR(host->regbase))
+		return PTR_ERR(host->regbase);
 
 	host->irq = platform_get_irq_optional(pdev, 0);
-	if (host->irq == -EPROBE_DEFER) {
-		ret = -EPROBE_DEFER;
-		goto err_put_host;
-	}
+	if (host->irq == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
 
 	hisi_sfc_v3xx_disable_int(host);
 
@@ -501,16 +497,12 @@ static int hisi_sfc_v3xx_probe(struct platform_device *pdev)
 
 	ret = devm_spi_register_controller(dev, ctlr);
 	if (ret)
-		goto err_put_host;
+		return ret;
 
 	dev_info(&pdev->dev, "hw version 0x%x, %s mode.\n",
 		 version, host->irq ? "irq" : "polling");
 
 	return 0;
-
-err_put_host:
-	spi_controller_put(ctlr);
-	return ret;
 }
 
 static const struct acpi_device_id hisi_sfc_v3xx_acpi_ids[] = {
Signature · 1 line
2.53.0
#7 lore raw

PATCH 7/12 spi: jcore: switch to managed controller allocation

In reply to Johan Hovold

Switch to device managed controller allocation for consistency and to simplify error handling.

---
 drivers/spi/spi-jcore.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)
drivers/spi/spi-jcore.c +6 -17
index e37ca22e04ba..a75cd61ec7a3 100644
@@ -146,11 +146,10 @@ static int jcore_spi_probe(struct platform_device *pdev)
 	struct resource *res;
 	u32 clock_freq;
 	struct clk *clk;
-	int err = -ENODEV;
 
-	host = spi_alloc_host(&pdev->dev, sizeof(struct jcore_spi));
+	host = devm_spi_alloc_host(&pdev->dev, sizeof(struct jcore_spi));
 	if (!host)
-		return err;
+		return -ENOMEM;
 
 	/* Setup the host state. */
 	host->num_chipselect = 3;
@@ -167,14 +166,14 @@ static int jcore_spi_probe(struct platform_device *pdev)
 	/* Find and map our resources */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
-		goto exit_busy;
+		return -EBUSY;
 	if (!devm_request_mem_region(&pdev->dev, res->start,
 				     resource_size(res), pdev->name))
-		goto exit_busy;
+		return -EBUSY;
 	hw->base = devm_ioremap(&pdev->dev, res->start,
 					resource_size(res));
 	if (!hw->base)
-		goto exit_busy;
+		return -EBUSY;
 
 	/*
 	 * The SPI clock rate controlled via a configurable clock divider
@@ -200,17 +199,7 @@ static int jcore_spi_probe(struct platform_device *pdev)
 	jcore_spi_baudrate(hw, 400000);
 
 	/* Register our spi controller */
-	err = devm_spi_register_controller(&pdev->dev, host);
-	if (err)
-		goto exit;
-
-	return 0;
-
-exit_busy:
-	err = -EBUSY;
-exit:
-	spi_controller_put(host);
-	return err;
+	return devm_spi_register_controller(&pdev->dev, host);
 }
 
 static const struct of_device_id jcore_spi_of_match[] = {
Signature · 1 line
2.53.0
#8 lore raw

PATCH 8/12 spi: lp8841-rtc: switch to managed controller allocation

In reply to Johan Hovold

Switch to device managed controller allocation for consistency and to simplify error handling.

---
 drivers/spi/spi-lp8841-rtc.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/spi/spi-lp8841-rtc.c +4 -10
index e466866d5e80..355d9df4d1be 100644
@@ -185,7 +185,7 @@ spi_lp8841_rtc_probe(struct platform_device *pdev)
 	struct spi_controller		*host;
 	struct spi_lp8841_rtc		*data;
 
-	host = spi_alloc_host(&pdev->dev, sizeof(*data));
+	host = devm_spi_alloc_host(&pdev->dev, sizeof(*data));
 	if (!host)
 		return -ENOMEM;
 	platform_set_drvdata(pdev, host);
@@ -208,23 +208,17 @@ spi_lp8841_rtc_probe(struct platform_device *pdev)
 	ret = PTR_ERR_OR_ZERO(data->iomem);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to get IO address\n");
-		goto err_put_host;
+		return ret;
 	}
 
 	/* register with the SPI framework */
 	ret = devm_spi_register_controller(&pdev->dev, host);
 	if (ret) {
 		dev_err(&pdev->dev, "cannot register spi host\n");
-		goto err_put_host;
+		return ret;
 	}
 
-	return ret;
-
-
-err_put_host:
-	spi_controller_put(host);
-
-	return ret;
+	return 0;
 }
 
 MODULE_ALIAS("platform:" DRIVER_NAME);
Signature · 1 line
2.53.0
#9 lore raw

PATCH 9/12 spi: lp8841-rtc: drop unused ifdef

In reply to Johan Hovold

Drop the probe CONFIG_OF ifdef which is unused since commit 3974a585be78 ("spi: Drop duplicate of_node assignment").

---
 drivers/spi/spi-lp8841-rtc.c | 2 --
 1 file changed, 2 deletions(-)
drivers/spi/spi-lp8841-rtc.c +0 -2
index 355d9df4d1be..b2546a3a9eaa 100644
@@ -199,8 +199,6 @@ spi_lp8841_rtc_probe(struct platform_device *pdev)
 	host->set_cs = spi_lp8841_rtc_set_cs;
 	host->transfer_one = spi_lp8841_rtc_transfer_one;
 	host->bits_per_word_mask = SPI_BPW_MASK(8);
-#ifdef CONFIG_OF
-#endif
 
 	data = spi_controller_get_devdata(host);
 
Signature · 1 line
2.53.0
#10 lore raw

PATCH 10/12 spi: meson-spifc: switch to managed controller allocation

In reply to Johan Hovold

Switch to device managed controller allocation for consistency and to simplify error handling.

---
 drivers/spi/spi-meson-spifc.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/spi/spi-meson-spifc.c +8 -14
index b818950a8cb7..d700fa315223 100644
@@ -288,9 +288,9 @@ static int meson_spifc_probe(struct platform_device *pdev)
 	struct meson_spifc *spifc;
 	void __iomem *base;
 	unsigned int rate;
-	int ret = 0;
+	int ret;
 
-	host = spi_alloc_host(&pdev->dev, sizeof(struct meson_spifc));
+	host = devm_spi_alloc_host(&pdev->dev, sizeof(struct meson_spifc));
 	if (!host)
 		return -ENOMEM;
 
@@ -300,23 +300,18 @@ static int meson_spifc_probe(struct platform_device *pdev)
 	spifc->dev = &pdev->dev;
 
 	base = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(base)) {
-		ret = PTR_ERR(base);
-		goto out_err;
-	}
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	spifc->regmap = devm_regmap_init_mmio(spifc->dev, base,
 					      &spifc_regmap_config);
-	if (IS_ERR(spifc->regmap)) {
-		ret = PTR_ERR(spifc->regmap);
-		goto out_err;
-	}
+	if (IS_ERR(spifc->regmap))
+		return PTR_ERR(spifc->regmap);
 
 	spifc->clk = devm_clk_get_enabled(spifc->dev, NULL);
 	if (IS_ERR(spifc->clk)) {
 		dev_err(spifc->dev, "missing clock\n");
-		ret = PTR_ERR(spifc->clk);
-		goto out_err;
+		return PTR_ERR(spifc->clk);
 	}
 
 	rate = clk_get_rate(spifc->clk);
@@ -342,8 +337,7 @@ static int meson_spifc_probe(struct platform_device *pdev)
 	return 0;
 out_pm:
 	pm_runtime_disable(spifc->dev);
-out_err:
-	spi_controller_put(host);
+
 	return ret;
 }
 
Signature · 1 line
2.53.0
#11 lore raw

PATCH 11/12 spi: mux: switch to managed controller allocation

In reply to Johan Hovold

Switch to device managed controller allocation for consistency and to simplify error handling.

---
 drivers/spi/spi-mux.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/spi/spi-mux.c +4 -15
index bd122de152c0..08fe1fa32dea 100644
@@ -127,9 +127,8 @@ static int spi_mux_probe(struct spi_device *spi)
 {
 	struct spi_controller *ctlr;
 	struct spi_mux_priv *priv;
-	int ret;
 
-	ctlr = spi_alloc_host(&spi->dev, sizeof(*priv));
+	ctlr = devm_spi_alloc_host(&spi->dev, sizeof(*priv));
 	if (!ctlr)
 		return -ENOMEM;
 
@@ -146,9 +145,8 @@ static int spi_mux_probe(struct spi_device *spi)
 
 	priv->mux = devm_mux_control_get(&spi->dev, NULL);
 	if (IS_ERR(priv->mux)) {
-		ret = dev_err_probe(&spi->dev, PTR_ERR(priv->mux),
-				    "failed to get control-mux\n");
-		goto err_put_ctlr;
+		return dev_err_probe(&spi->dev, PTR_ERR(priv->mux),
+				     "failed to get control-mux\n");
 	}
 
 	priv->current_cs = SPI_MUX_NO_CS;
@@ -164,16 +162,7 @@ static int spi_mux_probe(struct spi_device *spi)
 	ctlr->must_async = true;
 	ctlr->defer_optimize_message = true;
 
-	ret = devm_spi_register_controller(&spi->dev, ctlr);
-	if (ret)
-		goto err_put_ctlr;
-
-	return 0;
-
-err_put_ctlr:
-	spi_controller_put(ctlr);
-
-	return ret;
+	return devm_spi_register_controller(&spi->dev, ctlr);
 }
 
 static const struct spi_device_id spi_mux_id[] = {
Signature · 1 line
2.53.0
#12 lore raw

PATCH 12/12 spi: xlp: switch to managed controller allocation

In reply to Johan Hovold

Switch to device managed controller allocation for consistency and to simplify error handling.

---
 drivers/spi/spi-xlp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-xlp.c +1 -2
index be8bbe1cbba3..d014955e6d4b 100644
@@ -398,7 +398,7 @@ static int xlp_spi_probe(struct platform_device *pdev)
 
 	xspi->spi_clk = clk_get_rate(clk);
 
-	host = spi_alloc_host(&pdev->dev, 0);
+	host = devm_spi_alloc_host(&pdev->dev, 0);
 	if (!host) {
 		dev_err(&pdev->dev, "could not alloc host\n");
 		return -ENOMEM;
@@ -418,7 +418,6 @@ static int xlp_spi_probe(struct platform_device *pdev)
 	err = devm_spi_register_controller(&pdev->dev, host);
 	if (err) {
 		dev_err(&pdev->dev, "spi register host failed!\n");
-		spi_controller_put(host);
 		return err;
 	}
 
Signature · 1 line
2.53.0
maintainer
#13 lore raw
In reply to Johan Hovold
Quoted 8 lines · Johan Hovold

spi: switch to managed controller allocation (part 3/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 managed registration to also use managed allocation.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.2

Thanks!

[01/12] spi: altera-platform: switch to managed controller allocation

        https://git.kernel.org/broonie/spi/c/a7a24f0eaa71
[02/12] spi: armada-3700: switch to managed controller allocation
        https://git.kernel.org/broonie/spi/c/5b4a0450fe2f
[03/12] spi: clps711x: switch to managed controller allocation
        https://git.kernel.org/broonie/spi/c/ee9575d2b3db
[04/12] spi: falcon: switch to managed controller allocation
        https://git.kernel.org/broonie/spi/c/864c368199cf
[05/12] spi: fsi: switch to managed controller allocation
        https://git.kernel.org/broonie/spi/c/c087eb4603d9
[06/12] spi: hisi-sfc-v3xx: switch to managed controller allocation
        https://git.kernel.org/broonie/spi/c/572a9fb1a609
[07/12] spi: jcore: switch to managed controller allocation
        https://git.kernel.org/broonie/spi/c/0a290bb1ff0b
[08/12] spi: lp8841-rtc: switch to managed controller allocation
        https://git.kernel.org/broonie/spi/c/06ba67d9d479
[09/12] spi: lp8841-rtc: drop unused ifdef
        https://git.kernel.org/broonie/spi/c/4fee1d3a563d
[10/12] spi: meson-spifc: switch to managed controller allocation
        https://git.kernel.org/broonie/spi/c/1e447a5aa124
[11/12] spi: mux: switch to managed controller allocation
        https://git.kernel.org/broonie/spi/c/60db555fca74
[12/12] spi: xlp: switch to managed controller allocation
        https://git.kernel.org/broonie/spi/c/f3d1dc0bc65a

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