From patchwork Mon Jan 29 11:33:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 10189541 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 D09EF6020C for ; Mon, 29 Jan 2018 11:34:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B484F223A7 for ; Mon, 29 Jan 2018 11:34:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A91FB268AE; Mon, 29 Jan 2018 11:34:24 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42EE9223A7 for ; Mon, 29 Jan 2018 11:34:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751769AbeA2Ldf (ORCPT ); Mon, 29 Jan 2018 06:33:35 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:31891 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751569AbeA2Ldd (ORCPT ); Mon, 29 Jan 2018 06:33:33 -0500 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20180129113331epoutp046baf34a7482066ed4e2ac9e9847b50d7~ORKe-Z6Qv1860518605epoutp04X; Mon, 29 Jan 2018 11:33:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20180129113331epoutp046baf34a7482066ed4e2ac9e9847b50d7~ORKe-Z6Qv1860518605epoutp04X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1517225611; bh=zmhuenlQYD5PVayZ4sTWbs5b7KKNl/QCetyQfCQKBB8=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=twUxDlGaltyXlh1+NDkAmTfjLSUgRW9fYUXEXRkkYf6L28n89wdBYtkz5vgom43b1 tiPJ1+lH2S7ygQluK3/SrtVmULOhbMmKWC/OFgFWtfN+PT8PZXmMajDdGYEoXzZi8j 3SCy/hYiwGq61UhHiHmJjd38iYQ8sOeFl3YSsMto= Received: from epsmges2p2.samsung.com (unknown [182.195.40.64]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20180129113331epcas1p2602ce0544edbb04c10b07367b8d78bf0~ORKeiJmtO0772207722epcas1p2_; Mon, 29 Jan 2018 11:33:31 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id E2.C7.04137.B860F6A5; Mon, 29 Jan 2018 20:33:31 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20180129113331epcas2p1851ecb668e26bee1a09d162b4fe42225~ORKeWoMf10669506695epcas2p1k; Mon, 29 Jan 2018 11:33:31 +0000 (GMT) X-AuditID: b6c32a46-3c1ff70000001029-fc-5a6f068b0c87 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 0F.EC.03890.A860F6A5; Mon, 29 Jan 2018 20:33:30 +0900 (KST) Received: from gangnam.samsung ([10.113.77.200]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P3B00AJIERSSUA0@mmp2.samsung.com>; Mon, 29 Jan 2018 20:33:30 +0900 (KST) From: Andi Shyti To: Dmitry Torokhov , Simon Shields Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH 2/8] Input: mms114 - get read of custm i2c read/write functions Date: Mon, 29 Jan 2018 20:33:17 +0900 Message-id: <20180129113323.18961-3-andi.shyti@samsung.com> X-Mailer: git-send-email 2.15.1 In-reply-to: <20180129113323.18961-1-andi.shyti@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzVSe0hTURz27G53V2lxuWoeFqhdFHLoHtfHruWjyGygf6yyoGXaZV6cuIft bpJGsJmJLVCLqJSeahDL8oGpiQY+oEIJJdFEzAgx8YUpPigWbbv53/f7ne9xzuHDEKJRJMWK zDbWamaMJBok7BqKoeNuoxadcrVPQncPL4jopt2fAnqocRHQ0xvbIvpL7yOU7hydQY+hmqnm DUTzrmFWrKls7UA1NZ1uoNnsCNeKdGyKgWUKWGska9ZbCorMhalk1tn8E/mJSUpVnCqZVpOR ZsbEppIZ2dq4zCKj9wZkZCljtHtXWobjSEVaitVit7GRBgtnSyUvqlSUXKVUyymKkifEXzpC JXopl1nDWJ8TKWkIv7rW9VfgAG+gCwRiEE+A9aPvERcIwgi8B8Dl8QdCftgB8GH3FLrHqnZ9 F/MHbQB++rEs4IcNACenFwU+ForHwIqZXb8iBD8Pa1+98Psi+A0APWOVwAUwLBg/DRs85T6O EI+GlYtbfq0EPwr/vPX8T4uAdZ0VQh8OxFNgTf0I6vOBuBOFju01xOcD8Qz4ZJzg+cFw6UOn mMcH4YK7HfDYm9s1o+e1dQBu9PNhEI+HC89dfozg+2H1kEfMe0pgdRXBQw10tl/g4XHoeU3x z60FcP5rK6gD0mcgwA0OsCWcqZDlqBJKzjEmzm4ulOstpg7g74csswc0f84eBDgGyH2S9XNm HSFiSrky0yCAGEKGSL5d8a4kBUxZOWu15FvtRpYbBInen7mDSEP1Fm/bzLZ8VUKyMiEpiVIn 0d4yhEluajN0BF7I2Nhili1hrXs6ARYodQB37wqZN6urAkHrpoHSiadripxriqmdSkIc1i/b rAhcdiiztlRpTdn65bZY7epaT87wvckFZctwbvdKUZzod17dSPqvlqiB0UOrMLRRVhEdMK04 VVz6OHf+8K3Eky+XPhJ6akJdr1ZI51YYfZnzesRuLH3mLpceRdxPNczZSSFnYFQyxMox/wAa ImpRNQMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnluLIzCtJLcpLzFFi42I5/e+xoG4XW36UwduLVhbbjzxjtVj84zmT xeFFLxgtbn76xmpxedccNostZ26zObB5XF/yidlj56y77B4t6zexefRtWcXo8XmTXABrFJdN SmpOZllqkb5dAlfGhT2NzAWz5CrebfvH1MC4TqKLkZNDQsBEoqPrAXsXIxeHkMA6Rol9a1az gSSEBD4xSnxZKQZiswloSjTd/gEWFxEIk/i77zMjSAOzQDOjRPuBS2AJYQF/id6pDawgNouA qkTLi69MIDavgLXE761/2SC2yUtM2NLEAmJzCthI9M08DbXMWqLv6RuWCYw8CxgZVjFKphYU 56bnFhsVGOWllusVJ+YWl+al6yXn525iBAbPtsNa/TsYHy+JP8QowMGoxMP7ITQvSog1say4 MvcQowQHs5II771CoBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXFe/vxjkUIC6YklqdmpqQWpRTBZ Jg5OqQbGJv5TE7qmZx1+6HFdfhanb8UR/YCHgWrxoW/fv1VYtF3cVP+nwOmfHdtCOJdlTP5t xioiVHOUm+/PCsd/G5lOn+fhEPVrnMvb+Ct148To6fP2FE16t23W5pK/voqW3SyVLstMTwsL ftofLnT+SMWJI2tYYh3/y5wLrCvbwVs5Vy2fO2Ddtnc7lFiKMxINtZiLihMB0j7fmRoCAAA= X-CMS-MailID: 20180129113331epcas2p1851ecb668e26bee1a09d162b4fe42225 X-Msg-Generator: CA CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180129113331epcas2p1851ecb668e26bee1a09d162b4fe42225 X-RootMTR: 20180129113331epcas2p1851ecb668e26bee1a09d162b4fe42225 References: <20180129113323.18961-1-andi.shyti@samsung.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The 'mms114_read_reg' and 'mms114_write_reg' are used when reading or writing to the 'MMS114_MODE_CONTROL' register for updating the 'cache_mode_control' variable. Update the 'cache_mode_control' variable in the calling mms114_set_active() function and get rid of all the custom i2c read/write functions. With this remove also the redundant sleep of MMS114_I2C_DELAY (50us) between i2c operations. The waiting should to be handled by the i2c driver. Signed-off-by: Andi Shyti --- drivers/input/touchscreen/mms114.c | 87 +++++--------------------------------- 1 file changed, 10 insertions(+), 77 deletions(-) diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index 0b8b1f0e8ba6..94a97049d711 100644 --- a/drivers/input/touchscreen/mms114.c +++ b/drivers/input/touchscreen/mms114.c @@ -37,9 +37,6 @@ #define MMS152_FW_REV 0xE1 #define MMS152_COMPAT_GROUP 0xF2 -/* Minimum delay time is 50us between stop and start signal of i2c */ -#define MMS114_I2C_DELAY 50 - /* 200ms needs after power on */ #define MMS114_POWERON_DELAY 200 @@ -83,76 +80,6 @@ struct mms114_touch { u8 reserved[2]; } __packed; -static int __mms114_read_reg(struct mms114_data *data, unsigned int reg, - unsigned int len, u8 *val) -{ - struct i2c_client *client = data->client; - struct i2c_msg xfer[2]; - u8 buf = reg & 0xff; - int error; - - if (reg <= MMS114_MODE_CONTROL && reg + len > MMS114_MODE_CONTROL) - BUG(); - - /* Write register: use repeated start */ - xfer[0].addr = client->addr; - xfer[0].flags = I2C_M_TEN | I2C_M_NOSTART; - xfer[0].len = 1; - xfer[0].buf = &buf; - - /* Read data */ - xfer[1].addr = client->addr; - xfer[1].flags = I2C_M_RD; - xfer[1].len = len; - xfer[1].buf = val; - - error = i2c_transfer(client->adapter, xfer, 2); - if (error != 2) { - dev_err(&client->dev, - "%s: i2c transfer failed (%d)\n", __func__, error); - return error < 0 ? error : -EIO; - } - udelay(MMS114_I2C_DELAY); - - return 0; -} - -static int mms114_read_reg(struct mms114_data *data, unsigned int reg) -{ - u8 val; - int error; - - if (reg == MMS114_MODE_CONTROL) - return data->cache_mode_control; - - error = __mms114_read_reg(data, reg, 1, &val); - return error < 0 ? error : val; -} - -static int mms114_write_reg(struct mms114_data *data, unsigned int reg, - unsigned int val) -{ - struct i2c_client *client = data->client; - u8 buf[2]; - int error; - - buf[0] = reg & 0xff; - buf[1] = val & 0xff; - - error = i2c_master_send(client, buf, 2); - if (error != 2) { - dev_err(&client->dev, - "%s: i2c send failed (%d)\n", __func__, error); - return error < 0 ? error : -EIO; - } - udelay(MMS114_I2C_DELAY); - - if (reg == MMS114_MODE_CONTROL) - data->cache_mode_control = val; - - return 0; -} - static void mms114_process_mt(struct mms114_data *data, struct mms114_touch *touch) { struct i2c_client *client = data->client; @@ -231,19 +158,25 @@ static irqreturn_t mms114_interrupt(int irq, void *dev_id) static int mms114_set_active(struct mms114_data *data, bool active) { - int val; + int val, err; - val = mms114_read_reg(data, MMS114_MODE_CONTROL); + val = i2c_smbus_read_byte_data(data->client, MMS114_MODE_CONTROL); if (val < 0) return val; - val &= ~MMS114_OPERATION_MODE_MASK; + val = data->cache_mode_control &= ~MMS114_OPERATION_MODE_MASK; /* If active is false, sleep mode */ if (active) val |= MMS114_ACTIVE; - return mms114_write_reg(data, MMS114_MODE_CONTROL, val); + err = i2c_smbus_write_byte_data(data->client, MMS114_MODE_CONTROL, val); + if (err < 0) + return err; + + data->cache_mode_control = val; + + return 0; } static int mms114_get_version(struct mms114_data *data)