From patchwork Wed May 16 07:16:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 10402913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ED0C060155 for ; Wed, 16 May 2018 07:18:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6A092846D for ; Wed, 16 May 2018 07:18:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB027285D2; Wed, 16 May 2018 07:18:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 55FBE2846D for ; Wed, 16 May 2018 07:18:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dHRANvUndqs5p9ar7xIBwUOhJHuBmymfFSPU3b5wVv0=; b=JlYThF+L0nHqGG YbbA1JjkvSVHKyFyOTXYCi0DIn5DYGuYDZ9NplKmye+s6xaOWME78p5u/1Kh6nPIN8jkJKN7yJoCP oU9Ks6vqxcgmsdZBSiw5f89bCV0GE1kQ2omsSzacdYcbEcuQa1eUVJjDpLPhNGgwUev+91WDVl6jT jdlNiU4RdF4DrHTTyX37owC90AGFphPDN8mzTjrZ3wzftyC/Yn2GX37M2eTtTMP65liGJ4R+fV/OX Hk39J6pAZGLf+u4YTQJdosPsHK4b7Z+TUC5TGYIfIv03UuClWarn8Fg0DmtHTBTUiTCzBKiHkhLQ9 DgorIH0evXaDAYm8jwwQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fIqhV-0005M4-Vj; Wed, 16 May 2018 07:18:17 +0000 Received: from mail-eopbgr10114.outbound.protection.outlook.com ([40.107.1.114] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fIqgn-00050D-Am for linux-arm-kernel@lists.infradead.org; Wed, 16 May 2018 07:17:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NgKiiux1eWA0jfH0CDrtRBNi5u8lG4Mi4nmRIMfoel0=; b=GrM2+BDcqIYgwgJ34q3IaDT+NgAL7HCbxWG6qgJeEbQ8mKSzI56ljl7IBF4AoBpZjzaIttDOjSuBMefcuYHwSivNzpXI4CTYQiXBAWqreq6oU/GFsxinpz815ReENfGQYMSuNeuEbxIOlpwGdFXko32dJfACe7wsXq8SVFNfIzM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; Received: from orc.pedanet (85.226.244.23) by HE1PR0202MB2780.eurprd02.prod.outlook.com (2603:10a6:3:e8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Wed, 16 May 2018 07:17:19 +0000 From: Peter Rosin To: linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] i2c: algos: make use of i2c_8bit_addr_from_msg Date: Wed, 16 May 2018 09:16:46 +0200 Message-Id: <20180516071647.29277-2-peda@axentia.se> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180516071647.29277-1-peda@axentia.se> References: <20180516071647.29277-1-peda@axentia.se> MIME-Version: 1.0 X-Originating-IP: [85.226.244.23] X-ClientProxiedBy: HE1PR0102CA0028.eurprd01.prod.exchangelabs.com (2603:10a6:7:14::41) To HE1PR0202MB2780.eurprd02.prod.outlook.com (2603:10a6:3:e8::22) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(7021125)(5600026)(4534165)(7022125)(4603075)(4627221)(201702281549075)(7048125)(7024125)(7027125)(7028125)(7023125)(2017052603328)(7153060)(7193020); SRVR:HE1PR0202MB2780; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0202MB2780; 3:UxRDSy+ig9Phn5pqkNtrm4geIhdSJhKofNnzXEG2tkUwVWJTBdiuZ62eCxPzEOHXYsr+7t3ZkdmXnK5WnrTGarsj352a03lwNn825cshqyIO8AnlY1GCda5dIWnoAT0iQPMXept+6n227J9ZM9pk+/eJ9SAYDXfbHa72w8EvOdkCGxWPzSVbbpRMmKrg9LbCZk/X6Ycy85JfSrJl3n+Ge5RfiNbzPCBjFcRZQ/xFzJx/kYygMX3lv5hBCxsvT6qB; 25:a9+/u9EeKlHn/oq/rNbIxgQanG4AAL1KWIRcCjWf0ty16fu6Ye+kVo+STUr5TejXb8Xo+tMjTOR4CHhos/X4BUbY8vkOlNI8EJojYLv0SpGykPY48wFVuRnUiZEQp4JiPM4ohAaA82WyoMi5fmX03jabZ/qoONmFOeMqSxTxOL5vjR+WHHYRMOucDv/r+ua6t4T/AosBORp3/cs9WvejF3miaKBujxO9NwvNKpHi2ywuqLJaLgsAzPgVZBcIg5QtejpGLo4uTghAQ/blsfkeceFfNZOUGO+nhzyBpqR7jGXIOHvq4cr90aPHferMGXLOYrdwwP98ucc/V/82j+H8lw==; 31:rU3mXqz8rugoQkiXVVHhFuvI5SgKc7LgP2LEINOM+SJ6+vj5xGvVc7JunIdgXgdFgNIQzZ8NByWrKQKZqmL++cA2lflgzh/F2yTBq4nHrWC/mfTRfDr2tjs78ku3/MfUM7NznVNvwGB9di5BRCuvrRhNBFWlYx/JdrU76LS8A+sutqpJldvHPOAPWWHDj1+eM8tWqOBCra631ywWkMWPqQzOGQq4HmVmkSUgy9WOoDY= X-MS-TrafficTypeDiagnostic: HE1PR0202MB2780: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(149027)(150027)(6041310)(20161123562045)(20161123564045)(2016111802025)(20161123558120)(20161123560045)(6072148)(6043046)(201708071742011); SRVR:HE1PR0202MB2780; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0202MB2780; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0202MB2780; 4:6chxjFDa91/t5Hh+5uWvMoGI3jGUuF75r46DGxbTNXIfgwreGY4RgSKxnrxwgzX1ozDQ+o25wICOmM5QPvKALTYJ0+Mgqw7f6+2pYwHhpz0lDHWw/l7TOkRiCqqwt/m1vg2ar4uG/4IHJREzIPwPXY1afzxGX6kqaOV1RmgRnLnsLfgnEbBIGCHf6tRQacCgtF3XAu0bTlFtouRetbBxHJE/7ddD8Aw2S6H3kHOU9J2K5BDenvmPkiMlOb7q4+DOyZ3K3jEhBuk8saB80HBspA== X-Forefront-PRVS: 0674DC6DD3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(376002)(366004)(39830400003)(39380400002)(396003)(346002)(189003)(199004)(54906003)(76176011)(15760500003)(16586007)(316002)(68736007)(52116002)(6666003)(51416003)(6916009)(66066001)(47776003)(386003)(6506007)(81156014)(81166006)(305945005)(7416002)(5660300001)(7736002)(97736004)(50226002)(8676002)(25786009)(2351001)(2361001)(8936002)(36756003)(2906002)(53936002)(478600001)(6512007)(575784001)(16526019)(86362001)(106356001)(4326008)(186003)(26005)(11346002)(476003)(1076002)(486006)(6486002)(956004)(2616005)(50466002)(446003)(48376002)(6116002)(3846002)(74482002)(105586002)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0202MB2780; H:orc.pedanet; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0202MB2780; 23:X056sjrjIIZWYaDZLUa8Q+z2K9kt2uw29tSAMYg?= =?us-ascii?Q?6qxIAS1S5BX2yQnDkvZVTJlZkKS0FK3H2p9spSz94ftzJQU0blWkGl3wK7f9?= =?us-ascii?Q?vDCtaLko4/pMOZ3mTxM2DYYQ9iEgAJQpZmVCWnWZpFFjmv8xJ0t2mmR5mP+y?= =?us-ascii?Q?ZP/dafwaNdACae7hw8mnkPI0fLPOQ1m+6MxFBqcRjlhUKyTw4qXfPsxz0jbI?= =?us-ascii?Q?q9u+MJoNH956OvLngGuEJBH3kC82yee+QMnlmQpw2Are3t79MwOzV2AUjM0j?= =?us-ascii?Q?1Tu4mITEWKU9Czg68tsY9FopBMWyi+VuWjij7dlB2lV97hEpe92NRUZ4JEt+?= =?us-ascii?Q?ySYjlvfYvAqE0oGJud68eEuJ7940ZrLC5ufFbQe89Nov1kjunXjYZyP36toL?= =?us-ascii?Q?UE29Ck7yffXwDMhIgYIV2L7bVTummifUIj5uH6oZkPnVI7Oikkfnxm9Xlzdy?= =?us-ascii?Q?+0XvwWhGpe6W60GCgWyNTiFZ62wQWj4vB3E6WQ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:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0202MB2780; 7:hakthizG7BuJJigzvcRY8CEzZtZr+yVmAVDwzHmNfot0ahUTi9HpW29ItijCDnM6v/Q6fF7TJd/Zusx5p9YxSuZX1Y6sc8IS07xKGwPMzgqL1sL8Klz/RQtzlpDIuCcnOYScivMyo4GN3ffRxhGxgySIltHMS7vstMWdcQ/pesKtwia7fxS1Yk+ZsCcTR/K/RvyQZYmKTH7quIx2GSy8oxuQTLKaNbYW4bFbsTM+jCUBZ/IFxdbTYdyh2NDlluOr X-MS-Office365-Filtering-Correlation-Id: db99ebe0-a8a4-4b11-07e5-08d5bafd0fca X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2018 07:17:19.2184 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db99ebe0-a8a4-4b11-07e5-08d5bafd0fca X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0202MB2780 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180516_001733_383130_E20E414A X-CRM114-Status: GOOD ( 12.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-soc@vger.kernel.org, linux-aspeed@lists.ozlabs.org, David Brown , Andrew Jeffery , Benjamin Herrenschmidt , Linus Walleij , Brendan Higgins , linux-arm-msm@vger.kernel.org, openbmc@lists.ozlabs.org, Wolfram Sang , Joel Stanley , Pengutronix Kernel Team , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Andy Gross , Peter Korsgaard , linuxppc-dev@lists.ozlabs.org, Peter Rosin , Guenter Roeck , linux-i2c@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Because it looks neater. Signed-off-by: Peter Rosin --- drivers/i2c/algos/i2c-algo-bit.c | 4 +--- drivers/i2c/algos/i2c-algo-pca.c | 5 +---- drivers/i2c/algos/i2c-algo-pcf.c | 8 ++------ 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index 3df0efd69ae3..4a34f311e1ff 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c @@ -519,9 +519,7 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) } } } else { /* normal 7bit address */ - addr = msg->addr << 1; - if (flags & I2C_M_RD) - addr |= 1; + addr = i2c_8bit_addr_from_msg(msg); if (flags & I2C_M_REV_DIR_ADDR) addr ^= 1; ret = try_address(i2c_adap, addr, retries); diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index e370804ec8bc..883a290f6a4d 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c @@ -112,11 +112,8 @@ static int pca_address(struct i2c_algo_pca_data *adap, struct i2c_msg *msg) { int sta = pca_get_con(adap); - int addr; + int addr = i2c_8bit_addr_from_msg(msg); - addr = ((0x7f & msg->addr) << 1); - if (msg->flags & I2C_M_RD) - addr |= 1; DEB2("=== SLAVE ADDRESS %#04x+%c=%#04x\n", msg->addr, msg->flags & I2C_M_RD ? 'R' : 'W', addr); diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c index 270d84bfc2c6..5c29a4d397cf 100644 --- a/drivers/i2c/algos/i2c-algo-pcf.c +++ b/drivers/i2c/algos/i2c-algo-pcf.c @@ -291,13 +291,9 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf, static int pcf_doAddress(struct i2c_algo_pcf_data *adap, struct i2c_msg *msg) { - unsigned short flags = msg->flags; - unsigned char addr; + unsigned char addr = i2c_8bit_addr_from_msg(msg); - addr = msg->addr << 1; - if (flags & I2C_M_RD) - addr |= 1; - if (flags & I2C_M_REV_DIR_ADDR) + if (msg->flags & I2C_M_REV_DIR_ADDR) addr ^= 1; i2c_outb(adap, addr);