From patchwork Mon Jan 29 11:33:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 10189551 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 51B1D6020C for ; Mon, 29 Jan 2018 11:35:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3550927C2D for ; Mon, 29 Jan 2018 11:35:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28DC428178; Mon, 29 Jan 2018 11:35:18 +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 8EEE027C2D for ; Mon, 29 Jan 2018 11:35:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751640AbeA2Leg (ORCPT ); Mon, 29 Jan 2018 06:34:36 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:23002 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751591AbeA2Ldd (ORCPT ); Mon, 29 Jan 2018 06:33:33 -0500 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20180129113331epoutp01db75ab4bc3e07e16fbfaabe7d9b3e4df~ORKe_vAJX2962029620epoutp01i; Mon, 29 Jan 2018 11:33:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20180129113331epoutp01db75ab4bc3e07e16fbfaabe7d9b3e4df~ORKe_vAJX2962029620epoutp01i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1517225611; bh=CyfS9oVD3ysgRIeqmQvmWv0l4+91BHZC+090pYj/OPE=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=JNYv6aD0bKMHjzMpJQAdeKrwjlpT2F4OCdAW4tHusyh2Y7bYjwycc67Z4G1BxVzxf BaHCqCJa49Az9RMBDkPyqzRtL9scDFBrueHW01BDCc1cPE4zaQpLpsI3GirqR+27yd dgYUyjj25mztdQF6D+LjwJPX2qRpJ79T6OeTl1T0= Received: from epsmges2p4.samsung.com (unknown [182.195.40.65]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20180129113331epcas1p4e80207647b1d4adda7afcf06c0130060~ORKed8ImZ0845108451epcas1p4B; Mon, 29 Jan 2018 11:33:31 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 3A.D7.04080.B860F6A5; Mon, 29 Jan 2018 20:33:31 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20180129113330epcas2p436609515afc0c89504791908ae49059a~ORKeMghPm2424324243epcas2p4W; Mon, 29 Jan 2018 11:33:30 +0000 (GMT) X-AuditID: b6c32a48-9c5ff70000000ff0-a5-5a6f068b9689 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 9E.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 1/8] Input: mms114 - use smbus functions whenever possible Date: Mon, 29 Jan 2018 20:33:16 +0900 Message-id: <20180129113323.18961-2-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: H4sIAAAAAAAAAzWSbUhTURjHPd7t7k5aXeZLB4UaF6IUNrc5t2kaiiNGKQhhH2ZhFz04yb24 u0lGhajZWKWrLEhK0hRkA1+mORULmZKiYoKSmi8RiZkfQg1fqLS2Xfv2O8///z/neQ4PgQmb udFEkdGKLEa6mMLDOD1DsYni+7hJJ/VsEGrv8CpX/XrvW6h6qGkNqOe3drjq6f4XuLp7YgFP w7WzzVuYtq9+iaetavfg2ppuF9D+9JzI5upQih7RBcgiQsZ8U0GRsTCVungpLyMvUSmViWVJ ahUlMtIGlEppMrPF54uK/R1QolK62OYvZdMMQ8WfS7GYbFYk0psYayqVK5PJJTKpSiKXyyWK hKvJ8kS/5RrSu0ZHeObdmBs7i7ugHHRGOQCfgKQC1t9tAw4QRgjJXgA3vROhAUFI7gI40wod gAialp7xWE8HgH/e1HHYwxaAH+fXggGcjIUVC3t4gCPIy7DW3YIFTBhZCeD+VBUICOHkBej4 tc4JMIc8Bd0N3iALyLPQ++CAw7Z0Ejq7K4LMJ1NgzfNxPHARJO04HBz5wWNNGmh/3HMYCIfr I92H9Ri46uoELPtf7lnIZ8NOALfeboeyQgJcbXQEGSOPQvvQPo+dUwDt1ULWooXtbbNcltPh uG+My45cC+B45RTXCaJfgRAXiEJmxlCIGLlZIWFoA2MzFkryTQYPCG5InLYXDE5m+gBJAOqI YCPHqBNy6VKmzOADkMCoCMFyib8kKKDLbiKLKc9iK0aMDyT6P+cRFh2Zb/Lvm9GaJ1MkSRVK pVylVPvX4bigOlujE5KFtBVdR8iMLP9zoQQ/uhx0hBxY05/MePGSv+9tvWTpImZYEZ9uGH15 bPVW/KZLO2ge68pUuKcH9A0ZoHEjif4S0rI7mbz9mVOKL6c5QdZT/np/uLRO+TdSNIew1ri+ 1CbDwPeuOx+wspWskHvbtzVi3JNAXXnH/z2HD2vcXrsX9qpyY75+OvMwx11CcRg9LYvDLAz9 DzIoMeQ3AwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjluLIzCtJLcpLzFFi42I5/e+xoG4XW36UweYVxhbbjzxjtVj84zmT xeFFLxgtbn76xmpxedccNostZ26zObB5XF/yidlj56y77B4t6zexefRtWcXo8XmTXABrFJdN SmpOZllqkb5dAlfGqhPH2Qu+S1d8u/OdsYFxo1gXIweHhICJxN1p7F2MXBxCAusYJU6t+Mjc xcgJ5HxilPiyUgzEZhPQlGi6/YMNxBYRCJP4u+8zI0gDs0Azo0T7gUtgCWEBL4muX69YQGwW AVWJ1fO2g9m8AtYS23v+gdkSAvISE7Y0gdmcAjYSfTNPs0Ess5boe/qGZQIjzwJGhlWMkqkF xbnpucVGBUZ5qeV6xYm5xaV56XrJ+bmbGIGhs+2wVv8OxsdL4g8xCnAwKvHwfgjNixJiTSwr rsw9xCjBwawkwnuvECjEm5JYWZValB9fVJqTWnyIUZqDRUmclz//WKSQQHpiSWp2ampBahFM lomDU6qBsfbFDY/Zl2zCLvpqPCxZ7rZOU7Dgev0PM4f36Skezzi/SKdPNJrxtN7j08G0tKbf NZ/1Vtgv3rcj566jn+zF9xfexmrqCmi+WyS6x+Og/wYX5vWVDI8Yf2U+WL2TqeTm2aQFus5n yg8ttLN5tWrrpHbVr30ZM6U3fJh+dK/73MRNzOIviu5+qFRiKc5INNRiLipOBADfJOYZGQIA AA== X-CMS-MailID: 20180129113330epcas2p436609515afc0c89504791908ae49059a X-Msg-Generator: CA CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180129113330epcas2p436609515afc0c89504791908ae49059a X-RootMTR: 20180129113330epcas2p436609515afc0c89504791908ae49059a 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 exchange of data to and from the mms114 touchscreen never exceeds 256 bytes. In the worst case it goes up to 80 bytes in the interrupt handler while reading the events. Thus it's not needed to make use of custom read/write functions for accessing the i2c. Replace, whenever possible, the use of custom functions with the more standard smbus ones. It's not possible only in one case, in the mms114_set_active() function where the 'cache_mode_control' variable is updated according to the value in the register 'MMS114_MODE_CONTROL' register. Signed-off-by: Andi Shyti --- drivers/input/touchscreen/mms114.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index c54f4afe1103..0b8b1f0e8ba6 100644 --- a/drivers/input/touchscreen/mms114.c +++ b/drivers/input/touchscreen/mms114.c @@ -207,14 +207,15 @@ static irqreturn_t mms114_interrupt(int irq, void *dev_id) } mutex_unlock(&input_dev->mutex); - packet_size = mms114_read_reg(data, MMS114_PACKET_SIZE); + packet_size = i2c_smbus_read_byte_data(data->client, + MMS114_PACKET_SIZE); if (packet_size <= 0) goto out; touch_size = packet_size / MMS114_PACKET_NUM; - error = __mms114_read_reg(data, MMS114_INFOMATION, packet_size, - (u8 *)touch); + error = i2c_smbus_read_i2c_block_data(data->client, MMS114_INFOMATION, + packet_size, (u8 *)touch); if (error < 0) goto out; @@ -254,7 +255,8 @@ static int mms114_get_version(struct mms114_data *data) switch (data->type) { case TYPE_MMS152: - error = __mms114_read_reg(data, MMS152_FW_REV, 3, buf); + error = i2c_smbus_read_i2c_block_data(data->client, + MMS152_FW_REV, 3, buf); if (error) return error; @@ -268,7 +270,8 @@ static int mms114_get_version(struct mms114_data *data) break; case TYPE_MMS114: - error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf); + error = i2c_smbus_read_i2c_block_data(data->client, + MMS114_TSP_REV, 6, buf); if (error) return error; @@ -300,30 +303,35 @@ static int mms114_setup_regs(struct mms114_data *data) val = (props->max_x >> 8) & 0xf; val |= ((props->max_y >> 8) & 0xf) << 4; - error = mms114_write_reg(data, MMS114_XY_RESOLUTION_H, val); + error = i2c_smbus_write_byte_data(data->client, + MMS114_XY_RESOLUTION_H, val); if (error < 0) return error; val = props->max_x & 0xff; - error = mms114_write_reg(data, MMS114_X_RESOLUTION, val); + error = i2c_smbus_write_byte_data(data->client, + MMS114_X_RESOLUTION, val); if (error < 0) return error; val = props->max_x & 0xff; - error = mms114_write_reg(data, MMS114_Y_RESOLUTION, val); + error = i2c_smbus_write_byte_data(data->client, + MMS114_Y_RESOLUTION, val); if (error < 0) return error; if (data->contact_threshold) { - error = mms114_write_reg(data, MMS114_CONTACT_THRESHOLD, - data->contact_threshold); + error = i2c_smbus_write_byte_data(data->client, + MMS114_CONTACT_THRESHOLD, + data->contact_threshold); if (error < 0) return error; } if (data->moving_threshold) { - error = mms114_write_reg(data, MMS114_MOVING_THRESHOLD, - data->moving_threshold); + error = i2c_smbus_write_byte_data(data->client, + MMS114_MOVING_THRESHOLD, + data->moving_threshold); if (error < 0) return error; }