From: Johan Hovold Date: Mon, 11 May 2026 15:04:07 +0000 (+0200) Subject: spi: mux: switch to managed controller allocation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60db555fca747c8d860d9b683d281d903c4dab50;p=thirdparty%2Flinux.git spi: mux: switch to managed controller allocation Switch to device managed controller allocation for consistency and to simplify error handling. Signed-off-by: Johan Hovold Link: https://patch.msgid.link/20260511150408.796155-12-johan@kernel.org Signed-off-by: Mark Brown --- diff --git a/drivers/spi/spi-mux.c b/drivers/spi/spi-mux.c index bd122de152c0f..08fe1fa32dea3 100644 --- a/drivers/spi/spi-mux.c +++ b/drivers/spi/spi-mux.c @@ -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[] = {