Skip to content

Commit

Permalink
spi: imx: Check for allocation failure earlier
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Fabio Estevam authored and Mark Brown committed Jun 21, 2017
1 parent 2e312f6 commit 2c14777
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/spi/spi-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2c14777

Please sign in to comment.