From aa0c38e9f70edd2e50d9133f415ed4c561b38f7d Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Tue, 16 Dec 2014 12:19:00 -0800 Subject: [PATCH] spi: Die if Winbond chip driver gets probed twice The way we use the SPI API does not allow for multiple chips to be used simultaneously. This adds a dumb check to see if the chip has already been probed/initialized, which should only happen once given the current assumptions. If we want to support multiple chips simultaneously, we should further re-factor these chip drivers to be malloc()-friendly in early stages (Julius suggested suggested implementing a mini-heap). BUG=none BRANCH=none TEST=none (current ToT is broken) Signed-off-by: David Hendricks Change-Id: I27ccbd5d94e00970f3a07c6383ccdce14a09cb60 Reviewed-on: https://chromium-review.googlesource.com/236080 Reviewed-by: Julius Werner (cherry picked from commit 5da9e0eceb50b99fa9aba6f597dafcab1965486c) Signed-off-by: Julius Werner Reviewed-on: https://chromium-review.googlesource.com/237024 --- src/drivers/spi/winbond.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c index a0abeb4ef0..d4f61df480 100644 --- a/src/drivers/spi/winbond.c +++ b/src/drivers/spi/winbond.c @@ -192,6 +192,9 @@ struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode) unsigned page_size; unsigned int i; + if (stm.params) + die("Winbond driver already initialized."); + for (i = 0; i < ARRAY_SIZE(winbond_spi_flash_table); i++) { params = &winbond_spi_flash_table[i]; if (params->id == ((idcode[1] << 8) | idcode[2]))