diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2010-07-18 14:42:28 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2010-07-18 14:42:28 +0000 |
commit | 17e23ac9798e5e983232c42314d7affb2994925e (patch) | |
tree | 6602356afa0436123eed615c45a88f3d5071b821 | |
parent | 62175a094dcb74dc4845cd091be5100b6b4ec5d7 (diff) | |
download | flashrom-17e23ac9798e5e983232c42314d7affb2994925e.tar.gz flashrom-17e23ac9798e5e983232c42314d7affb2994925e.tar.bz2 flashrom-17e23ac9798e5e983232c42314d7affb2994925e.zip |
Check during SPI bitbang init that SPI bitbang master configuration is correct
Corresponding to flashrom svn r1092.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
-rw-r--r-- | bitbang_spi.c | 10 | ||||
-rw-r--r-- | flash.h | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/bitbang_spi.c b/bitbang_spi.c index 9f0e87880..b58633a42 100644 --- a/bitbang_spi.c +++ b/bitbang_spi.c @@ -54,6 +54,16 @@ static int bitbang_spi_get_miso(void) 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@flashrom.org\n"); + return 1; + } bitbang_spi_master = master; bitbang_spi_half_period = halfperiod; @@ -128,7 +128,7 @@ void chip_readn(uint8_t *buf, const chipaddr addr, size_t len); 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 { |