]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
spi: coldfire-qspi: fix error return code in mcfqspi_probe()
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Thu, 16 May 2013 05:11:32 +0000 (13:11 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 16 May 2013 18:21:50 +0000 (19:21 +0100)
If pdev->dev.platform_data is not set, mcfqspi_probe() will return 0
and release all the resources, in this case, we should return a error
code instead of 0.
This patch fix to return -ENOENT in this case and move the check for
pdev->dev.platform_data to the begin of this function.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/spi/spi-coldfire-qspi.c

index 7b5cc9e4e94d6a355962fca0afe05d3a3837339b..f99943bf3519fe20d8fa9351451e3a026e70f18a 100644 (file)
@@ -408,6 +408,12 @@ static int mcfqspi_probe(struct platform_device *pdev)
        struct mcfqspi_platform_data *pdata;
        int status;
 
+       pdata = pdev->dev.platform_data;
+       if (!pdata) {
+               dev_dbg(&pdev->dev, "platform data is missing\n");
+               return -ENOENT;
+       }
+
        master = spi_alloc_master(&pdev->dev, sizeof(*mcfqspi));
        if (master == NULL) {
                dev_dbg(&pdev->dev, "spi_alloc_master failed\n");
@@ -458,11 +464,6 @@ static int mcfqspi_probe(struct platform_device *pdev)
        }
        clk_enable(mcfqspi->clk);
 
-       pdata = pdev->dev.platform_data;
-       if (!pdata) {
-               dev_dbg(&pdev->dev, "platform data is missing\n");
-               goto fail4;
-       }
        master->bus_num = pdata->bus_num;
        master->num_chipselect = pdata->num_chipselect;