summaryrefslogtreecommitdiffstats
path: root/realtek_mst_i2c_spi.c
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2021-05-02 19:03:58 +0200
committerEdward O'Callaghan <quasisec@chromium.org>2021-05-09 03:34:17 +0000
commitb81dbc5233c89f35b51dc763d531a337d4237a8f (patch)
treef9b3dcf9334583cb989c05a0f5b757b1da4120f7 /realtek_mst_i2c_spi.c
parentdb23295f8d2a1ecc08f279c3f295558cc55fbeb5 (diff)
downloadflashrom-b81dbc5233c89f35b51dc763d531a337d4237a8f.tar.gz
flashrom-b81dbc5233c89f35b51dc763d531a337d4237a8f.tar.bz2
flashrom-b81dbc5233c89f35b51dc763d531a337d4237a8f.zip
realtek_mst_i2c_spi: Use `i2c_open_from_programmer_params`
This allows using `buspath` to specify which I2C device to use. Change-Id: Ibdf07a9fde0ddfcda1c0bfa35a3e7cde5c22cedb Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/52831 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'realtek_mst_i2c_spi.c')
-rw-r--r--realtek_mst_i2c_spi.c41
1 files changed, 5 insertions, 36 deletions
diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c
index 27bcb4a00..64579e1de 100644
--- a/realtek_mst_i2c_spi.c
+++ b/realtek_mst_i2c_spi.c
@@ -442,38 +442,11 @@ static int realtek_mst_i2c_spi_shutdown(void *data)
return ret;
}
-static int get_params(int *i2c_bus, int *reset, int *enter_isp)
+static int get_params(int *reset, int *enter_isp)
{
- char *bus_str = NULL, *reset_str = NULL, *isp_str = NULL;
+ char *reset_str = NULL, *isp_str = NULL;
int ret = SPI_GENERIC_ERROR;
- bus_str = extract_programmer_param("bus");
- if (bus_str) {
- char *bus_suffix;
- errno = 0;
- int bus = (int)strtol(bus_str, &bus_suffix, 10);
- if (errno != 0 || bus_str == bus_suffix) {
- msg_perr("%s: Could not convert 'bus'.\n", __func__);
- goto _get_params_failed;
- }
-
- if (bus < 0 || bus > 255) {
- msg_perr("%s: Value for 'bus' is out of range(0-255).\n", __func__);
- goto _get_params_failed;
- }
-
- if (strlen(bus_suffix) > 0) {
- msg_perr("%s: Garbage following 'bus' value.\n", __func__);
- goto _get_params_failed;
- }
-
- msg_pinfo("Using i2c bus %i.\n", bus);
- *i2c_bus = bus;
- ret = 0;
- } else {
- msg_perr("%s: Bus number not specified.\n", __func__);
- }
-
reset_str = extract_programmer_param("reset-mcu");
if (reset_str) {
if (reset_str[0] == '1') {
@@ -504,22 +477,18 @@ static int get_params(int *i2c_bus, int *reset, int *enter_isp)
}
free(isp_str);
-_get_params_failed:
- if (bus_str)
- free(bus_str);
-
return ret;
}
int realtek_mst_i2c_spi_init(void)
{
int ret = 0;
- int i2c_bus = 0, reset = 0, enter_isp = 0;
+ int reset = 0, enter_isp = 0;
- if (get_params(&i2c_bus, &reset, &enter_isp))
+ if (get_params(&reset, &enter_isp))
return SPI_GENERIC_ERROR;
- int fd = i2c_open(i2c_bus, REGISTER_ADDRESS, 0);
+ int fd = i2c_open_from_programmer_params(REGISTER_ADDRESS, 0);
if (fd < 0)
return fd;