spi: imx: Check for allocation failure earlier
authorFabio Estevam <fabio.estevam@nxp.com>
Tue, 20 Jun 2017 16:50:55 +0000 (13:50 -0300)
committerMark Brown <broonie@kernel.org>
Wed, 21 Jun 2017 11:09:07 +0000 (12:09 +0100)
In case of spi_alloc_master() failure it is better to return the
error immediately, so move the error check right after the allocation.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-imx.c

index e544f45348cc3d0c9f60338f3db277191fcecf77..f9698b7aeb3b50bbcd79ee01a950faf48908e33c 100644 (file)
@@ -1169,15 +1169,15 @@ static int spi_imx_probe(struct platform_device *pdev)
        }
 
        master = spi_alloc_master(&pdev->dev, sizeof(struct spi_imx_data));
+       if (!master)
+               return -ENOMEM;
+
        ret = of_property_read_u32(np, "fsl,spi-rdy-drctl", &spi_drctl);
        if ((ret < 0) || (spi_drctl >= 0x3)) {
                /* '11' is reserved */
                spi_drctl = 0;
        }
 
-       if (!master)
-               return -ENOMEM;
-
        platform_set_drvdata(pdev, master);
 
        master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);