diff options
author | Peter Marheine <pmarheine@chromium.org> | 2021-03-31 11:28:11 +1100 |
---|---|---|
committer | Angel Pons <th3fanbus@gmail.com> | 2021-05-02 16:30:51 +0000 |
commit | 0969e43b3fae48c90aaf1df284560f6b76f84efd (patch) | |
tree | f09e87b59c200988c378f45d8684857ffe9332cc /i2c_helper.h | |
parent | d4063bf3a7f5fd7831ee0321def13161976676d2 (diff) | |
download | flashrom-0969e43b3fae48c90aaf1df284560f6b76f84efd.tar.gz flashrom-0969e43b3fae48c90aaf1df284560f6b76f84efd.tar.bz2 flashrom-0969e43b3fae48c90aaf1df284560f6b76f84efd.zip |
lspcon_i2c_spi: support a devpath option
Some callers may find it easier to provide the path to an I2C device
at which to communicate with the device, rather than specify the bus
number- doing so might involve trying to parse a path to extract the
number only for flashrom to do the reverse, which is error-prone and
unnecessary.
This change adds support for a `devpath` option, continuing to
allow `bus` and requiring only one of them be specified.
TEST=Verified --flash-size outputs correct values with both
devpath=/dev/i2c-7 and bus=7, as well as noting that one is
required if neither is specified and only one may be specified
if both are given.
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Change-Id: Id2adf8a307b9205ce5e5804a6c3e22f19d0c34c9
Reviewed-on: https://review.coreboot.org/c/flashrom/+/51967
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'i2c_helper.h')
-rw-r--r-- | i2c_helper.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/i2c_helper.h b/i2c_helper.h index 599e08bb..cab2ce6f 100644 --- a/i2c_helper.h +++ b/i2c_helper.h @@ -72,6 +72,14 @@ static inline int i2c_buffer_t_fill(i2c_buffer_t *i2c_buf, void *buf, uint16_t l int i2c_open(int bus, uint16_t addr, int force); /** + * i2c_open_path: open an I2C device by device path + * + * This function behaves the same as i2c_open, but takes a filesystem + * path (assumed to be an I2C device file) instead of a bus number. + */ +int i2c_open_path(const char *path, uint16_t addr, int force); + +/** * i2c_close - closes the file descriptor returned by i2c_open * * @fd: file descriptor to be closed. |