linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] spi/spi_s3c64xx: Make probe more robust against missing board config
@ 2010-08-20 16:17 Mark Brown
  2010-08-20 16:17 ` [PATCH 2/2] spi/spi_s3c64xx: Staticise non-exported functions Mark Brown
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Mark Brown @ 2010-08-20 16:17 UTC (permalink / raw)
  To: David Brownell, Grant Likely
  Cc: Jassi Brar, spi-devel-general, linux-kernel, Mark Brown

The S3C64xx SPI driver requires the machine to call s3c64xx_spi_set_info()
to select a few options, including the clock to use for the SPI controller.
If this is not done then a NULL will be passed as the clock name for
clk_get(), causing an obscure crash. Guard against this and other missing
configuration by validating that the clock name has been filled in in
the platform data that ets passed in.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/spi/spi_s3c64xx.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi_s3c64xx.c b/drivers/spi/spi_s3c64xx.c
index 9736581..a0b63b7 100644
--- a/drivers/spi/spi_s3c64xx.c
+++ b/drivers/spi/spi_s3c64xx.c
@@ -919,6 +919,13 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	sci = pdev->dev.platform_data;
+	if (!sci->src_clk_name) {
+		dev_err(&pdev->dev,
+			"Board init must call s3c64xx_spi_set_info()\n");
+		return -EINVAL;
+	}
+
 	/* Check for availability of necessary resource */
 
 	dmatx_res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
@@ -946,8 +953,6 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	sci = pdev->dev.platform_data;
-
 	platform_set_drvdata(pdev, master);
 
 	sdd = spi_master_get_devdata(master);
-- 
1.7.1

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

end of thread, other threads:[~2010-08-23  9:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-20 16:17 [PATCH 1/2] spi/spi_s3c64xx: Make probe more robust against missing board config Mark Brown
2010-08-20 16:17 ` [PATCH 2/2] spi/spi_s3c64xx: Staticise non-exported functions Mark Brown
     [not found]   ` <1282321028-32196-2-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2010-08-21  1:52     ` Jassi Brar
2010-08-20 20:46 ` [PATCH 1/2] spi/spi_s3c64xx: Make probe more robust against missing board config Grant Likely
2010-08-21  1:45 ` [spi-devel-general] " Jassi Brar
2010-08-21 10:08   ` Mark Brown
     [not found]     ` <20100821100855.GA5545-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2010-08-21 13:58       ` Jassi Brar
2010-08-21 19:30         ` [spi-devel-general] " Mark Brown
2010-08-22  3:37           ` Jassi Brar
     [not found]             ` <AANLkTikDj7YsOQXnFGjZCNRYuQQbLRtKiWw5Sm=vkCuq-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-23  9:57               ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).