summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2020-04-17 14:10:55 +1000
committerEdward O'Callaghan <quasisec@chromium.org>2020-04-19 12:17:54 +0000
commita25c13cdb601f9d43b0f8edad96f9489efcb4b37 (patch)
treed747e1781d3d0367097cb6f9f0724534532962f8
parentaa4aa16554c2e9961147cabafc347fc22dbafdc0 (diff)
downloadflashrom-a25c13cdb601f9d43b0f8edad96f9489efcb4b37.tar.gz
flashrom-a25c13cdb601f9d43b0f8edad96f9489efcb4b37.tar.bz2
flashrom-a25c13cdb601f9d43b0f8edad96f9489efcb4b37.zip
lspcon_i2c_spi.c: Clean up some unnecessary indirection
Clean up some confusion of implicit copies by indirection. This allows the caller of register_spi_master() to have it's internal state in the expected way. Also add an error when the mpu reset fails on init. BUG=b:148746232,b:153027771,b:140394053 BRANCH=none TEST=builds Signed-off-by: Edward O'Callaghan <quasisec@google.com> Change-Id: I66ba4ffeb696309b8ad5b5ba58650630e8feefa9 Reviewed-on: https://review.coreboot.org/c/flashrom/+/40470 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
-rw-r--r--lspcon_i2c_spi.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/lspcon_i2c_spi.c b/lspcon_i2c_spi.c
index 4c8542644..1ee5f373f 100644
--- a/lspcon_i2c_spi.c
+++ b/lspcon_i2c_spi.c
@@ -406,7 +406,7 @@ static int lspcon_i2c_spi_write_aai(struct flashctx *flash, const uint8_t *buf,
return SPI_GENERIC_ERROR;
}
-static const struct spi_master spi_master_i2c_lspcon = {
+static struct spi_master spi_master_i2c_lspcon = {
.max_data_read = 16,
.max_data_write = 12,
.command = lspcon_i2c_spi_send_command,
@@ -468,14 +468,6 @@ get_bus_done:
return ret;
}
-static int register_lspcon_i2c_spi_master(void *ptr)
-{
- struct spi_master mst = spi_master_i2c_lspcon;
- mst.data = ptr;
-
- return register_spi_master(&mst);
-}
-
int lspcon_i2c_spi_init(void)
{
int lspcon_i2c_spi_bus = get_bus();
@@ -488,8 +480,10 @@ int lspcon_i2c_spi_init(void)
return fd;
ret |= lspcon_i2c_spi_reset_mpu_stop(fd);
- if (ret)
+ if (ret) {
+ msg_perr("%s: call to reset_mpu_stop failed.\n", __func__);
return ret;
+ }
struct lspcon_i2c_spi_data *data = calloc(1, sizeof(struct lspcon_i2c_spi_data));
if (!data) {
@@ -498,8 +492,10 @@ int lspcon_i2c_spi_init(void)
}
data->fd = fd;
+ spi_master_i2c_lspcon.data = data;
+
ret |= register_shutdown(lspcon_i2c_spi_shutdown, data);
- ret |= register_lspcon_i2c_spi_master(data);
+ ret |= register_spi_master(&spi_master_i2c_lspcon);
return ret;
}