mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] spi: coldfire-qspi: fix error return code in mcfqspi_probe()
@ 2013-05-16  5:11 Wei Yongjun
  2013-05-16 18:22 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2013-05-16  5:11 UTC (permalink / raw)
  To: broonie, grant.likely; +Cc: yongjun_wei, spi-devel-general, linux-kernel

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

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>
---
 drivers/spi/spi-coldfire-qspi.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-coldfire-qspi.c b/drivers/spi/spi-coldfire-qspi.c
index 3f17660..f2acb90 100644
--- a/drivers/spi/spi-coldfire-qspi.c
+++ b/drivers/spi/spi-coldfire-qspi.c
@@ -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;
 


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] spi: coldfire-qspi: fix error return code in mcfqspi_probe()
  2013-05-16  5:11 [PATCH] spi: coldfire-qspi: fix error return code in mcfqspi_probe() Wei Yongjun
@ 2013-05-16 18:22 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-05-16 18:22 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: grant.likely, yongjun_wei, spi-devel-general, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 306 bytes --]

On Thu, May 16, 2013 at 01:11:32PM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> 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.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-16 18:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-16  5:11 [PATCH] spi: coldfire-qspi: fix error return code in mcfqspi_probe() Wei Yongjun
2013-05-16 18:22 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®