From patchwork Sat Mar 24 15:15:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 890461 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=the-dreams.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 407kVw0z1bz9s0W for ; Sun, 25 Mar 2018 02:15:36 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752394AbeCXPPe (ORCPT ); Sat, 24 Mar 2018 11:15:34 -0400 Received: from sauhun.de ([88.99.104.3]:41858 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752343AbeCXPPe (ORCPT ); Sat, 24 Mar 2018 11:15:34 -0400 Received: from localhost (p54B33AE5.dip0.t-ipconnect.de [84.179.58.229]) by pokefinder.org (Postfix) with ESMTPSA id 1CA4445B47A; Sat, 24 Mar 2018 16:15:33 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Cc: Jean Delvare , Peter Rosin , Romain Porte , Wolfram Sang Subject: [PATCH] i2ctransfer: '-f' shouldn't allow all addresses, '-a' does that Date: Sat, 24 Mar 2018 16:15:24 +0100 Message-Id: <20180324151524.7407-1-wsa@the-dreams.de> X-Mailer: git-send-email 2.11.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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 Reviewed-by: Peter Rosin --- 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) {