From patchwork Fri Oct 25 00:25:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Duggan X-Patchwork-Id: 11211175 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27C7F13B1 for ; Fri, 25 Oct 2019 00:26:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F060021929 for ; Fri, 25 Oct 2019 00:26:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Synaptics.onmicrosoft.com header.i=@Synaptics.onmicrosoft.com header.b="lRKkkhzy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728483AbfJYA0B (ORCPT ); Thu, 24 Oct 2019 20:26:01 -0400 Received: from mail-eopbgr720082.outbound.protection.outlook.com ([40.107.72.82]:9893 "EHLO NAM05-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727629AbfJYA0B (ORCPT ); Thu, 24 Oct 2019 20:26:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yuvi79xyBESj1R7xJ5NjsghRlYfbq+oA49BWJPIA4AMb0fNZCBJNqhghTVYcynDT7nUoa2I+PLThxzqsXtOfKPtgvprCF8AFl1NsdJ3j+Tbn1O85pNIR78qe0MbN3hBH6uO2nAnx7+hlXL6BGShzTzx3u6y4JAKGed8risPFXZyQ6VF8M2SJr2eFQrkiCNjvrcNzVTT2ZpAaQqF87EEZrA/PiLpX2yzpId67iDqXftyb8QMB8JFOax+6gLMgpBHcHFx/9+sTswJ/zkPedrsmQUw7OJ+boVlh0MaVV9UOFjRXPD0KiAIqOHis7gxxX+7vvhMWEdSFbBcswYiovB/F0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0eKl2TRohBcSM/cvcy/Gt7QXa/i3KF/x2n7qiSve+rI=; b=lH78hteL+WeW1IRBrLO90UCzSO2lWWsQ+EaOFb/Up46RYroJUgUTpMXWm1SGcTRo2Ixq5rrUoTQSblgL+z/1n3P3FYpiRQIPFUwwMyaJSyOwcoI4WGrAUVsCS8chLcxdk2XiBRKc5igQvfqC4pveot55T7FzpR5PvVYgDAgiNietajPh7Ivi7AtOb+D+ISqNXh3f5UEyviUP+D0a8rbcjbcfmb7F77faSVAkyWodilw1YnRYm4opNJQn5LQS2aGCHnQPTl/dMkvXlSWCKqrta/BncD2Ky+ncu1HwjVyhwVNdjQWFyWwZB5dXFNwBSmI5x+MGJUWuplDrijTs5wErUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0eKl2TRohBcSM/cvcy/Gt7QXa/i3KF/x2n7qiSve+rI=; b=lRKkkhzyrsBkrx6qjcYl8Z0OtJWkdmgD2IwcXmeTaiyGCzsmzu0n9uJM9b81DeVvDUvotcY1Le2f605sF1NSyFhlkPQ5kyEt7RUgQHVaILs+YaNrLN+FgNDKlCX1a+jdKCghQmUM8wA9Mm1gLN4fyeEjcshBG6WI9Z1/ougsdmk= Received: from BYAPR03MB4135.namprd03.prod.outlook.com (20.177.127.85) by BYAPR03MB4885.namprd03.prod.outlook.com (20.179.92.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.23; Fri, 25 Oct 2019 00:25:58 +0000 Received: from BYAPR03MB4135.namprd03.prod.outlook.com ([fe80::d168:6b9a:e289:e124]) by BYAPR03MB4135.namprd03.prod.outlook.com ([fe80::d168:6b9a:e289:e124%4]) with mapi id 15.20.2347.029; Fri, 25 Oct 2019 00:25:57 +0000 From: Andrew Duggan To: "linux-input@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Andrew Duggan , Dmitry Torokhov , Benjamin Tissoires , Christopher Heiny , Simon Wood , Nick Dyer Subject: [PATCH 1/3] Input: synaptics-rmi4 - disable the relative position IRQ in the F12 driver Thread-Topic: [PATCH 1/3] Input: synaptics-rmi4 - disable the relative position IRQ in the F12 driver Thread-Index: AQHVisrE0vTfWVJQc0GvTvForKD/KQ== Date: Fri, 25 Oct 2019 00:25:56 +0000 Message-ID: <20191025002527.3189-2-aduggan@synaptics.com> References: <20191025002527.3189-1-aduggan@synaptics.com> In-Reply-To: <20191025002527.3189-1-aduggan@synaptics.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.147.44.15] x-clientproxiedby: BYAPR07CA0051.namprd07.prod.outlook.com (2603:10b6:a03:60::28) To BYAPR03MB4135.namprd03.prod.outlook.com (2603:10b6:a03:77::21) authentication-results: spf=none (sender IP is ) smtp.mailfrom=aduggan@synaptics.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 774dab67-b8c1-492b-b0e4-08d758e1e713 x-ms-traffictypediagnostic: BYAPR03MB4885: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 02015246A9 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(346002)(366004)(39860400002)(376002)(396003)(199004)(189003)(6436002)(52116002)(81156014)(2501003)(81166006)(26005)(110136005)(66556008)(8936002)(386003)(36756003)(66476007)(66946007)(2906002)(6506007)(99286004)(102836004)(6512007)(8676002)(186003)(66446008)(86362001)(50226002)(64756008)(54906003)(76176011)(25786009)(316002)(478600001)(6486002)(6306002)(3846002)(6116002)(1076003)(256004)(5660300002)(11346002)(446003)(71190400001)(966005)(7736002)(2616005)(305945005)(486006)(476003)(66066001)(14454004)(71200400001)(4326008);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR03MB4885;H:BYAPR03MB4135.namprd03.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:0;MX:1; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: eMo5PXKnB2pW/M/MMssFj1ltWXcD4YegsO+auJpt+n4pRO4i3o9lekKuMZSnYDI7S0q11jQNCRCr87sx/Qh7rUVE8EThoPDsaVqZvGBXB7gTLfA691wTTRPvrhvnQAk+/ZR2fn7rN7Ue+d9KjtbRsURp1PnB3BUplgbEGArGcbXkNEwjKawRYLVQleOPFd6/DreWUI6So6e8myD+mbphRnViyo6tjn8HgLT0K7jtXBt879OTTrZ9ZmMPKuVlqsdXZWWNCFAxwMOWs/JE7uy8v11ZGo/vGCuGijZvW2bhWyiCS/vzGguYfVJ4QpgHPB5EY/vKOrvxJujvqy8tIf/IiGp2ArCMCYpkp9t8bREZQYXgw6negtiMN6Z8Oc9Azz9WLH3glzPFpo+X9lXflf/kTBhBvskBmnQD4PlyOsKGSmbv/ST3GpnnR1tcHpuNeNY8h+GBp9wBMfon1PgW6kK90c7lvYmgunF1mm0u4r/y7Eo= MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 774dab67-b8c1-492b-b0e4-08d758e1e713 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2019 00:25:56.8375 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mf4v7QPbKjt/Y0jWInSSHBBHSfafJl0EnRHviI7EEszVScnS5kPhBEhQB/q0hOzZQql4lDCN3czYmxgOOhtUPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4885 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This patch fixes an issue seen on HID touchpads which report finger positions using RMI4 Function 12. The issue manifests itself as spurious button presses as described in: https://www.spinics.net/lists/linux-input/msg58618.html Commit 24d28e4f1271 ("Input: synaptics-rmi4 - convert irq distribution to irq_domain") switched the RMI4 driver to using an irq_domain to handle RMI4 function interrupts. Functions with more then one interrupt now have each interrupt mapped to their own IRQ and IRQ handler. The result of this change is that the F12 IRQ handler was now getting called twice. Once for the absolute data interrupt and once for the relative data interrupt. For HID devices, calling rmi_f12_attention() a second time causes the attn_data data pointer and size to be set incorrectly. When the touchpad button is pressed, F30 will generate an interrupt and attempt to read the F30 data from the invalid attn_data data pointer and report incorrect button events. This patch disables the F12 relative interrupt which prevents rmi_f12_attention() from being called twice. Signed-off-by: Andrew Duggan Reported-by: Simon Wood --- drivers/input/rmi4/rmi_f12.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/input/rmi4/rmi_f12.c b/drivers/input/rmi4/rmi_f12.c index d20a5d6780d1..734077f2c40b 100644 --- a/drivers/input/rmi4/rmi_f12.c +++ b/drivers/input/rmi4/rmi_f12.c @@ -55,6 +55,9 @@ struct f12_data { const struct rmi_register_desc_item *data15; u16 data15_offset; + + unsigned long *abs_mask; + unsigned long *rel_mask; }; static int rmi_f12_read_sensor_tuning(struct f12_data *f12) @@ -291,9 +294,18 @@ static int rmi_f12_write_control_regs(struct rmi_function *fn) static int rmi_f12_config(struct rmi_function *fn) { struct rmi_driver *drv = fn->rmi_dev->driver; + struct f12_data *f12 = dev_get_drvdata(&fn->dev); + struct rmi_2d_sensor *sensor; int ret; - drv->set_irq_bits(fn->rmi_dev, fn->irq_mask); + sensor = &f12->sensor; + + if (!sensor->report_abs) + drv->clear_irq_bits(fn->rmi_dev, f12->abs_mask); + else + drv->set_irq_bits(fn->rmi_dev, f12->abs_mask); + + drv->clear_irq_bits(fn->rmi_dev, f12->rel_mask); ret = rmi_f12_write_control_regs(fn); if (ret) @@ -315,9 +327,12 @@ static int rmi_f12_probe(struct rmi_function *fn) struct rmi_device_platform_data *pdata = rmi_get_platform_data(rmi_dev); struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); u16 data_offset = 0; + int mask_size; rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s\n", __func__); + mask_size = BITS_TO_LONGS(drvdata->irq_count) * sizeof(unsigned long); + ret = rmi_read(fn->rmi_dev, query_addr, &buf); if (ret < 0) { dev_err(&fn->dev, "Failed to read general info register: %d\n", @@ -332,10 +347,19 @@ static int rmi_f12_probe(struct rmi_function *fn) return -ENODEV; } - f12 = devm_kzalloc(&fn->dev, sizeof(struct f12_data), GFP_KERNEL); + f12 = devm_kzalloc(&fn->dev, sizeof(struct f12_data) + mask_size * 2, + GFP_KERNEL); if (!f12) return -ENOMEM; + f12->abs_mask = (unsigned long *)((char *)f12 + + sizeof(struct f12_data)); + f12->rel_mask = (unsigned long *)((char *)f12 + + sizeof(struct f12_data) + mask_size); + + set_bit(fn->irq_pos, f12->abs_mask); + set_bit(fn->irq_pos + 1, f12->rel_mask); + f12->has_dribble = !!(buf & BIT(3)); if (fn->dev.of_node) { From patchwork Fri Oct 25 00:25:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Duggan X-Patchwork-Id: 11211171 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7206112C for ; Fri, 25 Oct 2019 00:26:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9AEC421D81 for ; Fri, 25 Oct 2019 00:26:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Synaptics.onmicrosoft.com header.i=@Synaptics.onmicrosoft.com header.b="gZy+binR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729067AbfJYA0C (ORCPT ); Thu, 24 Oct 2019 20:26:02 -0400 Received: from mail-eopbgr720082.outbound.protection.outlook.com ([40.107.72.82]:9893 "EHLO NAM05-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727208AbfJYA0C (ORCPT ); Thu, 24 Oct 2019 20:26:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k5duDluDRnXn8b8mioS6+r4JJ5Q3QCGtv+o22N/5PhoVxPyPDK75L4DLVpIZBfjLJQ88yndXxJKKzj8RCp23aHE9B887GqX16v+1c8VCel22TmafmTpzl/YZ3ILrw0+u+n6p9zrY19aFh0QBqJw5q/4Rw0rf3bzOz3JNxzv2/DOZ8Qh7RaQ94jcJtgdQ8WH5Qg7zTvJssR2RmlPWf8UOqExZwwTUQK51FtA34AVu/OZ7mNrvShJ16ZlVYWsXcKMT1qrpVU2FKMpnCi18FTBYE0IobzjTx/9/Q/DAUUIFTXKTR+HLxAwQV2gkVQIvfT9bauO8SmCc56RffyZ4VRcP5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RL9uikq6IQrdG0QWvzWXG8YBdygq+//QeWGqO4YA39g=; b=UokJFOahDpB84XsoQvW6E39NQeCxDtao5CF+E6syN4JCM8IzCulfPIHITgsHy/6sqHpr7Z7AJG3+4RaqPn/gfM6G0DaY/7E0Mrzso/nCzQH6u6PlZs/Xzk/K1z2uzCIYjP6lnj60F5VFiSvT/q8elJ86kWclerNggityoxHx7yPqt1bY5CjF34qTR2Xpg2iIPcb+kNEp5cvFW1O/Oz6SxcIWZ1Hmiu5QcBXouDEVVed6xsLgnNqpA5oTn7dhtYbLRfYijn1sBJ/Xar/fhDpMwTK+eTr7M1SH0xIJazkm/OCp6xI+9hPERN1Aie4D4b4m7znwgVmdhRvnPjc5NWlTTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RL9uikq6IQrdG0QWvzWXG8YBdygq+//QeWGqO4YA39g=; b=gZy+binRZHcya5qwDrreUnwOuKVDRkVl+7cyd5ou+FAR+K0oHCw/se/vqhCtg80rfRl1nqShlWAs2fOX7/tIzKglheO3XE0LMSGDpd42wOPWNdoLehLeh5g2KQKj2JubKYOkurQmD9XIG63bSAVlIbT5P8KS9fisXEZlQLhq05Y= Received: from BYAPR03MB4135.namprd03.prod.outlook.com (20.177.127.85) by BYAPR03MB4885.namprd03.prod.outlook.com (20.179.92.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.23; Fri, 25 Oct 2019 00:25:59 +0000 Received: from BYAPR03MB4135.namprd03.prod.outlook.com ([fe80::d168:6b9a:e289:e124]) by BYAPR03MB4135.namprd03.prod.outlook.com ([fe80::d168:6b9a:e289:e124%4]) with mapi id 15.20.2347.029; Fri, 25 Oct 2019 00:25:59 +0000 From: Andrew Duggan To: "linux-input@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Andrew Duggan , Dmitry Torokhov , Benjamin Tissoires , Christopher Heiny , Simon Wood , Nick Dyer Subject: [PATCH 2/3] Input: synaptics-rmi4 - use the number of valid bytes read when updating the attn_data fields in F11 and F12 Thread-Topic: [PATCH 2/3] Input: synaptics-rmi4 - use the number of valid bytes read when updating the attn_data fields in F11 and F12 Thread-Index: AQHVisrGYuZ2map7AUGC9fcxnMF35w== Date: Fri, 25 Oct 2019 00:25:58 +0000 Message-ID: <20191025002527.3189-3-aduggan@synaptics.com> References: <20191025002527.3189-1-aduggan@synaptics.com> In-Reply-To: <20191025002527.3189-1-aduggan@synaptics.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.147.44.15] x-clientproxiedby: BYAPR07CA0051.namprd07.prod.outlook.com (2603:10b6:a03:60::28) To BYAPR03MB4135.namprd03.prod.outlook.com (2603:10b6:a03:77::21) authentication-results: spf=none (sender IP is ) smtp.mailfrom=aduggan@synaptics.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4fe28b19-01a0-4786-7435-08d758e1e869 x-ms-traffictypediagnostic: BYAPR03MB4885: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-forefront-prvs: 02015246A9 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(346002)(366004)(39860400002)(376002)(396003)(199004)(189003)(6436002)(52116002)(81156014)(2501003)(81166006)(26005)(110136005)(66556008)(8936002)(386003)(36756003)(66476007)(66946007)(2906002)(6506007)(99286004)(102836004)(6512007)(8676002)(186003)(66446008)(86362001)(50226002)(64756008)(54906003)(76176011)(25786009)(316002)(478600001)(6486002)(3846002)(6116002)(14444005)(1076003)(256004)(5660300002)(11346002)(446003)(71190400001)(7736002)(2616005)(305945005)(486006)(476003)(66066001)(14454004)(71200400001)(4326008);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR03MB4885;H:BYAPR03MB4135.namprd03.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:0;MX:1; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: uuqr36t/dr2Vz9mIbjSi0HFhWDzY3U9ZWeoJYZyJFh6Js/jyuuYUp+LjVhf2G1o5PwBBUjF3ihg/e4+fJGUTlOaOpvYCo2ugtzREDiNjl/yOwBYw2ueTtiC3HQUemE2xHw5jRkGtXO2SidUZZw9o+S7UiBfFki98wYQV9vQ0J1BTdKp4ful4QEcysuxeT0J78A5MDZCzq/coc5iv2wYag7Owzk6/bicJZVGnxOBLnwKCg5RRtIYMGeWQoZ6p+8p4STcZjlozfS0QOH4mF60ZEDiM5HiAzTQiW+Fnqnt/B9qNo26Pt2ts5sFTzVJP1CUbVzI3g/WUpGr4jTNoK5RTn8tuIODD3I5P5vRsT0bZTJ/4gFt9cXfNcMeX0Wr9UIN9ys7dWQjOYHzOoTmEg8sRuJGHo5dPJFmJH6gqBIjTniMbE2HKkmUk1CSxT6RZwQFV MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4fe28b19-01a0-4786-7435-08d758e1e869 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2019 00:25:58.9423 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: xGc+4CTL7O6ik2BuUUXAohxEiVeGX0ZirqRsul/2EXJV+5VC9Ye8FcTwZtgmmAGZ2uCrnz8I4WAxemM8ZRoR8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4885 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Currently, rmi_f11_attention() and rmi_f12_attention() functions update the attn_data data pointer and size based on the size of the expected size of the attention data. However, if the actual valid data in the attn buffer is less then the expected value then the updated data pointer will point to memory beyond the end of the attn buffer. Using the calculated valid_bytes instead will prevent this from happening. Signed-off-by: Andrew Duggan --- drivers/input/rmi4/rmi_f11.c | 4 ++-- drivers/input/rmi4/rmi_f12.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c index f28a7158b2ef..26c239325f95 100644 --- a/drivers/input/rmi4/rmi_f11.c +++ b/drivers/input/rmi4/rmi_f11.c @@ -1284,8 +1284,8 @@ static irqreturn_t rmi_f11_attention(int irq, void *ctx) valid_bytes = f11->sensor.attn_size; memcpy(f11->sensor.data_pkt, drvdata->attn_data.data, valid_bytes); - drvdata->attn_data.data += f11->sensor.attn_size; - drvdata->attn_data.size -= f11->sensor.attn_size; + drvdata->attn_data.data += valid_bytes; + drvdata->attn_data.size -= valid_bytes; } else { error = rmi_read_block(rmi_dev, data_base_addr, f11->sensor.data_pkt, diff --git a/drivers/input/rmi4/rmi_f12.c b/drivers/input/rmi4/rmi_f12.c index 734077f2c40b..7e97944f7616 100644 --- a/drivers/input/rmi4/rmi_f12.c +++ b/drivers/input/rmi4/rmi_f12.c @@ -212,8 +212,8 @@ static irqreturn_t rmi_f12_attention(int irq, void *ctx) valid_bytes = sensor->attn_size; memcpy(sensor->data_pkt, drvdata->attn_data.data, valid_bytes); - drvdata->attn_data.data += sensor->attn_size; - drvdata->attn_data.size -= sensor->attn_size; + drvdata->attn_data.data += valid_bytes; + drvdata->attn_data.size -= valid_bytes; } else { retval = rmi_read_block(rmi_dev, f12->data_addr, sensor->data_pkt, sensor->pkt_size); From patchwork Fri Oct 25 00:26:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Duggan X-Patchwork-Id: 11211173 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76BAA13B1 for ; Fri, 25 Oct 2019 00:26:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A19721929 for ; Fri, 25 Oct 2019 00:26:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Synaptics.onmicrosoft.com header.i=@Synaptics.onmicrosoft.com header.b="Du+lHpQx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727208AbfJYA0H (ORCPT ); Thu, 24 Oct 2019 20:26:07 -0400 Received: from mail-eopbgr720082.outbound.protection.outlook.com ([40.107.72.82]:9893 "EHLO NAM05-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728974AbfJYA0H (ORCPT ); Thu, 24 Oct 2019 20:26:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XmaVFjwc50K41Am+sWMst+WRFGpGVz9Luoh/jic4FY1VAIgMo96n9sMOKTy34maphMdv19WHXauCxoJSwEk8xM/nCfTEq3hn1Qm1rk5BHclfjyRT8GS6HeGhOPdKOcx5bda3reSc9frSuP9jcvl1O3JzdiMzjR/NadocGxtDr+ugLDqG4Sx7pdmrC991haqNTqKKBmKtSQUHDiidQw7siDfGAJRgaintxOlGC5BDqxH6kf7DiN5Co+GnBFYtQ12RIeTeJcXvsPzV4FrqF6PZkeOj0auSFloKKw6HlKjD/KxOeDVR5p5QOLQKhSs870iq7tYAHth7Rq8IH57If0c+kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dfff4yOH061+CW62Q5/udySjEm4p9yEfJG5pf6tkhnA=; b=ixwK5AYlcaRW3OBu7Tj0y3cwCO95cH5Q4DhKxLy2K/oNs5peMmyCwFzxYM+WAWaGK60+C3K9uQEPF7AqESMzEZL2qRWhB4qhZK0N2lpeUezLmwYjhEMCtN2INv75ai3AD3w/IeZiI0lB4IcawR00DfBBpTRLM6K7+PxQLpQtlttU+8S6j5YiEJ17rHpJpPmM6aVsZo3i4wOsWU4PCa/+dcESVKyujJmq7eoFkUFj+FT20bhmN+EiH7SM1d8fbqghyZDE9GvRR0Qxz14tw+qNXJnpmm6iXG5zBp4mgpMz7deMRXrYUkcP8aB2jbXbjfYo8ElOxHU/rYDdU2Rd0Ny3YA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dfff4yOH061+CW62Q5/udySjEm4p9yEfJG5pf6tkhnA=; b=Du+lHpQx/VkZysgfGX3rIccIRMEt42Xi7tGucDUzamTrPiMc2/BC9ShFT3unhM/q3VthMTAypGzvj8R7ZTEsfggsaLZyqCxhnFJ3scaBrrhsNYwAKgMqz/D8Tx9Rq4K+14WJijjDekPBL0qF9XjkXr5wnt/apxprIFT6be/zDzI= Received: from BYAPR03MB4135.namprd03.prod.outlook.com (20.177.127.85) by BYAPR03MB4885.namprd03.prod.outlook.com (20.179.92.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.23; Fri, 25 Oct 2019 00:26:00 +0000 Received: from BYAPR03MB4135.namprd03.prod.outlook.com ([fe80::d168:6b9a:e289:e124]) by BYAPR03MB4135.namprd03.prod.outlook.com ([fe80::d168:6b9a:e289:e124%4]) with mapi id 15.20.2347.029; Fri, 25 Oct 2019 00:26:00 +0000 From: Andrew Duggan To: "linux-input@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Andrew Duggan , Dmitry Torokhov , Benjamin Tissoires , Christopher Heiny , Simon Wood , Nick Dyer Subject: [PATCH 3/3] Input: synaptics-rmi4 - remove unused result_bits mask Thread-Topic: [PATCH 3/3] Input: synaptics-rmi4 - remove unused result_bits mask Thread-Index: AQHVisrHXpJCG1jOgkKDGh+ebpapnw== Date: Fri, 25 Oct 2019 00:26:00 +0000 Message-ID: <20191025002527.3189-4-aduggan@synaptics.com> References: <20191025002527.3189-1-aduggan@synaptics.com> In-Reply-To: <20191025002527.3189-1-aduggan@synaptics.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.147.44.15] x-clientproxiedby: BYAPR07CA0051.namprd07.prod.outlook.com (2603:10b6:a03:60::28) To BYAPR03MB4135.namprd03.prod.outlook.com (2603:10b6:a03:77::21) authentication-results: spf=none (sender IP is ) smtp.mailfrom=aduggan@synaptics.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c51ebfb3-cac3-423e-9d1b-08d758e1e95d x-ms-traffictypediagnostic: BYAPR03MB4885: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4714; x-forefront-prvs: 02015246A9 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(346002)(366004)(39860400002)(376002)(396003)(199004)(189003)(6436002)(52116002)(81156014)(2501003)(81166006)(26005)(110136005)(66556008)(8936002)(386003)(36756003)(66476007)(66946007)(2906002)(6506007)(99286004)(102836004)(6512007)(8676002)(186003)(66446008)(86362001)(50226002)(64756008)(54906003)(76176011)(25786009)(316002)(478600001)(6486002)(3846002)(6116002)(1076003)(256004)(5660300002)(11346002)(446003)(71190400001)(7736002)(2616005)(305945005)(486006)(476003)(66066001)(14454004)(71200400001)(4326008);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR03MB4885;H:BYAPR03MB4135.namprd03.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:0;MX:1; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: i+UdQdgb7hSwkfSEl2VK1flk0ZQf4ZtP4UZqQzh97ClBPw8T3CnX1Oi+/qO2hbE4RAnCuUxkE4hfP4sYECgjVfMp3x0582Y6iirSCdOUHnhdrprc65m35eNiSA5Pb5CWnb8QMlCgFavr08JwHJ7hHJENJQlwoGSJNXMhMXE/jQT3ov4T2+RDUpS0ilg6amCU+4ZxHB6LnPrBg3x88fmaWhKoJxB+be5sIXL2/+alCSULqCGqLiA4yJRLqgJdelNB8kz7SAeKPP9be1FfiwPyvVCVFTyao+skMvfyXAFw/UbT42KHNlsztvb0/NNvIvLslPIHlgkmyEb/BmBYEkfE9VOTXuN3Hplzg1cz2WDe2j5jsurF/zlkO5+YKi7DQfBvslhoiVeR0H18M1xgHbnO9t8vkMHp9l3OxrN2XXoFP1bxc/z1igd6zKRCUIeyrwkV MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: c51ebfb3-cac3-423e-9d1b-08d758e1e95d X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2019 00:26:00.5595 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: lC0jCkNHJ8+b/OAPTqyXUerBJy3LKTzSDVymF5elQRSvFhVHgkN0qGB8jlcq7kcAYvt7RlRT2CRq/Jg/R5RqeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4885 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The result_bits mask is no longer used by the driver and should be removed. Signed-off-by: Andrew Duggan --- drivers/input/rmi4/rmi_f11.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c index 26c239325f95..bbf9ae9f3f0c 100644 --- a/drivers/input/rmi4/rmi_f11.c +++ b/drivers/input/rmi4/rmi_f11.c @@ -510,7 +510,6 @@ struct f11_data { struct rmi_2d_sensor_platform_data sensor_pdata; unsigned long *abs_mask; unsigned long *rel_mask; - unsigned long *result_bits; }; enum f11_finger_state { @@ -1057,7 +1056,7 @@ static int rmi_f11_initialize(struct rmi_function *fn) /* ** init instance data, fill in values and create any sysfs files */ - f11 = devm_kzalloc(&fn->dev, sizeof(struct f11_data) + mask_size * 3, + f11 = devm_kzalloc(&fn->dev, sizeof(struct f11_data) + mask_size * 2, GFP_KERNEL); if (!f11) return -ENOMEM; @@ -1076,8 +1075,6 @@ static int rmi_f11_initialize(struct rmi_function *fn) + sizeof(struct f11_data)); f11->rel_mask = (unsigned long *)((char *)f11 + sizeof(struct f11_data) + mask_size); - f11->result_bits = (unsigned long *)((char *)f11 - + sizeof(struct f11_data) + mask_size * 2); set_bit(fn->irq_pos, f11->abs_mask); set_bit(fn->irq_pos + 1, f11->rel_mask);