[flashrom] [commit] r1092 - trunk

repository service svn at flashrom.org
Sun Jul 18 16:42:28 CEST 2010


Author: hailfinger
Date: Sun Jul 18 16:42:28 2010
New Revision: 1092
URL: http://flashrom.org/trac/coreboot/changeset/1092

Log:
Check during SPI bitbang init that SPI bitbang master configuration is
correct.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Acked-by: Michael Karcher <flashrom at mkarcher.dialup.fu-berlin.de>

Modified:
   trunk/bitbang_spi.c
   trunk/flash.h

Modified: trunk/bitbang_spi.c
==============================================================================
--- trunk/bitbang_spi.c	Sun Jul 18 01:27:47 2010	(r1091)
+++ trunk/bitbang_spi.c	Sun Jul 18 16:42:28 2010	(r1092)
@@ -54,6 +54,16 @@
 
 int bitbang_spi_init(const struct bitbang_spi_master *master, int halfperiod)
 {
+	/* BITBANG_SPI_INVALID is 0, so if someone forgot to initialize ->type,
+	 * we catch it here. Same goes for missing initialization of bitbanging
+	 * functions.
+	 */
+	if (!master || master->type == BITBANG_SPI_INVALID || !master->set_cs ||
+	    !master->set_sck || !master->set_mosi || !master->get_miso) {
+		msg_perr("Incomplete bitbanging SPI master setting! Please "
+			 "report a bug at flashrom at flashrom.org\n");
+		return 1;
+	}
 	bitbang_spi_master = master;
 	bitbang_spi_half_period = halfperiod;
 

Modified: trunk/flash.h
==============================================================================
--- trunk/flash.h	Sun Jul 18 01:27:47 2010	(r1091)
+++ trunk/flash.h	Sun Jul 18 16:42:28 2010	(r1092)
@@ -128,7 +128,7 @@
 void programmer_delay(int usecs);
 
 enum bitbang_spi_master_type {
-	BITBANG_SPI_DUMMY	/* remove as soon as there is a real entry */
+	BITBANG_SPI_INVALID	= 0, /* This must always be the first entry. */
 };
 
 struct bitbang_spi_master {




More information about the flashrom mailing list