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: 914231 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40m5g64tr4z9s0y for ; Wed, 16 May 2018 17:29:54 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=axentia.se Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=axentia.se header.i=@axentia.se header.b="GrM2+BDc"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40m5g637kbzF1Q2 for ; Wed, 16 May 2018 17:29:54 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=axentia.se Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=axentia.se header.i=@axentia.se header.b="GrM2+BDc"; dkim-atps=neutral X-Original-To: linux-aspeed@lists.ozlabs.org Delivered-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=axentia.se (client-ip=2a01:111:f400:fe09::71d; helo=eur03-ve1-obe.outbound.protection.outlook.com; envelope-from=peda@axentia.se; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=axentia.se Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=axentia.se header.i=@axentia.se header.b="GrM2+BDc"; dkim-atps=neutral Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03on071d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe09::71d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40m5Nl6KbFzDr3y; Wed, 16 May 2018 17:17:27 +1000 (AEST) 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; HE1PR0202MB2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yXMDvSktSuMn1Us/pLoA/ORp+z/TOnUBPeWfwSduYuAm7vqvnB4bEeprgxriPuaW40PLsx9/kt5hd5a+Z6qXHediqyFcp/sciwQQgwrPFjf58525ikRPVAcYN72isgekgJYYOzKQ+S4tpuXZUNxWr88c6n6feh9oZno=; 24:FZ+eOxiYUMHDx5YYUnok2+KtL6C3S6nJ6GV8CRPdBGHKprlc2qPBFyoCISFDTJNKzOGRwJZ8XSwReA9+Z4DFvqbkKtKcqKzDzz51IQ2Jgjw= SpamDiagnosticOutput: 1: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-Mailman-Approved-At: Wed, 16 May 2018 17:28:01 +1000 X-BeenThere: linux-aspeed@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux ASPEED SoC development 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 , Benjamin Herrenschmidt , Linus Walleij , Brendan Higgins , linux-arm-msm@vger.kernel.org, openbmc@lists.ozlabs.org, Wolfram Sang , Pengutronix Kernel Team , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Andy Gross , Peter Korsgaard , linuxppc-dev@lists.ozlabs.org, Peter Rosin , Guenter Roeck , linux-i2c@vger.kernel.org Errors-To: linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linux-aspeed" 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);