diff options
author | Wolfram Sang <wsa@the-dreams.de> | 2018-03-24 16:15:24 +0100 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2018-04-04 20:50:27 +0200 |
commit | 4d64ab27dca0bf5f3594b6f77f720a055b87f5f5 (patch) | |
tree | 7ce1aaf308fe7138304ba6a3ae68a0a91f2b2e97 | |
parent | 702804251c366bd4e4af8036984c7bde6bd268a8 (diff) | |
download | i2c-tools-4d64ab27dca0bf5f3594b6f77f720a055b87f5f5.tar.gz |
i2ctransfer: '-f' shouldn't allow all addresses, '-a' does that
We now have the flag '-a' for all i2c-tools to allow access for all
addresses. This was tied in i2ctransfer to the '-f' flag. Remove it and
keep that feature to '-a' only. This is also more in sync with the other
i2c-tools which use '-f' only to access already busy devices.
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Reviewed-by: Peter Rosin <peda@axentia.se>
-rw-r--r-- | tools/i2ctransfer.8 | 2 | ||||
-rw-r--r-- | tools/i2ctransfer.c | 23 |
2 files changed, 8 insertions, 17 deletions
diff --git a/tools/i2ctransfer.8 b/tools/i2ctransfer.8 index 99123fa..5d3cc27 100644 --- a/tools/i2ctransfer.8 +++ b/tools/i2ctransfer.8 @@ -41,7 +41,7 @@ This program helps you to create proper transfers for your needs. Force access to the device even if it is already busy. By default, .B i2ctransfer -will refuse to access addresses marked as reserved by the I2C standard or to a device which is already under the control of a kernel driver. +will refuse to access a device which is already under the control of a kernel driver. Using this flag is dangerous, it can seriously confuse the kernel driver in question. It can also cause .B i2ctransfer diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c index 8e9ce63..7b95d48 100644 --- a/tools/i2ctransfer.c +++ b/tools/i2ctransfer.c @@ -210,22 +210,13 @@ int main(int argc, char *argv[]) * the address here. */ - if (!force) { - address = parse_i2c_address(arg_ptr, all_addrs); - if (address < 0) - goto err_out_with_arg; - - /* Ensure address is not busy */ - if (set_slave_addr(file, address, 0)) - goto err_out_with_arg; - } else { - /* 'force' allows whole address range */ - address = strtol(arg_ptr, &end, 0); - if (arg_ptr == end || *end || address > 0x7f) { - fprintf(stderr, "Error: Invalid chip address\n"); - goto err_out_with_arg; - } - } + address = parse_i2c_address(arg_ptr, all_addrs); + if (address < 0) + goto err_out_with_arg; + + /* Ensure address is not busy */ + if (!force && set_slave_addr(file, address, 0)) + goto err_out_with_arg; } else { /* Reuse last address if possible */ if (address < 0) { |