spi: xcomm: make use of devm_spi_alloc_host()
authorNuno Sa <nuno.sa@analog.com>
Fri, 5 Jul 2024 15:12:40 +0000 (17:12 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 5 Jul 2024 17:47:44 +0000 (18:47 +0100)
Use devm_spi_alloc_host() so that there's no need to call
spi_controller_put() in the error path.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240705-dev-spi-xcomm-gpiochip-v2-2-b10842fc9636@analog.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-xcomm.c

index 063ce75af65042aaddebd6c0311b286fdb055290..5bbc250bc05347d241af2ad918aad9d23bf12872 100644 (file)
@@ -248,7 +248,7 @@ static int spi_xcomm_probe(struct i2c_client *i2c)
        struct spi_controller *host;
        int ret;
 
-       host = spi_alloc_host(&i2c->dev, sizeof(*spi_xcomm));
+       host = devm_spi_alloc_host(&i2c->dev, sizeof(*spi_xcomm));
        if (!host)
                return -ENOMEM;
 
@@ -265,7 +265,7 @@ static int spi_xcomm_probe(struct i2c_client *i2c)
 
        ret = devm_spi_register_controller(&i2c->dev, host);
        if (ret < 0)
-               spi_controller_put(host);
+               return ret;
 
        return spi_xcomm_gpio_add(spi_xcomm);
 }