From patchwork Tue Nov 29 03:02:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff LaBundy X-Patchwork-Id: 13058157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2263AC4332F for ; Tue, 29 Nov 2022 03:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235387AbiK2DDX (ORCPT ); Mon, 28 Nov 2022 22:03:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235475AbiK2DDG (ORCPT ); Mon, 28 Nov 2022 22:03:06 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2043.outbound.protection.outlook.com [40.107.93.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 432B44B9A5 for ; Mon, 28 Nov 2022 19:02:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dqY8NaP+DCYWzoD1KZnTTEfcFcAItQeeVdIWcWQzcnqSLNkScQnxbJ6IDTxhpV2cGaAm1EnDNrxBhf62tIcajBGf2I/WdAMsldHfWG9UdCbiRGVoa8rkW73Ql3jg4If55sFeZnvugslVgxSPGYjOomnK2qFvQHZpQEY/N0tqqni36HLeZ9EYn5UQ9mS8ZlhD8AGq2Nef6v+oQzekqeixMydLRrSYwO3Xv2tB4BgnUYO+E2WgGu6+E5gDFmZxZqA2uSIOZ9+0dhdXHnMs3fFALkDbupnVjiThCwGFWlfvLzefW/cBVuPUxRMc/mgNeGKd4Gg7C6CP28V7WiYlOLhX+g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4mVgKyBOHsKwjG7AQXgLYhbITMEWzqBW5qTQIoc/kNc=; b=F4eLwcBYrjtzcSBd2YniFu0pF8z/xm1+mOSS5c102mXkucqYgcdFM8qeYZI+b5AX6w6jvCY58rsmPEyfDubsX7stOKw3t1LMUlBvhMGioTX0Po+vq9SY0pG8BsxieCrSwDcULw+nn1Bzgw9SVxI5etET5WdgSpf05SAFzYzIAA3hdJGt8l1pyD9xF0DIGWRBMyVbAGNkNlJmuQWG5Z3fnHT3IStoe71MBKfW5VCUvPNGSSZFA1FymH44E66A5U+cUiOFOUlFijksMkbOOk5cWSglx+omFO7pHB8jeBy9zHprSEjMZMooF5jWBMYSecXFvdOuEG5LtX1T2p6Ji+b0Sw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=labundy.com; dmarc=pass action=none header.from=labundy.com; dkim=pass header.d=labundy.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NETORG5796793.onmicrosoft.com; s=selector1-NETORG5796793-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4mVgKyBOHsKwjG7AQXgLYhbITMEWzqBW5qTQIoc/kNc=; b=YJssakvGI06o7hfF83JjGvbqR8TrzAZ5Tp5Hi6KGjQm/2CVbMQAlVr1l+X4FbmaBFsCVxw0G7VK3KMlkNjdhrOQZ627K9cTqqijI7h3tLCxFRfaCE6AvZRAR+gYsQQfLSvgXA8aTVuWUUCVG6Igzw3PM7wjztNPIPagspKPrGic= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=labundy.com; Received: from SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) by BL0PR08MB4546.namprd08.prod.outlook.com (2603:10b6:208:5b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 03:02:19 +0000 Received: from SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c]) by SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c%4]) with mapi id 15.20.5813.019; Tue, 29 Nov 2022 03:02:19 +0000 Date: Mon, 28 Nov 2022 21:02:17 -0600 From: Jeff LaBundy To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, jeff@labundy.com Subject: [PATCH 1/5] Input: iqs269a - drop unused device node references Message-ID: Content-Disposition: inline In-Reply-To: References: X-ClientProxiedBy: SA1PR03CA0011.namprd03.prod.outlook.com (2603:10b6:806:2d3::23) To SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR0801MB3774:EE_|BL0PR08MB4546:EE_ X-MS-Office365-Filtering-Correlation-Id: dd64f03b-04d5-4e5c-5791-08dad1b620c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rKHAfkRvASeceVAAN0sA8Qny7MVHriKPfr1TYmO29bzO7W9c5WzN0sw/gkogCJiSwpigREx/N/hMlbFNAHfxGHxeMhmE52yYWkJzMaW/blNsY0SxgHZq7vydj5mLekwaEcWBHGe1Pc6Dsq1zzRLeaaJFp8X/2u8WxXeVqqAK52jcx98ljq39os6Jh5JeCjZrGweFl/HIEuUe1K61QaZ8+dziVhpeklrPO2Rzht3kbmWIUv/LI6ISSAvr3lRbIF4efLYe0xRnegK1zkin139YZuV/xiP7U+vFQnOFS7jdCY6g6ALqh2d0oZc1RSprETMI9jvh6XW0jo7U/XgNy6YvoE31eou5cW94VrBJaYzGmVIXT973d6/R8yBfa7T0I+D5twaBEMeiQ6zi+9Jb5EWgen1zsm/XCuB7t3SoxT7NHbkL1o87J75xFXonwDVP0cE7poXrwQ2s7TUStBbZVXqlWs+SZt3b7Qg+Vlly06GuVfDHPp5/p2ukTs41GMy138A6/6S+7zfiakSKOCtONtRJxv0JP3db0mSs4dLaMDfJNsMb4OMQxIm4aeQKl0EKvy0oMBE5nTSU2KD86YUTCrB8y3SvGVDVCJRVdDqvA1SeaWRCrhw9sGBlTKzgOct28zPhyqBoNb/auSbF7zvVdN//6Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN4PR0801MB3774.namprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(7916004)(39830400003)(346002)(376002)(396003)(136003)(366004)(451199015)(66556008)(8936002)(8676002)(66476007)(66946007)(5660300002)(41300700001)(107886003)(86362001)(33716001)(6506007)(6512007)(26005)(9686003)(83380400001)(186003)(38100700002)(6916009)(6486002)(478600001)(4326008)(316002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AGMOoIkgn4xaLgytfdrAZ4vRR1VbJq8L+XE/UhrWoRKWQCEUuEwAkCCJ7tIGkKAdNFOomXSdP2kyYtP3flIQGO1zekJh+NkfKX3qJRA+vwxyd7P7rpizw9b19Y8nQpjH1aBRKGwkZkMJxMUsnFNmyv8KuYoZMDz8o5hQVqYBckOq6XBeY7OvmiZiyf4UcsfgNJOW87xQktTu4JtrQU2QCmxgk3GmKRWxv/N+QlC0TroMcIcALtW9PmFupQNfb0iz7tZPwLcMfLB1/PBO3ljmut4Yg4jpRVfTNeEoequ46Ujl6nkPEHXGKj6XYDK9JXtJCKSZlhurK7hL8Ew7o2jwg9ueCwHV0UBmDYUSK0orE7kFVFZR1aKTOLxJ/QNJAbgbT5YAzAdvXSiqFKJVNO0oi4y+VE9nAED3NmmR22+zzHM5Wq1CbVcxUfZAGOgpO59op/Y9kvU+kkWhpd9fzpk8qXM0ZVFLYcUZ84q8qEDpjL3RNk0Lt+188dbwxiJaq9d8mab5oVcqebf5wtFQOtewfDYorVzMeNy84fQ1UhJjOG80uneoPuWg7sI9Nq3ObLlE3Chrnrf4gZ3ERK5zQDgPuuKeQN+JNhiIpEX62tGE4eCOPnTXikcjErGkMahTZqFCADg/FpYApb0tIE/ZWfbAm4YJklv5BsAWNJDsl25We3XH6ravA7arcw24uMv5cmtp8hpbiAPKi8024jfelC0XcHk+IaeJ1H+HHMKNnK0o3+GpDnQIkQpteiaCMBLgB8xDJrgNZGdvfFg7lMqLeW56rUUdAn5sB7zc+OIfRRbQo2rEK5IzKS1uGPp/3mfXG74zcsyG5oayKr6tPHYxq443gRL0dJ/30Q0nxxt7hPcFXCA2IEqL1kOE+U4E2Gs0uwoWayserIY3duvglE07xCeCfjcKAdrsXbJ53dZl1rO5e0592jr+H9OmSsR7IiQZGI4AJ7oO8uu70gYHdEHiAA3i3QdFOWxWF/jA+gVRVTQS94iVmi/PCdpaz8rfk37FO6HopBHVPzqPJPN8aA5i/RQCoiTwfFB3mJn3ABE6NVgCAAbuX9wMPmJJyDyIcSOOnQIpKeMuCgXRrmEy6VkfKjYOC5OcQSoMeQRKvc4j37IiHLKzInap7vGp5aGJoPXHRbhcv0IXc8N+3QgwgUwaTlcwudM21FFmScUUTrPygjZQD5cp9QQl1t5ZYN5j7rHOPvbcUvdUNlDfsJPCidGcPJQ3zhLtpYzafJIo8WQzHx4+r7UkWdsCpww8YDnFMSRtwCgKplGAUZdJyL1/qd4Glsxid2uyRa7cweeRjQ96pkNQcdJYfpBDBBu/pavteYzRMiyMSMJWxnv2dnDEeB+WVqBnTs44DcK9rYUK2mYu8+fv4tg8aE/TA8LxY4QWWMUiLlIiInWbOUGDyqW8PinxItU3JfVfexj9bSXtGn0XMAIRLZxPNDECL1PGQBo7BpOa0ju486ZjMoL93MNSlkmmNP8V8B/jmcq0+b6mcXGi/eQpU6zVjL5Tz0jxSSFfUDCJCPNsUfQWfD+zJrwRe9uI15BQI8DW4CW7jfo6D9E22petzcDnxVOvX6J37ORVJUGPfz0h X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd64f03b-04d5-4e5c-5791-08dad1b620c2 X-MS-Exchange-CrossTenant-AuthSource: SN4PR0801MB3774.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 03:02:19.1456 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 00b69d09-acab-4585-aca7-8fb7c6323e6f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SV9f1XtlzoyFYY5DYMc8cnaVGssnPi4/ouFwhqrE/8/Ufcoj70t2I8ba3W4oFWLV+HTcW5H75WdBq/hdbzVYNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR08MB4546 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Each call to device/fwnode_get_named_child_node() must be matched with a call to fwnode_handle_put() once the corresponding node is no longer in use. This ensures a reference count remains balanced in the case of dynamic device tree support. Currently, the driver does not call fwnode_handle_put() on nested event nodes. This patch solves this problem by adding the missing instances of fwnode_handle_put(). As part of this change, the logic which parses each channel's key code is gently refactored in order to reduce the number of places from which fwnode_handle_put() is called. Fixes: 04e49867fad1 ("Input: add support for Azoteq IQS269A") Signed-off-by: Jeff LaBundy Reviewed-by: Mattijs Korpershoek --- drivers/input/misc/iqs269a.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c index a348247d3d38..5620a009bf55 100644 --- a/drivers/input/misc/iqs269a.c +++ b/drivers/input/misc/iqs269a.c @@ -694,7 +694,8 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269, dev_err(&client->dev, "Invalid channel %u threshold: %u\n", reg, val); - return -EINVAL; + error = -EINVAL; + break; } ch_reg->thresh[iqs269_events[i].th_offs] = val; @@ -707,7 +708,8 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269, dev_err(&client->dev, "Invalid channel %u hysteresis: %u\n", reg, val); - return -EINVAL; + error = -EINVAL; + break; } if (i == IQS269_EVENT_DEEP_DN || @@ -721,8 +723,19 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269, } } - if (fwnode_property_read_u32(ev_node, "linux,code", &val)) + error = fwnode_property_read_u32(ev_node, "linux,code", &val); + if (error && error != -EINVAL) { + dev_err(&client->dev, + "Failed to read channel %u code: %d\n", reg, + error); + break; + } + + fwnode_handle_put(ev_node); + if (error) { + error = 0; continue; + } switch (reg) { case IQS269_CHx_HALL_ACTIVE: @@ -744,7 +757,10 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269, iqs269->sys_reg.event_mask &= ~iqs269_events[i].mask; } - return 0; + if (error) + fwnode_handle_put(ev_node); + + return error; } static int iqs269_parse_prop(struct iqs269_private *iqs269) From patchwork Tue Nov 29 03:02:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff LaBundy X-Patchwork-Id: 13058158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 342BEC43217 for ; Tue, 29 Nov 2022 03:04:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235421AbiK2DEC (ORCPT ); Mon, 28 Nov 2022 22:04:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235464AbiK2DDp (ORCPT ); Mon, 28 Nov 2022 22:03:45 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20618.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::618]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DAB64A9EB for ; Mon, 28 Nov 2022 19:02:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LTOgazd8Jtq+9e9g5TqKIewK80eY6pEMFHZPaU307jMPy57q6W8VoAnhBPPcYR3o70jXHCYHpdzcqVfup7KgK+XcO9BBXBgl09zlqiz78eZ5attm6K7ZH/JS8MbQAN6hKLFZ4OWPpSH705xHH32GJeMB9QWtxDBmtCuBv98ADB2jhJabA15hiYx/UBJH7IvFw1LNny1NNYYu3n9Ci/Oj0xnS3bR+8+qQMh2yyCT3dOtKtlhKXXC4edGYJFMNQ0R/KImaHyJaazCTBgbDu/MPlE0DgxbceeHWcv0ULxryCvo/KHmnmskPCiylvOv5tv3m7vBJPQgRdG2R65a9bsoH7g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yoolyEDq0mbqRl1f6bE3MzSxx1uQGtKMf6aft92SAc4=; b=AsdUfLNxQKatclDGBY9ePBDI4sHslf4LjTcrWRVTFmVY1TqrsM7kod6m1bzETDSLqaWEIJje20BqjAQHm279EwR8Vic12F4Ubm2Kew9ZzBy6RvOCIj4R+zPxI6XcybxEEpJa0afuAx4KscINc9dsBT9VbDKQLL0rauHg1HLJZXX0A3pCjUfOciGfufJzgySSsBBOJIDyMCbyVpfx2tPFJXNtb/E7BDPMq1xCi9t62mKRC6lSfjnX9ezSuJkjfnulFdRZvdKw21fklI6Na4az2j8K6DDXgNFpcCxrdC4LKv5Mqk0KrEZ+Dwfvv/5aNKVcC9iibDs3JFuESzZIL3+GZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=labundy.com; dmarc=pass action=none header.from=labundy.com; dkim=pass header.d=labundy.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NETORG5796793.onmicrosoft.com; s=selector1-NETORG5796793-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yoolyEDq0mbqRl1f6bE3MzSxx1uQGtKMf6aft92SAc4=; b=Y2+QaBHHvXSEQP6V/6uPzbf7zDk6bVh+D+m/bQk5u5sPgk7V4hgTP++wpZsqi3JAZ0epeQAP4RDeG5IuhldueSmvtrjtx3oNkInZg3Wt76jfK4B6vg6CdPQoxYEl+kBUnPUgP92GtSfetRqVc/xmnSch2NyObm3awKXGZYxHtaA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=labundy.com; Received: from SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) by BL0PR08MB4546.namprd08.prod.outlook.com (2603:10b6:208:5b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 03:02:33 +0000 Received: from SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c]) by SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c%4]) with mapi id 15.20.5813.019; Tue, 29 Nov 2022 03:02:33 +0000 Date: Mon, 28 Nov 2022 21:02:31 -0600 From: Jeff LaBundy To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, jeff@labundy.com Subject: [PATCH 2/5] Input: iqs269a - increase interrupt handler return delay Message-ID: Content-Disposition: inline In-Reply-To: References: X-ClientProxiedBy: DM6PR06CA0047.namprd06.prod.outlook.com (2603:10b6:5:54::24) To SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR0801MB3774:EE_|BL0PR08MB4546:EE_ X-MS-Office365-Filtering-Correlation-Id: 550694fb-cc4c-4828-649e-08dad1b62939 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g0sWDHyRy+oPH2du+sPWYNTqpHTpNqJ7r4Z5FhTzQ6LlnFdxqmEft/FDihwuF1mk+In94NVHj+sS3Yw87LR4RDJcX1ca9XkPi/2feVviue6nMDd44HKYQNe1TEWzMRiYFWEnUnT/cE7Pv8TGSBHePDakfht3bbXT+4uY+iJL6hr7ngRhUoI0O3mMShDwsYorqOUq1F8kaJSW2zaYNgIWRcrYeM07D07qb3H/7tvbuO7WkNJMqN3k0S9HKYlB15nWPt+yQU3TULMY6DzHzltLWKpbRPhqk03o9urpyXkF0cehoQMd2cgoKycHpcoSaJPrTF/Jk55CPHoAxjeZgm8b8ooKwRg7C7AJJaoEllMap0mWfeY0Mr1GrHM1QT9ZpHRJ+CXnu8cV5iTY+/Ji6odOV5zNvVnccJBfQMz5u2ExmeFNDraUVNtW/InBe+dEsPqP6I498OGVffpu4DR1jM7g3N/ppBrNmY7x89Klw74WJl7+3YP2hxHjCMQbp9fP/rnaXmwCgHlmkVeXbgG+Fj/dA+87WoXQpVj2p6NUhg3WMdAcJ6EtUK+2IzAbqKPEGt09K6rPTAqnNCDXENPx4BrRJ+AEnDDhKO5xBMvIJLGDJFA4iORIgtsWWKg14yM7bqZh4PiuU37QANrOuyXs1WPFDg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN4PR0801MB3774.namprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(7916004)(39830400003)(346002)(376002)(396003)(136003)(366004)(451199015)(66556008)(8936002)(8676002)(66476007)(66946007)(5660300002)(41300700001)(107886003)(86362001)(33716001)(6506007)(6512007)(26005)(9686003)(83380400001)(186003)(38100700002)(6916009)(6486002)(478600001)(4326008)(316002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GqCGO6IQCN4OjznKh1S3Vbmpn65sTDm3atY2AVqhwYGJzV5+ifJUC52AuTkk+RF3I7v2V0EEh3jEEBhi932lDgvha9y7W5uq16HPfDU/XW9l1dQuQX+1qpLfGrrqjMtArLfTrylYZCJNAN5xr9k23hDaA5hf+qnq6cupkVxxCVW6b6oU82yWs2VOVKkdTrBq9CEh0YjpNpWpEk8IEZ9+S85YjbzWVWXexyup0XRqsbx16TyRJS+0jqUqPMB4i4Wgo6+qctqE7PuPDX2M/lQhJbPseaYX4AfFNJSqu8BDO2wuWJ+zVdv8AZCxeq5DWNfj7klE8YZsbEuHMYYajujfzsC5Ndj6h17CHfWSZj/KMAhaVl8GLQOUqXUCmbY8pC8kIgQX9/JmjVtm43tccOv80GBybBBHv579ZCCQOCCixifTOkV6pimiB7tMlGD4iBXKRRu8JPAMBpy44Vnksz7jTsVHk9xomNjCYBr0CXI0tklXaD8IIMEHSGBWh/CUlW+MNzFPBoSnDNAYxjB1KemtTk6FFzcOdqPx8cj+ta6HdIdTrNGHCEcIVSTwNhEAUgW9GutZEbTAXUpTC0djaEOxZo7WLSoe7bBB+WH7lewI6sij+mDPGuxOaGsVdgls2bRzxVua+9IMgwB92foe6DBGMPlFcI7o4fyUuVkNzY18y7ZvV/Y+d0HhPtj9ZhWcKAtP4HDijZXyvAo3lyIKoCASxinlltzytD4GWwmOjcGL4wM2dmeyhRV6NZ2B9BuQFoM7kmjADtBZPpVjnavQM00Ue3dMrQEjiwc6inl5YK5JY03cIUhBlgQorbV0QR+JYBwLLW6+F595C8RR94ZixIKgeRVNZoo38b/Pn0/dg2URVQXU+EgRtH8BUFw9DqTvuZqC+ryJXyRP+Lw7FVp1dtEQBBnukM1tMF4iyUY0Uq97ivlI+zGZuxScyFQdsQQByV5fbeIjtokVejY+MJXLPcrHWs/LaU/OSwGbmenJN9YO5Ihlix44mlac9zoYZ3uh0tErHr/g1THKsq3SbZtydPfIZ4eO/DzbrIcCpcmXzqtderyGmUWBd5g1TKKHcCrr1CVqLBb0Egk0d9a1TdNv+tQXR9YLOZDlfEIcyLlT3WhWxpaHSZF2ViBwaoPruMnj9LEBEuaN5jxyYulsKIHSRawctTKINuPge2SqMijO55bW6fN8/W4Un5Djw+I43cdAJQuH6yBUqANHkbdUvKtvrbtrr5kBeQN6BsyXVt03HWoYKCxdT/QFmyCRl1rxohwMDbYsOotJFsqFzA+awX1B+l29BSDSrHfwJb116R2SuMRgHcLHm8aq+/7E6QFHqGHAJ8TLF2wn1FGiVUqvB+j2lkFy+Xfw1zeq+ThM50c8agK8ONkBvKtPKl/W2veAS0bf7UE2Y1os6n+Q3xuptvhEaQIKWSA0uIOjTlkcyEXqpcESDkzsLxvm09MZMYc3T9DGIrkeA8KI92VymhkFlMBf8PYVbVXBRkN9+7TGZbTVPRoL6Da/LhV0fQ5PiSWMAsHBYn0KmF4ZthflVNsnxUS+eCTisNAWSyfy+SXIfHhPY+kOtRLsZG79AHjLrWr8Ovd0PgKZ X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: 550694fb-cc4c-4828-649e-08dad1b62939 X-MS-Exchange-CrossTenant-AuthSource: SN4PR0801MB3774.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 03:02:33.3476 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 00b69d09-acab-4585-aca7-8fb7c6323e6f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ab1rgBXUiCNMcr6SGdwrREhKFseSBm5sVAVWzM808pkDt+ctX5uZr2uzvAGM5JXUHcZSqDwrwHeuyOL8DNGZ8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR08MB4546 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The time the device takes to deassert its RDY output following an I2C stop condition scales with the core clock frequency. To prevent level-triggered interrupts from being reasserted after the interrupt handler returns, increase the time before returning to account for the worst-case delay (~140 us) plus margin. Fixes: 04e49867fad1 ("Input: add support for Azoteq IQS269A") Signed-off-by: Jeff LaBundy Reviewed-by: Mattijs Korpershoek --- drivers/input/misc/iqs269a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c index 5620a009bf55..711e67db71a4 100644 --- a/drivers/input/misc/iqs269a.c +++ b/drivers/input/misc/iqs269a.c @@ -153,7 +153,7 @@ #define IQS269_PWR_MODE_POLL_SLEEP_US IQS269_ATI_POLL_SLEEP_US #define IQS269_PWR_MODE_POLL_TIMEOUT_US IQS269_ATI_POLL_TIMEOUT_US -#define iqs269_irq_wait() usleep_range(100, 150) +#define iqs269_irq_wait() usleep_range(200, 250) enum iqs269_local_cap_size { IQS269_LOCAL_CAP_SIZE_0, From patchwork Tue Nov 29 03:02:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff LaBundy X-Patchwork-Id: 13058159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FC64C4332F for ; Tue, 29 Nov 2022 03:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235453AbiK2DEP (ORCPT ); Mon, 28 Nov 2022 22:04:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235458AbiK2DD5 (ORCPT ); Mon, 28 Nov 2022 22:03:57 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20618.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::618]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6E5C4FF85 for ; Mon, 28 Nov 2022 19:03:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SRci4RMu8ASaZsUrcKHe6pJUhUaHAoKMHbRydoEy0KChv8S/5xBLg58NCsF7+GvgJbKqxDccqzxtz4uf/gYA76lyL73F7cG5U1BzUHFSaPAYBgjBGfqGe6WdWQHnJXFMMtasnc7cgiIbjr7KT7hNP58sO9ELbCeWZnVjfp/aSTTrwo04R7OC3nMH2nPTts9UkU1cETZ2taq51JQFgjHQGZ/gZGl/Ij6yER3QOxAo/sBoxFnAsUy/MMixWccK+7UGKBctxiI4VYllTDm0G/bq9wMepnNjtTx1vJNi6FR0XcSOP6eCJnLdZFQjS+ciVQZQveLiSZ39VrmAuZgLn+4Ehw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dl748P9VVPr8yxU3X6hVRhj0uPvP3R8mafC+8GLGff0=; b=RBefqvCjT3miCAf9Fi/EtJ4mxKItLyZqyZLAIHeRrbOZrZlJXwm94Pzw0zBFmF0r8/41dNgMBcDau8EkFnkz5HtE0Hz3PNmIDvwNe/p5Rp6z8B7jcwcP7waWowCr0bmlnB/HpYwmAZaFcYcgG0EM05uoEVaM43y7pocWEs0E4iCrh1Pw9gMVhKTN3GHmslq281IR8IzhwSVDTK7SDHQR4xVp86oogmwTe4dn/QDsE0uHVGno/MKXrhbzjnMkeLkKeJRK2ilMbDSqDuJC13yw2yyPtX0T7SW8dUGQSikr0rmBGIzzPU//rv7ofIaEJHbhLwrPvLMsmEdxky+b9nYTVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=labundy.com; dmarc=pass action=none header.from=labundy.com; dkim=pass header.d=labundy.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NETORG5796793.onmicrosoft.com; s=selector1-NETORG5796793-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dl748P9VVPr8yxU3X6hVRhj0uPvP3R8mafC+8GLGff0=; b=W4nWscQ+WGQ4KTxREAlUkp1fw5NglSAcoBG1UI3fySZsvMc3rMqBa6W6G7KHpyvrVpYblKLEm2zPw9VOfbWAA8eZQIY4yKX+objpP7pDhnO6EDxw3XFUmVce7ynb68E0zr38SHdPQNwJnEa8HoKio7Nhb+ILfd5XyPG5sn96dfk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=labundy.com; Received: from SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) by BL0PR08MB4546.namprd08.prod.outlook.com (2603:10b6:208:5b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 03:02:43 +0000 Received: from SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c]) by SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c%4]) with mapi id 15.20.5813.019; Tue, 29 Nov 2022 03:02:43 +0000 Date: Mon, 28 Nov 2022 21:02:41 -0600 From: Jeff LaBundy To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, jeff@labundy.com Subject: [PATCH 3/5] Input: iqs269a - configure device with a single block write Message-ID: Content-Disposition: inline In-Reply-To: References: X-ClientProxiedBy: SN1PR12CA0095.namprd12.prod.outlook.com (2603:10b6:802:21::30) To SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR0801MB3774:EE_|BL0PR08MB4546:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a1d3b7d-6227-419f-2225-08dad1b62f6d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +RclgqhdrEXKglbvT2sH8OFvdWghK1uZGOwcf63ktYLy2yJKq9KGCAkcRWoiHyp6nP7bri3UQ7KKVa7FK2CjrYCvzhjWqqWcV15JI7Fk0v61okFf7E8BSHWhp4bGI3Bz99BAtT1hy2vXrcl++rgBUFEtB0XZdAK9d5wt8AwRUlRkryix935sBbFF28DkOii13AUM1HntUyR1Z4v27dzIP2QE40xzjH5nz7AnLIVxUMhNGUL7oEKnRMEXN3IEbHrW0zAmXCi1CFGkFp2rYD+j7rLDz1A+jg9+qy1LbnKpttSXwM6G0ItKrA1+Er93zyBXuZCknOZ0HpG8gmqxKKbgYNItMYiPjGtgIsUG+vXLG+jEPjcoAAwp9CftO3bzqEOXreEAc++1OCrp9FHD2vz8UJ5DfvifRhcEeMpkmahUo1axt0x4vhlNpLqp5VsVxLxgu2yaHQ73gVVm/gveEIyjN7hl4bWdzxcaEKU41CnKxuPjFmPWy5gJOXzKbC6Y7PU3AOwqdSOyGoyld8ZbxGSKCCdtRWByFwFzbhMUnM9w2XLwuS0G3E39SNZM17fdOY98qdzqTVsBsTyxpb6sa/3h97hoOfwqMLKDJuAKDj1G1iVVssCfsFts8r3qMGH53h2FkFzQSAFecipugTUdfWiZxg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN4PR0801MB3774.namprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(7916004)(39830400003)(346002)(376002)(396003)(136003)(366004)(451199015)(66556008)(8936002)(8676002)(66476007)(66946007)(5660300002)(41300700001)(107886003)(86362001)(33716001)(6506007)(6512007)(26005)(9686003)(83380400001)(186003)(38100700002)(6916009)(6486002)(478600001)(4326008)(316002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6pkQ5XIHO/eUz01rZWwSUlWbJVTOMdjBVpMaIbEado0v3dNIbdPRL4UzXYZ8rEVsm6tKUfJoxSBAXKi/SYTEi8CrPskGRlDtAlNg9rovKj5xsT56k/K9FPj48bUEq1ZMZTEHfkcZYNBDsv0QqC9Fzfb1inxjQD2oBCkYJag0NeZr0tMsYa39R4w9KFcyTsX029q0Nl5mf7ojNyuMRCzOOCx3NjaWOJNvPnsgybaKgESPLWn44YdYSeiGkw91/Aa7ekSC+ibdAX+T2bKnjxX3p0cHiTh+oUKfjgXf0uNx42bujre5XdsA0wzH26nVhlISwpndlcIupM3gxwTcG619MElWGtenHL+AC2wVM9dnOBCat9mpAKy812VXurNoxZ4IyBevfjbjaFyT3xBITgDtAw/qM0TEPBPxf7SE+swINLMztXhBRYKloSchqBLDbld51EegW8oggXUhFKebPgEo5wlNeiPq1nwzqOPhdfrSE32844WjYH3dXXXb9MMIoFDxFA6icTX8bmCjDj7vZnNvcAfxPlQExLcA1GbwUpKM0TptznNHLKzgvmc0UMq3v3kXWSuwCp4Pjs93e2VOj5AlXkcPSTspNLjNfVSrB9HiiYqGbLb7Lrqi6ZQAvVm0mtyJEBPF3c1D93Kd29l/OFE7ucMgdRmzLFBrP96Ny1q8bTYdITjqGBSZ3M27E2jZclS8BTcMnkG0z4vCpGa/8CK6dwnPTUCztrPvSF5Fdl08x7iQLQiYLKMv5BkkQ5NLPBxlfU2jYkOpNlvwlGWcjvnzDwYHepvpxEv5jCHIdxctdlPM26adnZ8iE7BCcZisVkUi7BVtHEpeuCpHy1FyuVk/yJjhSuv5zJVX99eWYmaFGf+hyLqzhhjRTZmz6C0noiKL+F0/xHnTJ90o+hq9rusFxoIdLbFEcMErG7kB0b8njrfIw31sPm5MFVcsRAuussNagOpdBJUHOpbqKcYVHKbpQQC5wW0WQnwzoh9YHmpPgUvea34JjpTnvgAC6ufgNdm9boxt7+FJsNvFb23Mtbf3TltbhbbWukvNRGUTKGhVdXno0psAxsb1w7wgcIhTlcr+6DHhvGpdqi6yJfyQIkDUpvTkrljTg01PU382LigS+iY84eKqklhgnCB3hFeE2wa2cwliQgowFjCDex5q23uXl8Pd98Jo3lx2U7clwhyT7VFkSLECOUOvjUEz6NWqZSCRrKVvwzp1bGRvCDGHr7cVIOCsyJpJfB8IME/7/TEoHPDmhTxKhLyOAN0avnwB23gLcmRvGZJjmodA1lCnQpycr9xmdh/Y22h+eFKQr3E+BZFPC9Ww/2MeqCOHl6sGMOQN+PYOcWbyjcq4SYr+38/5lWBsbu860lzK5mCrVaLx9ps+474E97GwqwQyWdZV0Tr2irtiq2uGZrr39aa05gVcmMG6ClqHwjgJUNYHqWTHZwv8LxksTIgy7ntzC2T2WOUXxrkG6FMaizqTjDVhZcj+nUjiC/dzFzuk1GP56uVyuHBAUdMFZh1EAEXJbLa6VlZT1I1fauQ4y92sh8VdHtx5ikzuLv1Br6rRGSyE9A5lJxDxrT0XFr9H8muOwLqdyGOB X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a1d3b7d-6227-419f-2225-08dad1b62f6d X-MS-Exchange-CrossTenant-AuthSource: SN4PR0801MB3774.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 03:02:43.7687 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 00b69d09-acab-4585-aca7-8fb7c6323e6f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FCImSGU9VjX06KI1ltemGfEOITJ4dBEQfLngvOxwHMhiRkqogP72vHqA+VMbiN9lrw2UhimvR2jsfRyBZNMPoA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR08MB4546 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Unless it is being done as part of servicing a soft reset interrupt, configuring channels on-the-fly (as is the case when writing to the ati_trigger attribute) may cause GPIO3 (which reflects the state of touch for a selected channel) to be inadvertently asserted. To solve this problem, follow the vendor's recommendation and write all channel configuration as well as the REDO_ATI register field as part of a single block write. This ensures the device has been told to re-calibrate itself following an I2C stop condition, after which sensing resumes and GPIO3 may be asserted. Fixes: 04e49867fad1 ("Input: add support for Azoteq IQS269A") Signed-off-by: Jeff LaBundy Reviewed-by: Mattijs Korpershoek --- drivers/input/misc/iqs269a.c | 98 ++++++++++++++---------------------- 1 file changed, 39 insertions(+), 59 deletions(-) diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c index 711e67db71a4..0eb3cff177e5 100644 --- a/drivers/input/misc/iqs269a.c +++ b/drivers/input/misc/iqs269a.c @@ -96,8 +96,6 @@ #define IQS269_MISC_B_TRACKING_UI_ENABLE BIT(4) #define IQS269_MISC_B_FILT_STR_SLIDER GENMASK(1, 0) -#define IQS269_CHx_SETTINGS 0x8C - #define IQS269_CHx_ENG_A_MEAS_CAP_SIZE BIT(15) #define IQS269_CHx_ENG_A_RX_GND_INACTIVE BIT(13) #define IQS269_CHx_ENG_A_LOCAL_CAP_SIZE BIT(12) @@ -245,6 +243,18 @@ struct iqs269_ver_info { u8 padding; } __packed; +struct iqs269_ch_reg { + u8 rx_enable; + u8 tx_enable; + __be16 engine_a; + __be16 engine_b; + __be16 ati_comp; + u8 thresh[3]; + u8 hyst; + u8 assoc_select; + u8 assoc_weight; +} __packed; + struct iqs269_sys_reg { __be16 general; u8 active; @@ -266,18 +276,7 @@ struct iqs269_sys_reg { u8 timeout_swipe; u8 thresh_swipe; u8 redo_ati; -} __packed; - -struct iqs269_ch_reg { - u8 rx_enable; - u8 tx_enable; - __be16 engine_a; - __be16 engine_b; - __be16 ati_comp; - u8 thresh[3]; - u8 hyst; - u8 assoc_select; - u8 assoc_weight; + struct iqs269_ch_reg ch_reg[IQS269_NUM_CH]; } __packed; struct iqs269_flags { @@ -292,7 +291,6 @@ struct iqs269_private { struct regmap *regmap; struct mutex lock; struct iqs269_switch_desc switches[ARRAY_SIZE(iqs269_events)]; - struct iqs269_ch_reg ch_reg[IQS269_NUM_CH]; struct iqs269_sys_reg sys_reg; struct input_dev *keypad; struct input_dev *slider[IQS269_NUM_SL]; @@ -307,6 +305,7 @@ struct iqs269_private { static int iqs269_ati_mode_set(struct iqs269_private *iqs269, unsigned int ch_num, unsigned int mode) { + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; u16 engine_a; if (ch_num >= IQS269_NUM_CH) @@ -317,12 +316,12 @@ static int iqs269_ati_mode_set(struct iqs269_private *iqs269, mutex_lock(&iqs269->lock); - engine_a = be16_to_cpu(iqs269->ch_reg[ch_num].engine_a); + engine_a = be16_to_cpu(ch_reg[ch_num].engine_a); engine_a &= ~IQS269_CHx_ENG_A_ATI_MODE_MASK; engine_a |= (mode << IQS269_CHx_ENG_A_ATI_MODE_SHIFT); - iqs269->ch_reg[ch_num].engine_a = cpu_to_be16(engine_a); + ch_reg[ch_num].engine_a = cpu_to_be16(engine_a); iqs269->ati_current = false; mutex_unlock(&iqs269->lock); @@ -333,13 +332,14 @@ static int iqs269_ati_mode_set(struct iqs269_private *iqs269, static int iqs269_ati_mode_get(struct iqs269_private *iqs269, unsigned int ch_num, unsigned int *mode) { + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; u16 engine_a; if (ch_num >= IQS269_NUM_CH) return -EINVAL; mutex_lock(&iqs269->lock); - engine_a = be16_to_cpu(iqs269->ch_reg[ch_num].engine_a); + engine_a = be16_to_cpu(ch_reg[ch_num].engine_a); mutex_unlock(&iqs269->lock); engine_a &= IQS269_CHx_ENG_A_ATI_MODE_MASK; @@ -351,6 +351,7 @@ static int iqs269_ati_mode_get(struct iqs269_private *iqs269, static int iqs269_ati_base_set(struct iqs269_private *iqs269, unsigned int ch_num, unsigned int base) { + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; u16 engine_b; if (ch_num >= IQS269_NUM_CH) @@ -379,12 +380,12 @@ static int iqs269_ati_base_set(struct iqs269_private *iqs269, mutex_lock(&iqs269->lock); - engine_b = be16_to_cpu(iqs269->ch_reg[ch_num].engine_b); + engine_b = be16_to_cpu(ch_reg[ch_num].engine_b); engine_b &= ~IQS269_CHx_ENG_B_ATI_BASE_MASK; engine_b |= base; - iqs269->ch_reg[ch_num].engine_b = cpu_to_be16(engine_b); + ch_reg[ch_num].engine_b = cpu_to_be16(engine_b); iqs269->ati_current = false; mutex_unlock(&iqs269->lock); @@ -395,13 +396,14 @@ static int iqs269_ati_base_set(struct iqs269_private *iqs269, static int iqs269_ati_base_get(struct iqs269_private *iqs269, unsigned int ch_num, unsigned int *base) { + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; u16 engine_b; if (ch_num >= IQS269_NUM_CH) return -EINVAL; mutex_lock(&iqs269->lock); - engine_b = be16_to_cpu(iqs269->ch_reg[ch_num].engine_b); + engine_b = be16_to_cpu(ch_reg[ch_num].engine_b); mutex_unlock(&iqs269->lock); switch (engine_b & IQS269_CHx_ENG_B_ATI_BASE_MASK) { @@ -429,6 +431,7 @@ static int iqs269_ati_base_get(struct iqs269_private *iqs269, static int iqs269_ati_target_set(struct iqs269_private *iqs269, unsigned int ch_num, unsigned int target) { + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; u16 engine_b; if (ch_num >= IQS269_NUM_CH) @@ -439,12 +442,12 @@ static int iqs269_ati_target_set(struct iqs269_private *iqs269, mutex_lock(&iqs269->lock); - engine_b = be16_to_cpu(iqs269->ch_reg[ch_num].engine_b); + engine_b = be16_to_cpu(ch_reg[ch_num].engine_b); engine_b &= ~IQS269_CHx_ENG_B_ATI_TARGET_MASK; engine_b |= target / 32; - iqs269->ch_reg[ch_num].engine_b = cpu_to_be16(engine_b); + ch_reg[ch_num].engine_b = cpu_to_be16(engine_b); iqs269->ati_current = false; mutex_unlock(&iqs269->lock); @@ -455,13 +458,14 @@ static int iqs269_ati_target_set(struct iqs269_private *iqs269, static int iqs269_ati_target_get(struct iqs269_private *iqs269, unsigned int ch_num, unsigned int *target) { + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; u16 engine_b; if (ch_num >= IQS269_NUM_CH) return -EINVAL; mutex_lock(&iqs269->lock); - engine_b = be16_to_cpu(iqs269->ch_reg[ch_num].engine_b); + engine_b = be16_to_cpu(ch_reg[ch_num].engine_b); mutex_unlock(&iqs269->lock); *target = (engine_b & IQS269_CHx_ENG_B_ATI_TARGET_MASK) * 32; @@ -531,13 +535,7 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269, if (fwnode_property_present(ch_node, "azoteq,slider1-select")) iqs269->sys_reg.slider_select[1] |= BIT(reg); - ch_reg = &iqs269->ch_reg[reg]; - - error = regmap_raw_read(iqs269->regmap, - IQS269_CHx_SETTINGS + reg * sizeof(*ch_reg) / 2, - ch_reg, sizeof(*ch_reg)); - if (error) - return error; + ch_reg = &iqs269->sys_reg.ch_reg[reg]; error = iqs269_parse_mask(ch_node, "azoteq,rx-enable", &ch_reg->rx_enable); @@ -1048,10 +1046,8 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269) static int iqs269_dev_init(struct iqs269_private *iqs269) { - struct iqs269_sys_reg *sys_reg = &iqs269->sys_reg; - struct iqs269_ch_reg *ch_reg; unsigned int val; - int error, i; + int error; mutex_lock(&iqs269->lock); @@ -1061,27 +1057,8 @@ static int iqs269_dev_init(struct iqs269_private *iqs269) if (error) goto err_mutex; - for (i = 0; i < IQS269_NUM_CH; i++) { - if (!(sys_reg->active & BIT(i))) - continue; - - ch_reg = &iqs269->ch_reg[i]; - - error = regmap_raw_write(iqs269->regmap, - IQS269_CHx_SETTINGS + i * - sizeof(*ch_reg) / 2, ch_reg, - sizeof(*ch_reg)); - if (error) - goto err_mutex; - } - - /* - * The REDO-ATI and ATI channel selection fields must be written in the - * same block write, so every field between registers 0x80 through 0x8B - * (inclusive) must be written as well. - */ - error = regmap_raw_write(iqs269->regmap, IQS269_SYS_SETTINGS, sys_reg, - sizeof(*sys_reg)); + error = regmap_raw_write(iqs269->regmap, IQS269_SYS_SETTINGS, + &iqs269->sys_reg, sizeof(iqs269->sys_reg)); if (error) goto err_mutex; @@ -1355,6 +1332,7 @@ static ssize_t hall_bin_show(struct device *dev, struct device_attribute *attr, char *buf) { struct iqs269_private *iqs269 = dev_get_drvdata(dev); + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; struct i2c_client *client = iqs269->client; unsigned int val; int error; @@ -1369,8 +1347,8 @@ static ssize_t hall_bin_show(struct device *dev, if (error) return error; - switch (iqs269->ch_reg[IQS269_CHx_HALL_ACTIVE].rx_enable & - iqs269->ch_reg[IQS269_CHx_HALL_INACTIVE].rx_enable) { + switch (ch_reg[IQS269_CHx_HALL_ACTIVE].rx_enable & + ch_reg[IQS269_CHx_HALL_INACTIVE].rx_enable) { case IQS269_HALL_PAD_R: val &= IQS269_CAL_DATA_A_HALL_BIN_R_MASK; val >>= IQS269_CAL_DATA_A_HALL_BIN_R_SHIFT; @@ -1450,9 +1428,10 @@ static ssize_t rx_enable_show(struct device *dev, struct device_attribute *attr, char *buf) { struct iqs269_private *iqs269 = dev_get_drvdata(dev); + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; return scnprintf(buf, PAGE_SIZE, "%u\n", - iqs269->ch_reg[iqs269->ch_num].rx_enable); + ch_reg[iqs269->ch_num].rx_enable); } static ssize_t rx_enable_store(struct device *dev, @@ -1460,6 +1439,7 @@ static ssize_t rx_enable_store(struct device *dev, size_t count) { struct iqs269_private *iqs269 = dev_get_drvdata(dev); + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; unsigned int val; int error; @@ -1472,7 +1452,7 @@ static ssize_t rx_enable_store(struct device *dev, mutex_lock(&iqs269->lock); - iqs269->ch_reg[iqs269->ch_num].rx_enable = val; + ch_reg[iqs269->ch_num].rx_enable = val; iqs269->ati_current = false; mutex_unlock(&iqs269->lock); From patchwork Tue Nov 29 03:02:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff LaBundy X-Patchwork-Id: 13058160 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40106C4332F for ; Tue, 29 Nov 2022 03:04:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235435AbiK2DEc (ORCPT ); Mon, 28 Nov 2022 22:04:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235409AbiK2DEO (ORCPT ); Mon, 28 Nov 2022 22:04:14 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20618.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::618]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2F164C262 for ; Mon, 28 Nov 2022 19:03:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lzLN7RyIKoDbfYej5TSPUzIWoSd6TV0gACauHRz+HfoCK7WwHFp30CgBVtMVo6Ruzxm+hyTlCBnj4p8bQE8HfEpSbx7HHbxWWz7RGru4j6g1zAPyKRpt68wuVtYDAmyX2kkymaURqyBLqePCeXReC0oxeVm1eaqzfNqDCwd8awTov0Mv1zyriKEJ7H5EG5Svbp6OOr4+OQM2gsycuznBeaBPNh4Wgv4zPB9zyWtlLHzAT7paOOJcS+LKUBFf2pbu9a9jp/6V70ldy45rNV6kN91NhVs65Li0gJ4Tc83Ry8FrT/VOGD5m2m7ETTh6V46sPCQRXlQzrthwKtgEz4wYbg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bq9VJZW+9T/AFf54+q7Rj9hV4i/A86imUc4yCoORKkY=; b=EmE6pmBRX57Zhq/s7LC8FDDbH9W+VlwvSlieDkgEwub3F5Koi93dzr0IH0tfjpnh1p7rGp6Q1SeKmjSax0d1Qgw9TGnIPXkQHHqdT9cikqVTRB6lJbKpmHBmSJzfDy4jWoZrFmDCROsr6umodjR2j+eWWj1UXb+4Y+HPGnKYHbPFvz1mKt7HEB33WIyckZSec/GWCC7mvpA0+ec9OWr6JjIlmU4gRLnQZYAYmeapWZzh85Y8cnqVrmDK45VbEwGt8wXn/NPW3fZRZjj0whyRzL0vkBItyMVPp+/7hAfiaLr6lXmBi3uvZJJVYwQ4J7DHT/6c0UokSNFmNzQnS9WJMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=labundy.com; dmarc=pass action=none header.from=labundy.com; dkim=pass header.d=labundy.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NETORG5796793.onmicrosoft.com; s=selector1-NETORG5796793-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bq9VJZW+9T/AFf54+q7Rj9hV4i/A86imUc4yCoORKkY=; b=cDANaQthizI2B4+6PXPhwbMuHnrbAGVxpAFwVBwhbzk0+GCSrACTP0zlApo4enO+ito4yvjSSuSRDHL6uZp+Lb/exyPCflh276kiZMWlw2Ab/XbDpGaSqyRGGnzGVPrZpKGT58pCTPs5UbxRJ1f9+ev2YfrtAHy+mdzcMTNrxck= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=labundy.com; Received: from SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) by BL0PR08MB4546.namprd08.prod.outlook.com (2603:10b6:208:5b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 03:02:54 +0000 Received: from SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c]) by SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c%4]) with mapi id 15.20.5813.019; Tue, 29 Nov 2022 03:02:54 +0000 Date: Mon, 28 Nov 2022 21:02:53 -0600 From: Jeff LaBundy To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, jeff@labundy.com Subject: [PATCH 4/5] Input: iqs269a - do not poll during suspend or resume Message-ID: Content-Disposition: inline In-Reply-To: References: X-ClientProxiedBy: DM6PR02CA0145.namprd02.prod.outlook.com (2603:10b6:5:332::12) To SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR0801MB3774:EE_|BL0PR08MB4546:EE_ X-MS-Office365-Filtering-Correlation-Id: 1017ccbf-5cd3-49b5-14dc-08dad1b635f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ewukNXNurKpOq8tlbrIqs7/G4t6sAi3Zs2BpR+GC3G6Jok953cbuWIzDkEQbHoF4SI6D4pZZ27mzfUYbHDrougs3kk8SKqSMYTJGzCXN0ZBMnE9uiCkEwdljrdYJVqxyfwmNEBUq/BXAw2/8nlAy54TKx8AAxZbDIKxjGX+rx9Je+cxi4Turl3CEZkxasSErr7gYIKDpK0yhSMzl9s7i6EhVr25JsNYHJOXDhWmCVmXlTVUqkvnnd9ksakZ+CYCoZafvKRtobkj2Gfc9X/sukVnd7mAVbZAqvFizwms61DHyvbV3pKQKPQPn3W9uI2m9wQKsK/AM3veqiMao3d2pltn64qnPXBQtVDHVYRXyXSOb6Hrnmfh6HZWFO37gf6MVWDBdp5qZm5EOnXNnkXHqG7HXBY7lwpSWOQnE9em1O5RKQ0ceCTdAUjrt8WTdNoD1A7eYiCa9YzlyhlNjfC+zXzCaTK1sxjWyqx1pIDqBgoSGqno5T2RjrVHsBRaqKA320RYDSSdR7sVyQwvKTPXNTjbhVrrikAsmG62IV0pWlb5SeSF5iM+py0nqjIBKRE6Y9qAJ9efhK2SjwMt0TReUCHhlKNG6KxXOr/2LV6aGlc44p9awlmIoZ+4PBQVw1E5nt/iRtyHCd3Tg5XbuZ1EmfQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN4PR0801MB3774.namprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(7916004)(39830400003)(346002)(376002)(396003)(136003)(366004)(451199015)(66556008)(8936002)(8676002)(15650500001)(66476007)(66946007)(5660300002)(41300700001)(107886003)(86362001)(33716001)(6506007)(6512007)(26005)(9686003)(83380400001)(186003)(38100700002)(6916009)(6486002)(478600001)(4326008)(316002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fmJUdEoLVQkJhaTdRKDxc1UdoaF7tvDHl2TApBAWtoXhQhFneilyCsDj609uELcqxwgkrTr9WDytpMh5uB9LlrA213z8sXrZ7ZEXU2AvIjacS9dctf8MfLlgpWX1v2NpCP8GI8Kzj1tPDfG+J6OjHx6GjtNc0nlpMo1th/UibcUzZjJgutD2///H0FkjIF2B6cnho7QobHGYh0wRKFUCL3IFulBn4as0o1hq4KrFMP6uerQrGdc/XvAZ84neVh7Pn3VhPMgTEMEsq89UYEJh/gvGRHle8kvMwT/tGC5fLbKHjFC2Kt2/k7UsGMrQHjOcSD6qrQBz82Awg243AFVLSbXrhacWCcxZ/7w0k8/lQxq8h+kfZSbl9dkpa82mIpSUZf32u7+h4ifMvZiVNI+ZdezUmwZIWE4U9vTt+HT/X3FNplEvbnTCr0PaXVJOIrySWDJk+pGIRF5bc0hrLMMvHHyeVzKfJxdidI+GVu1rwOZuPNkSZ1AGrywvmS6Qs7/p4+MUFY1dGAKto+OS9/svr/3XHZCbedC3eM83Fy7DeiuQFsrrD1he6CTQF8mEOGPdpRyaYIs8Z+qUYZGYAg2CxMz8pxk28uxR5zxSxc99WGO9io9ULjPx1KrHp7iczbs4Evkx7WxbRBig3hApvIHuc/vYKP7JQk4mmG6aV4rBt5flEHQh3mUARheevzk8oFYgnsQrv8/vVqWu7GvjSAwIFZ3r1ouUIdM7tSxL2/aOVCDT6ZEPkk2xla37qwEeSogg4E81S0CN6vf7R/nwRZeVxVuRoRFNCUYQ3dfuihrU1bKopWFnAVsAXj2W14JREeFcxdm+mHawST2iJYSteYw/YkKYzF0EfSYmQU6g/fzeIDVrFrDSeOI375JVfdt/o1u2h9s8VEKXZoStzVUBoNveBr9TYiIF5H5/slCbdJBraA9PWw9Em57Zeuw1QWwC8vaSiR/dUzPkewNeVgL3OUlCOZFEhWsiktl1N5niisjzJ/f7E9hml2m2xhcHKf1EN4eOVDTZhT5+o6GxemH+QpX4g0kNp7UjhrgxmCyI3TOTLW4MWIOY2Uu3ifd98fUi7Ed+oUMYLsxSPE+2y36ivRSSUHRJ2fShMndUpwUQAULcDqK80al+kJESn20Tm8MrDxZuIm005aQJekX0zT5gmISTWlbLC+bGd3sCwEPhel91ucpHi2AptiZzLLJsZ8JrB/32GG1qUfCbqqtQWXKD3TXnjRn6p4r1YhHGaSkRuuLV8Wl4ScPGYFwr7h3LeTR+1VibSVExXtnxA5uymM0wTbbKOkBCeZbwLmM0Oo6JfDFwuymEjkRaqN0CzHvZxxIgTxs5fygMM2inLl02qzigbfxXUSwJOGyNzZRUVJ08uPmQOJO9zzcvarDo5qpDigTwMpCOUuULeXCmZ6CryKXsbixB2gPgWSjtN1tYegPUJbsdLPongmyMafXbNSZMLAxuWSbFmcEFDA4n2rG/RDAYPi1bDbNyYRzoTDoDI0f3pT06XTntC97akJrBr+OqZaJC1EuLCfFbNQyyIcxU2VRJGM273YS3jsJdtLcuNtypFSBYZVQFG2OF88Bq/418oiMvwSyJ X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1017ccbf-5cd3-49b5-14dc-08dad1b635f9 X-MS-Exchange-CrossTenant-AuthSource: SN4PR0801MB3774.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 03:02:54.7521 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 00b69d09-acab-4585-aca7-8fb7c6323e6f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RvnWd+CX1rPofLcjL+IOUSt6MlWfp7ZWfxuAPOBmX00q/y641f3/qMpTrjGT7p2f2HzNocMO9sI+K8Q98IH1vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR08MB4546 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Polling the device while it transitions from automatic to manual power mode switching may keep the device from actually finishing the transition. The process appears to time out depending on the polling rate and the device's core clock frequency. This is ultimately unnecessary in the first place; instead it is sufficient to write the desired mode during initialization, then disable automatic switching at suspend. This eliminates the need to ensure the device is prepared for a manual change and removes the 'suspend_mode' variable. Similarly, polling the device while it transitions from one mode to another under manual control may time out as well. This added step does not appear to be necessary either, so drop it. Fixes: 04e49867fad1 ("Input: add support for Azoteq IQS269A") Signed-off-by: Jeff LaBundy Reviewed-by: Mattijs Korpershoek --- drivers/input/misc/iqs269a.c | 118 +++++++++-------------------------- 1 file changed, 31 insertions(+), 87 deletions(-) diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c index 0eb3cff177e5..eca680bf8c20 100644 --- a/drivers/input/misc/iqs269a.c +++ b/drivers/input/misc/iqs269a.c @@ -148,9 +148,6 @@ #define IQS269_ATI_POLL_TIMEOUT_US (iqs269->delay_mult * 500000) #define IQS269_ATI_STABLE_DELAY_MS (iqs269->delay_mult * 150) -#define IQS269_PWR_MODE_POLL_SLEEP_US IQS269_ATI_POLL_SLEEP_US -#define IQS269_PWR_MODE_POLL_TIMEOUT_US IQS269_ATI_POLL_TIMEOUT_US - #define iqs269_irq_wait() usleep_range(200, 250) enum iqs269_local_cap_size { @@ -295,7 +292,6 @@ struct iqs269_private { struct input_dev *keypad; struct input_dev *slider[IQS269_NUM_SL]; unsigned int keycode[ARRAY_SIZE(iqs269_events) * IQS269_NUM_CH]; - unsigned int suspend_mode; unsigned int delay_mult; unsigned int ch_num; bool hall_enable; @@ -773,17 +769,6 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269) iqs269->hall_enable = device_property_present(&client->dev, "azoteq,hall-enable"); - if (!device_property_read_u32(&client->dev, "azoteq,suspend-mode", - &val)) { - if (val > IQS269_SYS_SETTINGS_PWR_MODE_MAX) { - dev_err(&client->dev, "Invalid suspend mode: %u\n", - val); - return -EINVAL; - } - - iqs269->suspend_mode = val; - } - error = regmap_raw_read(iqs269->regmap, IQS269_SYS_SETTINGS, sys_reg, sizeof(*sys_reg)); if (error) @@ -1011,6 +996,17 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269) general &= ~IQS269_SYS_SETTINGS_DIS_AUTO; general &= ~IQS269_SYS_SETTINGS_PWR_MODE_MASK; + if (!device_property_read_u32(&client->dev, "azoteq,suspend-mode", + &val)) { + if (val > IQS269_SYS_SETTINGS_PWR_MODE_MAX) { + dev_err(&client->dev, "Invalid suspend mode: %u\n", + val); + return -EINVAL; + } + + general |= (val << IQS269_SYS_SETTINGS_PWR_MODE_SHIFT); + } + if (!device_property_read_u32(&client->dev, "azoteq,ulp-update", &val)) { if (val > IQS269_SYS_SETTINGS_ULP_UPDATE_MAX) { @@ -1693,59 +1689,30 @@ static int iqs269_probe(struct i2c_client *client) return error; } +static u16 iqs269_general_get(struct iqs269_private *iqs269) +{ + u16 general = be16_to_cpu(iqs269->sys_reg.general); + + general &= ~IQS269_SYS_SETTINGS_REDO_ATI; + general &= ~IQS269_SYS_SETTINGS_ACK_RESET; + + return general | IQS269_SYS_SETTINGS_DIS_AUTO; +} + static int __maybe_unused iqs269_suspend(struct device *dev) { struct iqs269_private *iqs269 = dev_get_drvdata(dev); struct i2c_client *client = iqs269->client; - unsigned int val; int error; + u16 general = iqs269_general_get(iqs269); - if (!iqs269->suspend_mode) + if (!(general & IQS269_SYS_SETTINGS_PWR_MODE_MASK)) return 0; disable_irq(client->irq); - /* - * Automatic power mode switching must be disabled before the device is - * forced into any particular power mode. In this case, the device will - * transition into normal-power mode. - */ - error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS, - IQS269_SYS_SETTINGS_DIS_AUTO, ~0); - if (error) - goto err_irq; - - /* - * The following check ensures the device has completed its transition - * into normal-power mode before a manual mode switch is performed. - */ - error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val, - !(val & IQS269_SYS_FLAGS_PWR_MODE_MASK), - IQS269_PWR_MODE_POLL_SLEEP_US, - IQS269_PWR_MODE_POLL_TIMEOUT_US); - if (error) - goto err_irq; - - error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS, - IQS269_SYS_SETTINGS_PWR_MODE_MASK, - iqs269->suspend_mode << - IQS269_SYS_SETTINGS_PWR_MODE_SHIFT); - if (error) - goto err_irq; - - /* - * This last check ensures the device has completed its transition into - * the desired power mode to prevent any spurious interrupts from being - * triggered after iqs269_suspend has already returned. - */ - error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val, - (val & IQS269_SYS_FLAGS_PWR_MODE_MASK) - == (iqs269->suspend_mode << - IQS269_SYS_FLAGS_PWR_MODE_SHIFT), - IQS269_PWR_MODE_POLL_SLEEP_US, - IQS269_PWR_MODE_POLL_TIMEOUT_US); + error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, general); -err_irq: iqs269_irq_wait(); enable_irq(client->irq); @@ -1756,43 +1723,20 @@ static int __maybe_unused iqs269_resume(struct device *dev) { struct iqs269_private *iqs269 = dev_get_drvdata(dev); struct i2c_client *client = iqs269->client; - unsigned int val; int error; + u16 general = iqs269_general_get(iqs269); - if (!iqs269->suspend_mode) + if (!(general & IQS269_SYS_SETTINGS_PWR_MODE_MASK)) return 0; disable_irq(client->irq); - error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS, - IQS269_SYS_SETTINGS_PWR_MODE_MASK, 0); - if (error) - goto err_irq; - - /* - * This check ensures the device has returned to normal-power mode - * before automatic power mode switching is re-enabled. - */ - error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val, - !(val & IQS269_SYS_FLAGS_PWR_MODE_MASK), - IQS269_PWR_MODE_POLL_SLEEP_US, - IQS269_PWR_MODE_POLL_TIMEOUT_US); - if (error) - goto err_irq; - - error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS, - IQS269_SYS_SETTINGS_DIS_AUTO, 0); - if (error) - goto err_irq; - - /* - * This step reports any events that may have been "swallowed" as a - * result of polling PWR_MODE (which automatically acknowledges any - * pending interrupts). - */ - error = iqs269_report(iqs269); + error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, + general & ~IQS269_SYS_SETTINGS_PWR_MODE_MASK); + if (!error) + error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, + general & ~IQS269_SYS_SETTINGS_DIS_AUTO); -err_irq: iqs269_irq_wait(); enable_irq(client->irq); From patchwork Tue Nov 29 03:03:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff LaBundy X-Patchwork-Id: 13058161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB932C4332F for ; Tue, 29 Nov 2022 03:04:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235439AbiK2DE4 (ORCPT ); Mon, 28 Nov 2022 22:04:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235441AbiK2DEg (ORCPT ); Mon, 28 Nov 2022 22:04:36 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20618.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::618]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CDFC4A595 for ; Mon, 28 Nov 2022 19:03:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=azAgOGJ+wThRnO8fHLsaqoFMKf+J48h/zRaKYwzBiZlk7zvUCeZ7XY84DsdJe7hI/8B3is1E3OlJcoBmNlp0+F2WVyHbG0a9ZJBE1XZjI1qa6cDE9FJ5wz6STj0Jcitzi9jxyXIJFlK3nFHDjVwpouwj82nxFvJdecBb5IrcvHKmhpxNxdpmFdzHvkikxYGg59hohFCKJgHfLO3T/VaH6FsSM8Ivu7s8LBxbspaHCODnoluRPH9YoJkt9GUwaXRG+972MOwY7bhyKSFGcw1kYgwGQhhKPFBssptbpRJtMhacGX3fsQbgqfTcfWhDahv1G64ZibxQPeMGK1Ec9zfR9g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BhGgafrIZHiSyj32XqsGqpnKa19UUlOpe+UnK9UMClw=; b=T3/rCHM//RyRga55lzL+POVwO+7rCMjq4GSsohvuuVNAa9ScZIyKSR0kRaQBX/ZHbtDK/l+xneA+Hsxc+wZOQYfnYZ7xNtZh05bCMjaNxWPx1WcEocuOczrx+5BDroVqS3uEajO3IK/JPSbwdfNx9yzgXmO2fckQFFhYl/vC+XjquMFV3T+AgpJByK0Fm//W64helPC5CMqztnv7R/ecV99Ux0IWLG5096jdDbkijC6N94t6I/S+cFksss0Nm0EXgE7haS8akMeA94b6xOyMXgg0B2D8xth5j91CJmfYAa7rtBXjOL62xi8uXFXtLLBFOqeKUnl1xpzhkpmlos6SIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=labundy.com; dmarc=pass action=none header.from=labundy.com; dkim=pass header.d=labundy.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NETORG5796793.onmicrosoft.com; s=selector1-NETORG5796793-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BhGgafrIZHiSyj32XqsGqpnKa19UUlOpe+UnK9UMClw=; b=GWsFu4SqVH9kEuJ2hw2nkklqCw9YYrF6sohDOytvsesu77C0QswydggEEs2+lBzALujFUqTxIHv56dPRy+Udpu/IAVrLX7RtbCBBH6cOFjw1bG2NlevhEFiMhVQdzvMQw8RIgZ4RvKPKiinOUylmiFTyKE5dbBUiIb6hRfUr6/E= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=labundy.com; Received: from SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) by BL0PR08MB4546.namprd08.prod.outlook.com (2603:10b6:208:5b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 03:03:05 +0000 Received: from SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c]) by SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c%4]) with mapi id 15.20.5813.019; Tue, 29 Nov 2022 03:03:05 +0000 Date: Mon, 28 Nov 2022 21:03:03 -0600 From: Jeff LaBundy To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, jeff@labundy.com Subject: [PATCH 5/5] Input: iqs269a - do not poll during ATI Message-ID: Content-Disposition: inline In-Reply-To: References: X-ClientProxiedBy: SN7PR04CA0223.namprd04.prod.outlook.com (2603:10b6:806:127::18) To SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR0801MB3774:EE_|BL0PR08MB4546:EE_ X-MS-Office365-Filtering-Correlation-Id: 25ff313a-4e9a-492d-d46c-08dad1b63c0d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FkMI54b1NBUqwH2ObA6vRZfms8BA29Xvau5texe7Te3eyDToJZtj4iWxmTcCJNJgqtQJDD14ExQXMgEkWbudFwQwy/aeLU8xXO/wG+yGEq3+mJ4d2ztZX0gL18BJcHOrLztA28XsWLajDMGPflRzR8+6vCrcbaA9TfyN5Icp6JiS4u6AgV/eMOOUg2MALgvLitGO+lTomofUUS44oE4YVDDkOT9PBzlAxEMvfJP656UY2mlkC/uv2nbDoh72yjonqlpoiSXtDK9UvwV8Rzy6MPKa75Zpj2ENmSTBNfG6wUSocE6iXCQymI7MXyWz0qLxJoE5dWO7izU3zjessozOATXwyyFsFX2MvufsdR05CspEmMYQcfZSs2wIDD7tiRgs2nOOQtSyLtygZgM9GChZ7zgPnU99SfHkOlFpOT1bQ6GIKdHnVyf+/w1ZrmNDMfnNXL4jXAg0w0xdV3/WOwQmpNRDTJfm4Xzv72BlJI6+gLxPgbyBWMQt5k0MMf5KQpN5kejvFXvaOhoaculfLJB45ZZ0LJdmW8kf1n/lIn94bT94TuiuQfuZ7dJROuUM9lExHPNx43BK9Zvo7Gi+Ssae81+o21SRCKOSfX6edDxlAOwWZhHd8rbrqrJWA+mYJxKcgap5cNWRl1lm92lMMduQSQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN4PR0801MB3774.namprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(7916004)(39830400003)(346002)(376002)(396003)(136003)(366004)(451199015)(66556008)(8936002)(8676002)(66476007)(66946007)(5660300002)(41300700001)(107886003)(86362001)(33716001)(6506007)(6512007)(26005)(9686003)(83380400001)(186003)(38100700002)(6916009)(6486002)(478600001)(4326008)(316002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ic14Ld/TofD1t5J00stPsFeYUNbKXQqvL+pr3aQOkVCwCjVwdB7e6bJge9pFrQht8aiFD1QSGXYy9DJ2Z4fQd59i5mKZAfCVC7GiKjw7HgZKNlW0xzmkO07wNS5Qm3lF31TLgueM19tbYAX/IYAQryFPbsAmYiD/CZkLa2mIkyskQqiM3XoRD1EtRhmi6A6kkCpsj6ks+gvaaFCl/VsOte3HSacFFg7CFu4KGp2pJi2CQHCEzRklWKPo4vfzf1XMfmY8LFvR7KHRQIdDY1IEImKDMvHELl8PLJXDDFEcfRgaloNZ+6t+MVXxvW1RXyoBhTOGWMcbfYBu8zJMi4lO2yxdg/62k1/z8J8cVskBdRoGII77fYaDXxmPv2d5pFTBmP/VFE+GJRlYmWmX4YL0pSLEczp4EToK9WVQ3VhRZnTzFZhRv8IyamVRIOgWk1+R7m+eZtiZm8JA+HQ/MeCivIFDoBU9L83P/1VBGqyC1xhmpwiyrZF4bJW8ixm8W6hDfqPbGtR4wM8p9PvAnRKMDsbdRkxzwwx2QWVdz5A/nCn2qHOO0FofOj/VR2NWh6jPz5JWFd2e1hc84mtGqpEHUbcGWjBETbMAVDuta5qU1aOfFHKGjSMFQWOkLhkpV4I/zPM9wd5gsGR61nmD9oEfimU0JiAsyxrzW3y8Wbrl0zSWXiDXOB+UCyYTpDR18fCSCmPKVXjjA1njTEegvoYtTBAVuK9e3M/gA6rG5JwqZvEN24s35yTkpqu3y8KahsjhX3xtxUXiaH4bYhgU09PRKbxeSejc4BNCe7vY9d47jbzPwbfl5TVJUXnvK8CzvwnXEZk+D0abnKlk4rp841mHwQUMAQuTjcEAA72vgWmjuHjj8elwr7WX1b2PI+ppz3YkIxq6S8Uq3ioPsIyF5x2Vafbix8qcQA7mT1VF2pWIkFmegm+8d7dE5v8PYpyzOeo8rP+Op/CZgFDpqLLB1BFncD5sj+zyHSfGD1ab/KMFg3/HLM5zFBveBs/a1YVQ6MODbBWKc/tTPWxgAdYI396qjolgtNaoGATzbuqE7fG5mN8MFlUTts8TF72Dq6Qmfc7VcCvmHJIV/mJwQ28FhXGQatuoB683naw9mdz8b04DHHqMDQUAgRxQCkJ3n1gcLW4C293CJCxW1yjJibcPSYZMgH5OKkeqDwyfbkVXpfZHG8y4cp2x7Q/xdi6PoVnCS0oR5dypK6JfUowMCQ3LzU2gvpAQCaSE84DIB54Grpn5rnev4r9VRxgRFYf5TsMwe/p+amNyZz63Sw0n5nG14Q3nIlYzdttm+tK0rtuj3wRhmD/p1HbsY+SHE+3IOdIuxwF67B2+DjGN1DhZGR3jlsB6cvIToIC7w4Hc+SsB86AjB4IX7v1QlfRvReFJOiD3VWh6w91m+RdqlPB5/3E2BwTfa1Yof09bMNGvX+pdhWY/Egxb0E5Z2m13zxRpTNYG3MOgMsdXfBXIW4OaUr8TiAzTbVI8qgOXoIJ3I6g8tJKENFLwyj1jgAg8MMdmmEbVNGsQ97zrxeDgXgxWcW6kPHTG/t4Gp7076NILFqN5okEkTtV/GkBkaEjddQZDzJ2SogX6 X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25ff313a-4e9a-492d-d46c-08dad1b63c0d X-MS-Exchange-CrossTenant-AuthSource: SN4PR0801MB3774.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 03:03:04.9388 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 00b69d09-acab-4585-aca7-8fb7c6323e6f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sxPmOCpkCXiZytog350t4arq5++COdwrWtt+cZ2m2gtc+4F6VmQM2YYP8YhvJLyDV09gWEQKmrqubxHkvQKjfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR08MB4546 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org After initial start-up, the driver triggers ATI (calibration) with the newly loaded register configuration in place. Next, the driver polls a register field to ensure ATI completed in a timely fashion and that the device is ready to sense. However, communicating with the device over I2C while ATI is under- way may induce noise in the device and cause ATI to fail. As such, the vendor recommends not to poll the device during ATI. To solve this problem, let the device naturally signal to the host that ATI is complete by way of an interrupt. A completion prevents the device from successfully probing until this happens. As an added benefit, initial switch states are now reported in the interrupt handler at the same time ATI status is checked. As such, duplicate code that reports initial switch states has been removed from iqs269_input_init(). The former logic that scaled ATI timeout and filter settling delay is not carried forward with the new implementation, as it produces overly conservative delays at the lower clock rate. Rather, a single timeout that covers both clock rates is used. The filter settling delay does not happen to be necessary and has been removed as well. Fixes: 04e49867fad1 ("Input: add support for Azoteq IQS269A") Signed-off-by: Jeff LaBundy Reviewed-by: Mattijs Korpershoek --- drivers/input/misc/iqs269a.c | 97 +++++++++++++++++------------------- 1 file changed, 46 insertions(+), 51 deletions(-) diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c index eca680bf8c20..4e7b46d30052 100644 --- a/drivers/input/misc/iqs269a.c +++ b/drivers/input/misc/iqs269a.c @@ -9,6 +9,7 @@ * axial sliders presented by the device. */ +#include #include #include #include @@ -144,10 +145,6 @@ #define IQS269_NUM_CH 8 #define IQS269_NUM_SL 2 -#define IQS269_ATI_POLL_SLEEP_US (iqs269->delay_mult * 10000) -#define IQS269_ATI_POLL_TIMEOUT_US (iqs269->delay_mult * 500000) -#define IQS269_ATI_STABLE_DELAY_MS (iqs269->delay_mult * 150) - #define iqs269_irq_wait() usleep_range(200, 250) enum iqs269_local_cap_size { @@ -289,10 +286,10 @@ struct iqs269_private { struct mutex lock; struct iqs269_switch_desc switches[ARRAY_SIZE(iqs269_events)]; struct iqs269_sys_reg sys_reg; + struct completion ati_done; struct input_dev *keypad; struct input_dev *slider[IQS269_NUM_SL]; unsigned int keycode[ARRAY_SIZE(iqs269_events) * IQS269_NUM_CH]; - unsigned int delay_mult; unsigned int ch_num; bool hall_enable; bool ati_current; @@ -979,13 +976,8 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269) general = be16_to_cpu(sys_reg->general); - if (device_property_present(&client->dev, "azoteq,clk-div")) { + if (device_property_present(&client->dev, "azoteq,clk-div")) general |= IQS269_SYS_SETTINGS_CLK_DIV; - iqs269->delay_mult = 4; - } else { - general &= ~IQS269_SYS_SETTINGS_CLK_DIV; - iqs269->delay_mult = 1; - } /* * Configure the device to automatically switch between normal and low- @@ -1042,7 +1034,6 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269) static int iqs269_dev_init(struct iqs269_private *iqs269) { - unsigned int val; int error; mutex_lock(&iqs269->lock); @@ -1058,14 +1049,12 @@ static int iqs269_dev_init(struct iqs269_private *iqs269) if (error) goto err_mutex; - error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val, - !(val & IQS269_SYS_FLAGS_IN_ATI), - IQS269_ATI_POLL_SLEEP_US, - IQS269_ATI_POLL_TIMEOUT_US); - if (error) - goto err_mutex; + /* + * The following delay gives the device time to deassert its RDY output + * so as to prevent an interrupt from being serviced prematurely. + */ + usleep_range(2000, 2100); - msleep(IQS269_ATI_STABLE_DELAY_MS); iqs269->ati_current = true; err_mutex: @@ -1077,10 +1066,8 @@ static int iqs269_dev_init(struct iqs269_private *iqs269) static int iqs269_input_init(struct iqs269_private *iqs269) { struct i2c_client *client = iqs269->client; - struct iqs269_flags flags; unsigned int sw_code, keycode; int error, i, j; - u8 dir_mask, state; iqs269->keypad = devm_input_allocate_device(&client->dev); if (!iqs269->keypad) @@ -1093,23 +1080,7 @@ static int iqs269_input_init(struct iqs269_private *iqs269) iqs269->keypad->name = "iqs269a_keypad"; iqs269->keypad->id.bustype = BUS_I2C; - if (iqs269->hall_enable) { - error = regmap_raw_read(iqs269->regmap, IQS269_SYS_FLAGS, - &flags, sizeof(flags)); - if (error) { - dev_err(&client->dev, - "Failed to read initial status: %d\n", error); - return error; - } - } - for (i = 0; i < ARRAY_SIZE(iqs269_events); i++) { - dir_mask = flags.states[IQS269_ST_OFFS_DIR]; - if (!iqs269_events[i].dir_up) - dir_mask = ~dir_mask; - - state = flags.states[iqs269_events[i].st_offs] & dir_mask; - sw_code = iqs269->switches[i].code; for (j = 0; j < IQS269_NUM_CH; j++) { @@ -1122,13 +1093,9 @@ static int iqs269_input_init(struct iqs269_private *iqs269) switch (j) { case IQS269_CHx_HALL_ACTIVE: if (iqs269->hall_enable && - iqs269->switches[i].enabled) { + iqs269->switches[i].enabled) input_set_capability(iqs269->keypad, EV_SW, sw_code); - input_report_switch(iqs269->keypad, - sw_code, - state & BIT(j)); - } fallthrough; case IQS269_CHx_HALL_INACTIVE: @@ -1144,14 +1111,6 @@ static int iqs269_input_init(struct iqs269_private *iqs269) } } - input_sync(iqs269->keypad); - - error = input_register_device(iqs269->keypad); - if (error) { - dev_err(&client->dev, "Failed to register keypad: %d\n", error); - return error; - } - for (i = 0; i < IQS269_NUM_SL; i++) { if (!iqs269->sys_reg.slider_select[i]) continue; @@ -1211,6 +1170,9 @@ static int iqs269_report(struct iqs269_private *iqs269) return error; } + if (be16_to_cpu(flags.system) & IQS269_SYS_FLAGS_IN_ATI) + return 0; + error = regmap_raw_read(iqs269->regmap, IQS269_SLIDER_X, slider_x, sizeof(slider_x)); if (error) { @@ -1273,6 +1235,12 @@ static int iqs269_report(struct iqs269_private *iqs269) input_sync(iqs269->keypad); + /* + * The following completion signals that ATI has finished, any initial + * switch states have been reported and the keypad can be registered. + */ + complete_all(&iqs269->ati_done); + return 0; } @@ -1304,6 +1272,9 @@ static ssize_t counts_show(struct device *dev, if (!iqs269->ati_current || iqs269->hall_enable) return -EPERM; + if (!completion_done(&iqs269->ati_done)) + return -EBUSY; + /* * Unsolicited I2C communication prompts the device to assert its RDY * pin, so disable the interrupt line until the operation is finished @@ -1560,7 +1531,9 @@ static ssize_t ati_trigger_show(struct device *dev, { struct iqs269_private *iqs269 = dev_get_drvdata(dev); - return scnprintf(buf, PAGE_SIZE, "%u\n", iqs269->ati_current); + return scnprintf(buf, PAGE_SIZE, "%u\n", + iqs269->ati_current && + completion_done(&iqs269->ati_done)); } static ssize_t ati_trigger_store(struct device *dev, @@ -1580,6 +1553,7 @@ static ssize_t ati_trigger_store(struct device *dev, return count; disable_irq(client->irq); + reinit_completion(&iqs269->ati_done); error = iqs269_dev_init(iqs269); @@ -1589,6 +1563,10 @@ static ssize_t ati_trigger_store(struct device *dev, if (error) return error; + if (!wait_for_completion_timeout(&iqs269->ati_done, + msecs_to_jiffies(2000))) + return -ETIMEDOUT; + return count; } @@ -1647,6 +1625,7 @@ static int iqs269_probe(struct i2c_client *client) } mutex_init(&iqs269->lock); + init_completion(&iqs269->ati_done); error = regmap_raw_read(iqs269->regmap, IQS269_VER_INFO, &ver_info, sizeof(ver_info)); @@ -1682,6 +1661,22 @@ static int iqs269_probe(struct i2c_client *client) return error; } + if (!wait_for_completion_timeout(&iqs269->ati_done, + msecs_to_jiffies(2000))) { + dev_err(&client->dev, "Failed to complete ATI\n"); + return -ETIMEDOUT; + } + + /* + * The keypad may include one or more switches and is not registered + * until ATI is complete and the initial switch states are read. + */ + error = input_register_device(iqs269->keypad); + if (error) { + dev_err(&client->dev, "Failed to register keypad: %d\n", error); + return error; + } + error = devm_device_add_group(&client->dev, &iqs269_attr_group); if (error) dev_err(&client->dev, "Failed to add attributes: %d\n", error);