]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: mux: switch to managed controller allocation
authorJohan Hovold <johan@kernel.org>
Mon, 11 May 2026 15:04:07 +0000 (17:04 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 18 May 2026 09:19:51 +0000 (10:19 +0100)
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-12-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-mux.c

index bd122de152c0ff5503db29661d79a0ab5453203e..08fe1fa32dea3cfc6f0ae318046aecedae2d83d3 100644 (file)
@@ -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[] = {