Re: [PATCH] i2ctransfer: '-f' shouldn't allow all addresses, '-a' does that

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2018-03-24 16:15, Wolfram Sang wrote:
> 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@xxxxxxxxxxxxx>

Reviewed-by: Peter Rosin <peda@xxxxxxxxxx>

Cheers,
peda

> ---
>  tools/i2ctransfer.8 |  2 +-
>  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) {
> 




[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux