From patchwork Tue Jan 3 17:58:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff LaBundy X-Patchwork-Id: 13087781 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 E3F08C3DA7D for ; Tue, 3 Jan 2023 17:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238284AbjACR7I (ORCPT ); Tue, 3 Jan 2023 12:59:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238554AbjACR6g (ORCPT ); Tue, 3 Jan 2023 12:58:36 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2072.outbound.protection.outlook.com [40.107.223.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA86D11474 for ; Tue, 3 Jan 2023 09:58:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oYVC9E73yv6JVx6NpLsvlKrptCsVVT0mKYX6nqxMWsWZ3n91EqtywuqjuaIXUJAqNlh33c4PC0nx3PtZiE8RW/g8dqq2glcOPYXs3rNx77UlHZN3p6zFTBTSyfuJO8VYSH4YXgh8WmLXND6RIIAS7HH/MBWD4ll+OhPv4WY3uYnvJIIjr1MLyaLdQ0ssbBocWWzhmJnTLQ7VbPdmm+zr9ybbEej9nlVqsWTom7vSxMeXmlpzSTwFXVlhewUSuMU5jiPaP2aF6zQfkmbPF/y5GaFzwuEDARfDWpo5evZ+E6Y6273GNutHALnID9D658eXKga42Yvrr8TnFyLn/QHDKw== 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=v4O5l4+WxGyJVkUPN/TKSf1paCeWD8d1NAtRK6yvst0=; b=Z/YYgeaRknaW1TzrhC10e26rriSQeCVeM3VbXkT0E4YMyH+pgeBjj1aVkrXS4hhm/omYxmH7zMrCYhXilBwWRF7AfwPw7krbxlRySEofMQ8V4jO+yilAPvTaIUsKn61oaVrSlDqUs7cLS/wuBBrrMWCZRIJb0OcGA5hhe0z/sZiC0946SLvvJ2qyidXIDsoQAgmbTb7nrV+yiCacdGcZwSNz7pxQzc1G9UbdQU46Q0gBMDh4UadEQJ3kn/8R1BeqqMSiyObD3LmDMZZkQn6b31Ktu3A0Gf47crZ/2EV9L7jTS+KhYRfRxMZPuI76uZEldbFgvTYYDUcP9ouutHIEaA== 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=v4O5l4+WxGyJVkUPN/TKSf1paCeWD8d1NAtRK6yvst0=; b=Oouz50rIL9hgoTw32vY7HWprYYlOzs3WrRPfN/3bkuLlh0ecn1+0ZjHTv+hti/MBmRgHwAknKlfn6l7Pl8+YU6A9++prSsHJ8hzMwZL5YZEIA/pFREAXoXpzrh9Rm3h3pWLrcoMawnQ5oGJrbrCwXjaLKaObnvV78zCUTtXda1o= 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 DM6PR08MB4474.namprd08.prod.outlook.com (2603:10b6:5:9f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 17:58: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%6]) with mapi id 15.20.5944.019; Tue, 3 Jan 2023 17:58:33 +0000 Date: Tue, 3 Jan 2023 11:58:31 -0600 From: Jeff LaBundy To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, jeff@labundy.com Subject: [PATCH v2 1/5] Input: iqs269a - drop unused device node references Message-ID: Content-Disposition: inline In-Reply-To: References: X-ClientProxiedBy: DM6PR17CA0008.namprd17.prod.outlook.com (2603:10b6:5:1b3::21) To SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR0801MB3774:EE_|DM6PR08MB4474:EE_ X-MS-Office365-Filtering-Correlation-Id: 73a326be-3cd3-4544-3eb4-08daedb42125 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LjQVQFCKQFpK6Ux+RVDsqF/1q95rR8ls1rutPl//WB5m2R7YkdaLgbh0jNzvewBYYxvZ5NNbUGteYLoYVzHJswSEuNnQVbaIrbFnlpyXIf2TSIZB67sstIOh7z+ODNWb1LXqT7NkkI2w93r2MVsw/8sDzoCLyMMtrmRmbi7pXvzFrLUo4YY//aGntfBP2FeNyMHaOa7yjnmJOMErb2S9keUY2d5QZe+La/W4gvtnAZH3gMCYCKTm5mnpqiQV4Fpv5QoTzRLGup3zOZBZnWk67wy0RdcU4OYZ8ln4QbeFB+ORVeTbIZh+awgE/2ej/9ANhKkziw6eT5+iVQ6roxcbdDd4fbvwt/h4GLfD3AdnVxm+oalUW1nfc1DEqIyncQ41JJxCVt7d49meduZH+1uqYj191tKhppUqQ37/Qv0fFoUIpnnxtFYUakxK/I/QoHMFNR/ptRQRTAiKlYYFUbVBKi6RgUKEaujyy4DfQAxB1IhzccaaX+lJDXqho38Gdax2cv89+AH4lEVDvRyDgIdWHPEAtqBf3bvnf2HqqVdw1+JqE9B1oLbDSpE7w3aM6eQS+c46RUfPi11SKaW88dTkQ5itUQz/aq0VFwY59vHL27SvEgtJlOv1H3wITt9m7wXYIYU1t56PyuKGFPdXhPKXD+ys0szVzl/4zTeKaSuqiGrtnzwBOweIk8/Zu0kmnsje 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)(376002)(396003)(366004)(136003)(346002)(451199015)(6916009)(316002)(38100700002)(8936002)(66946007)(41300700001)(66556008)(8676002)(66476007)(4326008)(86362001)(83380400001)(33716001)(6486002)(478600001)(6506007)(107886003)(9686003)(186003)(26005)(6512007)(2906002)(5660300002)(22166006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9Nzfdsl2BifipI02bF8hqYKzRLBzzFy4s3cSsDg+4cbLvQ/kodNdQoRMox5qnO/Is+F8hQ+LsWFfbTEFMOhNh+DU7O52ruS0N5Z/j4TGpfN+1ewgmTfsH2CNcnRtYAoC27IUWZmE8HC/cz/99Xmh44VnK+LggQ35hHrM5wBQtA00ymnHYmO1jYxgWpXl5bW31DtccTc1op8kodHrb1zoiGa745Ij5UBMLIAu0nQTPBVXRCvPhU8UqvMzUuusgX+9VqMa9Dgxc5pbKuJgSScuNjba6DPMMDc+BafqEkRtwyl9redWdnVeIN3bwDQi1ISL+3ijGVUexW7j8HfVxc4aaD2Pc16HWsyTsoFc/3L5HPuM7uKH2xMf2cZPqJtj3WTOf5rfs1OKqySx/wNWVmfaSZEsX9aQwx1rPTfZUl34N768TXoj5IcagQia59AE9hdX0pO6ND6NtzJZ5X/iiFBkcwKQroBl8gW0wfb9OmLg3Zaawvljbhy6HtMBDbXivhC9JAn8iF1+V44terscHtIaz2e85sCAGhGQ57TI53Ny7c4S7sGHi8zWOK7SDNiHczzDyOX/L5mJIPFu6icNfQELVWKVK4iK+93Utho4izzAfn/6wcZwrsjSLk1pDr13E/eOq9dm6MCsTundXolStFR/6Nmo9igd4Yi/Rui3gbmVAs/y1QLPDOCjp/VFWCDtEXkaiQsVSTPbxHprlI8MfZqAZhAACwRmknTalG/0XzWy/yzHKlR6c5ft7LGHW1FXpBFS+5eJkdDsk0Rxmrhabz/zN6wn12dCLcsxwPA5AjKtKMmPu+SStysGQxRnPW3eaf0pHSpRKNEBboxuohQSBSRj6oZ8uUbd30W8R1/+5nxdanZnFL/9CO0qcfmWg6WVY+erayc3nYJsuanukW6h2uOeOsMHU/juSt2m40gFPXM7CQVMbb21dNGxu4pZhIv5LVrjQ9Nyl3WrraczY62GzWMIsblLnYufdRLNULloBU0ZaVCxdwzJWZ1lO1Ei6tuiD6Sv+cugRiWDAnVAkVfwbZ3L7Qk2m3M7bFaiDU2fd8xixntivaaftLJth1QsHiqjl4T2EbrOaINqYFDZAXuOmf5LB40Z4vbkDukNS0/EEGkm/ClqZCAO9qrxBYdI3pwfpdDiqQVpx0UMlboIkIf0FT0XX6cG3X2isHBgS8n27a5fZsZL/1DTdede/SfiJ+2pUITwdkN1A63KZhz37xOB++ucfjr+3xNgP37y80GgF3QzTgB/HP4ckx90Bjpha5rmufVRQKfWg5s3uels5oDFPQzyOhFEHRX035OLTAVobd+KPP9Tw4xkxiKUZYqKj3fhm4csc9F23uXObH8XQxz2gslIFN0YS9Ha3j5FQh7AUIG6MNiKXdyWROkAb6dUDaAl3IByutf1ZET+bgDC6WYH3mXPPtCOlK6a7+ATg71khIGMlnwTYNnZtdXyD6j1E7UhWkQ5sKVb8NSq3ugkc58LDDTFKIbTCqjyMi4aGr//1H8SCNXtXGpMp24wkjoqlohxXttmV+Xydy5KhgaXH7ffHkhqp8qGuTfGvB3+F6FOV/PJbpi4G3WgrjJB1CluqxlW14kb X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73a326be-3cd3-4544-3eb4-08daedb42125 X-MS-Exchange-CrossTenant-AuthSource: SN4PR0801MB3774.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 17:58:33.3737 (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: bQqkmvObTvMbOID/G+fuRW3YMDV/vYx2Y9yBxCu7nWB2Zdrk3Ac2liApBiRG7DdEPi2S1rgSIPftZ5aHqY3BXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR08MB4474 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 --- Changes in v2: - Minor refactoring of error paths drivers/input/misc/iqs269a.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c index a348247d3d38..ea3c97c5f764 100644 --- a/drivers/input/misc/iqs269a.c +++ b/drivers/input/misc/iqs269a.c @@ -694,6 +694,7 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269, dev_err(&client->dev, "Invalid channel %u threshold: %u\n", reg, val); + fwnode_handle_put(ev_node); return -EINVAL; } @@ -707,6 +708,7 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269, dev_err(&client->dev, "Invalid channel %u hysteresis: %u\n", reg, val); + fwnode_handle_put(ev_node); return -EINVAL; } @@ -721,8 +723,16 @@ 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); + fwnode_handle_put(ev_node); + if (error == -EINVAL) { continue; + } else if (error) { + dev_err(&client->dev, + "Failed to read channel %u code: %d\n", reg, + error); + return error; + } switch (reg) { case IQS269_CHx_HALL_ACTIVE: From patchwork Tue Jan 3 17:58:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff LaBundy X-Patchwork-Id: 13087782 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 8D64BC53210 for ; Tue, 3 Jan 2023 17:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238138AbjACR7L (ORCPT ); Tue, 3 Jan 2023 12:59:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238620AbjACR7D (ORCPT ); Tue, 3 Jan 2023 12:59:03 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2067.outbound.protection.outlook.com [40.107.94.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D10241182A for ; Tue, 3 Jan 2023 09:59:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ogxw/t6D+401Wd0PJ0ZJoqd1G2nzMMRL96BZ7c+VlSwo02BaeIzVbRmBybLqs4X4Srz1V93HgMZsAOt68KwmfXhhKHXERzgS9kw07/umz7VRidGJ6orj3CNnIa+i+9UcQee8mEShndOcbiEJ8Mr8d2DlgBaUmLE0fX6x6xM2rCcDyRjXkNISkAGw37fJfY26mqXujJH43sxTNJRnaSqzu8EKI3fb7x2/YEk4VTq71e2+afCRQUk7oNOpwqZK7fruh7aQc+jl4uDr11ofaEIWGhxZLmjHMdcHiY9TCEHMHTRs1gbfKGA7WkzjpDHfUSdmRIlUWMm1p+CQJu4ydUru8A== 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=GiA3tzweHmkLit8EUfvaBKSCoh6vI7f/8oOHY7/tSQ4=; b=MhL1jv73uJIwkDC1kbXLx3SEd9MzJ6F7cMWSgh8y7Rzu7iExNUqx5fPMb/1j/gK6BTjprUv+xkJ1xm1MOjfOwJBXRvaXxA62cUHnkffFLYYXCfePBJC9K74RGmPSGw49cvFPXBARuu70i+lnw5IzqrWqFlJWQXtXd1fGCGyG/W4GVIekbJMm4Kpx2ZRJksPsdRI5kd0o7B3ZLyHNHoEtJUjm0POU4DQBn8qem3vRzXwHUEPNZmSK6dnboq7aIhlhjAIddBruJ7qGhWAuSmBbBUIX18E1KYIxg9DoYmKmHBCRV/n7wBIqZ46UQktOgHGLpV47jGYkVHJkHClF0UWeeg== 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=GiA3tzweHmkLit8EUfvaBKSCoh6vI7f/8oOHY7/tSQ4=; b=qY/qBKT52o9K6aJ00DeWj5n+IPeSn3G/zCHiuP8FGc+uCsddXP+sRIHuDn5SgQLCMZcrbODVCeOKZgLZDYGfu5cp/LIrRF3Q1meL1+tXun6EZAkyuc2ExL6nPdSszQelk/CuB37FVB0CGezJte40jggg0lVQo/8XQ5VkVEaoI0Y= 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 SJ0PR08MB6592.namprd08.prod.outlook.com (2603:10b6:a03:2d0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 17:59:00 +0000 Received: from SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c]) by SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c%6]) with mapi id 15.20.5944.019; Tue, 3 Jan 2023 17:59:00 +0000 Date: Tue, 3 Jan 2023 11:58:59 -0600 From: Jeff LaBundy To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, jeff@labundy.com Subject: [PATCH v2 2/5] Input: iqs269a - increase interrupt handler return delay Message-ID: Content-Disposition: inline In-Reply-To: References: X-ClientProxiedBy: SA0PR11CA0056.namprd11.prod.outlook.com (2603:10b6:806:d0::31) To SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR0801MB3774:EE_|SJ0PR08MB6592:EE_ X-MS-Office365-Filtering-Correlation-Id: fa36c2b3-144d-416d-c993-08daedb4313c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CC2LTWEISrtrKiLX5VeV2bZHCC7UH11lmdHrcMV2ewIWoKvQbkOs4raeLZ4V6QXNf4itfCm8rz9KD75d5D62ijrXNMKdiRehdkTt5Y3TaIr3Bs15CFxkCM0k0bgsTMhu3v5xpUZsdrAVrt+ixAHa/SVEtbcdqt+WW/vsez8mchEO20xW2yJVBAPFvZIWorgV3TGddswmb3UjKsICNo5xHV8N2qUUkxaTkXdECyAxLAu5VuPkpkRm4Y1DRElce07Vgekez3aGpJ5RphcjP+i+yzmgmka/+u4AzmeQaDkcyKt1mm92s4vt175DKcndjurHTiCY6axbHhZGA8EuN+7XN5m48y8qhstRAaaAp3Gcz9pKyOUDE1jExzOJcoV2wov/4VQfz5UYJtUYV17TmrWCEjefFZIU/ALQmZFFJTUYsmuPoPsgAOXS39/1OQIVv+yxhuA8mTyLBPhT8Tb5ga+RxjxjgIawcRUTcfE9uLy5+oJnHFcMBCRT5p4TzocNSAeaDKcTAZtnE8XTvYlAicHtMBXKeOIooTid0kSYjTQAg8iPy7R4K34SSI7OgAf5rXRyFAL8UFZm7ipkfagqZV5qYAojKtAD2tEj3iXWCojipz9+v3ZDKx5bJvl5MWYwqhZ0DDamnfFMj0bJAd56lA9G3mBt8pWzdZHDAlbExLb11cc77gaX1hjkqyOWX+MQEtqA 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)(136003)(346002)(376002)(366004)(396003)(39830400003)(451199015)(186003)(26005)(6512007)(9686003)(83380400001)(86362001)(33716001)(38100700002)(316002)(6916009)(2906002)(4326008)(66946007)(41300700001)(8936002)(5660300002)(8676002)(66556008)(66476007)(478600001)(107886003)(6486002)(6506007)(22166006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8u6rYU2PJjPY39seL7fY1OokQlcL3C1lmm/k0V1acen6Yfnxba5LTvAVjv8KJwvsJyrZyY0Gx5Bprw0YSn/XQPwbbl27M6/dKRmlmh/A4CEeh9NwIZ+NKAZhcdM3K7SMOKf7AJrxsQRBjuGYjegVpNVyKUcf2Tk/8HJePUdIZqtOW1+LQMtm+lUvJ4JtkosI4NC1r4tmXUWwoJc+nSdDBNvp/xwREqSJ7WYBb+uGqZphPXl+JWEtaswIwWOhCbgCFNjZ0sz7erh9jaLVlVckFa+MHbOWClE/jPh8YRINYfjNcelXbG9UA3IW9S9weLjBM1YYdQ3cageCissptf+6vCBHKz/UiGjvzdHvN7PfCgb93GgqA00TntqzofR291ql6xj8DmZcBMueg3nZDeTXT/vcNZQmig0IIzVTv74d7Xjtl6eozc7GQbUMVFIYFCf1X68cR9GYhhEFLqUYsv+DSE8Ws/XoB16AZFQNGcuKUrAb2QGgB8UCRDMJ1+/xSGp5jfFfdWZiPtPBS9H9g1572uK5YPMuryR2Ppypo0gTfXNQnvJpFbHuPT591sNu6j+rIw9vK0Ipnkvo7k4hDZ4eBGdHjSRYqeUANbZ/e50BJ+LSgXqVT+CjlCoGjSl9VUrZLoyKCVPP7VN8qJHufYn2U/DuvuC0DBTWn0HT6QJVNmn0TQe9fyKj9p2/nd3wZbq5w2rGdVE7tx4T0hvmKUyJ/x2R3SemZoys+DI9xvAyOCpZ720uBJe70ej2k+8X6bAxohb2VXeQKLi9khApVk9IhG8CJn6yV0xv9Usq2oTaClvYMcTcRiLOUsSilgxm7PBtlAI0y2g0o9eOzyMxUVucEz4JtXPHlgI7v0HxXZjP8+dLtkIpOQOTVN5jS7C7cSGr0j26LJyDKZ3zPEK5oBGVsO2bPsXnSAVlJfRrrjyK5Jv2HGBU2MYJ2Ve5DWFnpH5h9RSPsMr9B2l8E3WEO4WuZXyH4T/kIIHADBPypOIhfhzUTBEFQKeC+M1myV1UAerphYB0E1YBVuTIJkRQYC7bZorKMFcYcgyDIR4b7T0QmOkbPegPyiWBmroxiF+ms75NbQjyGKZ1ML1PHQ9YarpYXbAYFW2nFFygz1G9C6GAzI7SV7puN3lmE+AO8hLjnJDu7y7ZTe2Dw1tRah2o9q7uDc5dQg+vrR85/0qUMP600EV9M8hWfjB5Xru5oJf+TCanqXwMQQG/ifKvG+Goh/1/PHJQnn2vQ/uBYIMJX6o7iikrDRuSQM4NYtJqizWJbeQFDnqUPKVg7a7D0zt3ecV5PdIszBiKHG+BT5MMJiaymyyb/McpDv4OrGwC7zV1pfU2aramcVNrcnOtx/tusutsMLxe/ah36xj5GCu5wOLj+O3AUL36gk9MeOvTG33CbFhGV8yQvI8VihIvPDIX8p1v+zJ/Vw4uUyn1S9DurgWs4yGsC3rz0gEhsiF2dWzoru2jmv6ynjSWfNSyxHWe0BI6q19Jrr2py2uyNiTzHhTub8iCCuDk5ZIOPs41mJCKgltx9QDGXRoB8GeAafgbgMko2oOjKbqEdZMRCbEWA361E/h+8r9l6vBBgnecofHOsmvw X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa36c2b3-144d-416d-c993-08daedb4313c X-MS-Exchange-CrossTenant-AuthSource: SN4PR0801MB3774.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 17:59:00.3403 (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: G0BpyijZ0bxEbFsK50fzkw0ELD+FZ84S3j3c+HperTEaKgUI3oe64wNaWP2Ktx+RXoi3R7sEsEyuiKGrlSrCeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR08MB6592 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 --- Changes in v2: - Added Reviewed-by 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 ea3c97c5f764..ea3401a1000f 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 Jan 3 17:59:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff LaBundy X-Patchwork-Id: 13087783 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 34282C46467 for ; Tue, 3 Jan 2023 17:59:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238401AbjACR7k (ORCPT ); Tue, 3 Jan 2023 12:59:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238339AbjACR7R (ORCPT ); Tue, 3 Jan 2023 12:59:17 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2064.outbound.protection.outlook.com [40.107.94.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDF4111A09 for ; Tue, 3 Jan 2023 09:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iRnMD6DZTfKqb2MWTKKUQnKwXYZ9KSQ1Ioi/mHVvVBU79OaLpldgYxS4JvsFAd0nMaETmDeRlbBinFim8GlCvaXUDyYY/Zx8wdo4rUwBd0dczNZZesaADNzYKEzGqkvGRoQfuZtyNk7/2bbiEP6mTMsPTCb29T8Asv0/uy608/kWMyDBJCrLElZieFjD1b/eG4XS8+RFIm1EIEloitU6zdJnphyvCNR+GqrS/e7xZ+pym04Uh/kN1ueKKJSHAtxjJSoCZJb8vjJfL+7td223meyK8FMy0mR9PqGQHFh3Lof4IOz6WWzfm+bAlF6uVbxUlHJtYB6D/xwcgmKjn+LiRA== 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=7eCUba0lerGkttyGd3zinZJ9+4yK75ibktkHqKSZm14=; b=ZzBcvMYrcwK8xTi5epNj7Osy2MJQq+hJFxwpjxCxWuBsvpqQcA7rtr97YxkjWvM9oOvSAQbqFNgXw5+w5gKxvxiUmIHVsRRflp7TniOjA4WdmsL6v+rHLqo8HY8hm9a5l3MMaLQUG9nPFXWRbfXkr5d9QDe2ck6zCEUg4VGcVUnFhydYILIBIEZS362Mk8uMePJYbOVdBkbhrQbIeWEhgbbw/5Omd7E7/twfLrwbQ9n5lw8fXxwYbHagSc5Hlwvsxw7PwYAEJiNu0wcH3mEsl6E/IPwbcuHIg5Wv3vZ0wK7NgAbVpm+XyioLOfPf1dU74Eb09whRxlACI9nRFAk+3Q== 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=7eCUba0lerGkttyGd3zinZJ9+4yK75ibktkHqKSZm14=; b=qmzHy3PrEODux5r7XI+BzgDEO84N93ArqouSz8Dsim/jS+N3r5nasDdzf4jz6xU8ej5TVMNM9Lw4/2Xz45Wi6YDZUi+ofj8n6oKwVG4qlH0IMTfBqU7++lBx4EUSIEyr6VPlozLSDFKZcG1dPirKllRPIEC4pNPYUc7lomQ7MfI= 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 SJ0PR08MB6592.namprd08.prod.outlook.com (2603:10b6:a03:2d0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 17:59:14 +0000 Received: from SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c]) by SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c%6]) with mapi id 15.20.5944.019; Tue, 3 Jan 2023 17:59:14 +0000 Date: Tue, 3 Jan 2023 11:59:12 -0600 From: Jeff LaBundy To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, jeff@labundy.com Subject: [PATCH v2 3/5] Input: iqs269a - configure device with a single block write Message-ID: Content-Disposition: inline In-Reply-To: References: X-ClientProxiedBy: DM6PR06CA0016.namprd06.prod.outlook.com (2603:10b6:5:120::29) To SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR0801MB3774:EE_|SJ0PR08MB6592:EE_ X-MS-Office365-Filtering-Correlation-Id: eaaaa282-9724-42df-c650-08daedb43981 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JfqMda+9xv8LkNn2H1BHJT5/Au49/HwA8p+bbcDNYSLRf+pd+6Agt++AhMa4D2UCSahdKgEKINzYUo9mqnteZdd+jAl8dIXtFKE+PS2+j9O/iDG5oBEWPfVTra48/HEnxQIgsknwmciJIppuTdXjwo4XB/HwueTYeJ70Al7ilJvR2cg15j9HZ3Gc/jZweLKCX1OdiksKruRlSFg1hL1rJApY/ec3q+zReIxmwVopuzlZPONRYoezxdjTMhZC1dqieBvFaj/NNVvSfc+2cpnlHBfk0lwMIMIneH9axyYlPOCBxRChsEZT7qIJJll/ImX1HH4z2uUH6B/jPTLMZaAUhcJvL+24qD5CBaSL3V9fWgb7T6095DaWW/c7YTCj5vT/g5CfkeTJFS2022NKvJebBoDqRhYmEJcQ5MtmvDe534egrC9LzsjOUKjj+lMCJ50hrI3AxLikSJYwy8sJfV8SCNwb5hEGQgJ3diDoJdG2vD5L4NdVnrz18m2s0Fnk952wAy+65vbYYXERd2D+RDkRYyUUiC93VrXPhVmKwngicqhaYMER+kzF5fb6YbJEfo+JkcCnBW8V82DgaIH7kSrozMY+J1c8PR5yCT/BDCKf/xsjPiLGv8LUFbXvBzoy25UvzeZ/CTfNiOc9jz51MdcubIh6annoI6t6GbiIdTJdvU6NFJxgRG+YmUTqTDMnWBmH 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)(136003)(346002)(376002)(366004)(396003)(39830400003)(451199015)(186003)(26005)(6512007)(9686003)(83380400001)(86362001)(33716001)(38100700002)(316002)(6916009)(2906002)(4326008)(66946007)(41300700001)(8936002)(5660300002)(8676002)(66556008)(66476007)(478600001)(107886003)(6486002)(6506007)(22166006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cIWUEi+nvSGdIqHh9b6DwQRzo/13Sc8hsH5Wx1+3HU/NVLVfy1AD5/XvESMOsZy/g5OaKeEYT7HAIcUuVlYMNGfU5Lg7HS5zYnUGoTetEf6SxOPe0aF+Feno1M495RDnIqROhH+uZ+uaT/TdZVikvw5lfYPjfeUhLu+3bBteZrvV3AlCYZL3FkkO7Bla2h9IQyrDfA984ue9yYaeMau8fT7sNHGdyoLKlHzCRlWw+5NlRi6a5kaEf+Y+9XX87KPKhP9WsAQJOT1fkPepcR42xWySuqa/CDUwtNYm+AfP6o4dTRcF/RTC7Jl2SoZFQEtAtkgU+ivDI8GydJfNuyMVKxMv8sS0EHFqNhKfDrUUl2lf7HAKV7AtnlyuxDiqKoOi3zgvXQmMfNP7ArXmONuRu5abLVFzFrQIOts6lsbmezQBuzMej9eO2nCMYbhwBPnA3amgjl3X/eZwjUtn/1+tf562j2FL/9y2qVGYwiS0xQ4tl4Tepcq9h8aZID9QEsswIpbVFjJz6ipVgfWpZAH6cVMz6i+HG+FwVuJxfjjg7feFzkClGjVAaK7S6vy/FSylr8BicstjzDWM8MNhrLmUKRRbWqzOdar+qo1q4chBBMzjDrOXFXO7UUDzrorF8TtXWThWkwe/Gw+/Qyw/mUxvPRxZjR2nziYlagQ1nF/iU1R45fMna5wPCm+xX4sxYOm/OzQtN3hZsoF71MPryoSZLUSfs1hmUAsCVWS8IbHmrFJDwxy+dD35bRTv9/5CaqUpciOje8B7TcVjchY5xjR4udqc2CRRyL5GOP2u1Cqc5u8et7GHmEIDvZK2KKNyirr/8iizdvKeAYb1zunB4maLERG533RlsuDPTJIGW35EWBHIPk6tRLOVTAO8rjIjpKdKcn9a6tKn2LTZ5kWl8Rmwc3jBWP3AQddI+eAz3XL24GKJAtk1lMSBaL9ButlPtHzT09joTeH7VHE0yaAi65MMMY5HAlf9xudSlwL+TNE5chkoNDjxCU0P0DvsSnUOjAz6MEXHlgCsPC0IMlzmXCYG3ulhJ+3OdBoxDj9b+pAFELRi47fyICxjfbygQspQj5LJioHJa5A2LIOEfhHqb0kASVsCsmw7HlFK4yDyRCmgjtRb+JL8ZykG5n2IvDb+q7Cj7SB7Q2vjIB7/tgAo9lWSg0+e2Zf8JUTEoxM7H3hnHjH1tMZr4fZE+19pzclieyqQVa+oU03G1WnT5KVoTWL5ReXyHgXKZGzOJAgmxg/ESdJve8Fkk/RWZAVCwk8eiGwa0zcLp/wfrhGjMth/hSqOE9dK8tTO438rAkL+V0K4VTc+WHJ2MIrtFBm1ae1PyN1quN7JgB/5/nRkUqDGHtLOUtKAUN0JJjBJV7YVWdac+cHHN8jZ9kDQ9PVKTc5bLmt8TdcYjvKII2/cpCZyvnGUlVFaxcsMcS4az3D/zeC/3Eb1cycvE4HRdGelh/Bvd82Pa9PjhmzIkhj6mBcv723IADQSgSuSgVLUt3D0HvEgufVE0janV/zRZyg8wjFNv48W3Q1abV6cgYdqncqqoMlLaTk5CVv5uWWXLFYTCLCyNPBMLRz2sjFbZMbg+cBMHyVC X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: eaaaa282-9724-42df-c650-08daedb43981 X-MS-Exchange-CrossTenant-AuthSource: SN4PR0801MB3774.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 17:59:14.2298 (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: C8nDdceFIGoRwt7a0BfJhee6QdfCiU2BHLp23nlyoSTGTFO+dVrP+XWghO7LMnSY1qbWNQKjANXBno0f5ImUAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR08MB6592 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 --- Changes in v2: - Added Reviewed-by 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 ea3401a1000f..1530efd301c2 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); @@ -1042,10 +1040,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); @@ -1055,27 +1051,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; @@ -1349,6 +1326,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; @@ -1363,8 +1341,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; @@ -1444,9 +1422,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, @@ -1454,6 +1433,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; @@ -1466,7 +1446,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 Jan 3 17:59:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff LaBundy X-Patchwork-Id: 13087784 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 3AC6FC3DA7D for ; Tue, 3 Jan 2023 17:59:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237887AbjACR7l (ORCPT ); Tue, 3 Jan 2023 12:59:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238537AbjACR71 (ORCPT ); Tue, 3 Jan 2023 12:59:27 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2056.outbound.protection.outlook.com [40.107.92.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2984711472 for ; Tue, 3 Jan 2023 09:59:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LRF9yYlT3tU8YNDg5FmFzaJegdD2Du+T2LEcdENzPdZnQAPMfRkBeAnxXDzlA/sQLVaN2F4cSvhp9Az8rm+xppFRrwtDbE4qxXbEZ4loOfDBz/Ct4m4kRug8jNqRnoiapDAMiZLNpWvs/JrFML+VsQcTJjSorub1TUURiNR1cYsucelY1s22hScar4PaaSnEQVNAlR6cL1LF+gzJhybO0If1Q3cElx1i20/MneSGPsmS/FU0QGaXx0m+miPT5tQZ7o3PaZUAnvkmvS3HAzVIIWGklPNr1R9oia+AFq13jj53LfFtw6iPTZRI1ts+W4gpu6XKkirXst3nuNpfOg18cA== 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=uQW/uQFOn1Oq3Y237O0D92XgzfQknFA1ouydCXhnI+0=; b=P7p3OmTSQTtA7LFDva7wl/ttsggniEmLz8HuVFDcMMsM5TPhLIF9L4U6mgNEdP3/lU9ILeMfUR+QdBqxZpu+Hcrk/VfV4zFnc6aE5qw4eDiLrM5SttfO7tRKic0S/f7ErnUfKVTpvWiq4u16wT5kaudXFBktHJLu6I6vmxTgpDtan/Ppqw/u0JrtXAr103tKFplhE5Xh5mi+o4wxnPri62JqiPr6tJNBAsd7ZkvZBFUsGkslibFBqqEwWyiKcq9b4P1OZUpnvOaqvBhJVI9ZnRQExctPteMBDPdH7i9GtOp2MWEmCPvGiUWfueVx8+Z0ezYFsnr73LBC7Xyd9p9i+A== 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=uQW/uQFOn1Oq3Y237O0D92XgzfQknFA1ouydCXhnI+0=; b=fmlGLAd8YU7/fThjE5AJQJDQnA58Wbd7zhX1167Fm8+nNXIBYnzX60v4vvErweH+RjZtSvAUmHT5PHS2orvQGackl+5qh0Tdof3DvbZQ6DHcaKxQ1pY5sRYoVk85MA+CMsqIkGHirw9H/JghmdFjiK8HBojqcTETGTlP9nieTDM= 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 SJ0PR08MB6592.namprd08.prod.outlook.com (2603:10b6:a03:2d0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 17:59:23 +0000 Received: from SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c]) by SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c%6]) with mapi id 15.20.5944.019; Tue, 3 Jan 2023 17:59:23 +0000 Date: Tue, 3 Jan 2023 11:59:21 -0600 From: Jeff LaBundy To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, jeff@labundy.com Subject: [PATCH v2 4/5] Input: iqs269a - do not poll during suspend or resume Message-ID: Content-Disposition: inline In-Reply-To: References: X-ClientProxiedBy: DM6PR07CA0067.namprd07.prod.outlook.com (2603:10b6:5:74::44) To SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR0801MB3774:EE_|SJ0PR08MB6592:EE_ X-MS-Office365-Filtering-Correlation-Id: 85dd109d-e5bb-4aa2-b736-08daedb43f02 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +JTWS1Hd7Pi6yEaOQ03SxuC7ilhBY7KiU0vs/r+GR2Qh5SAZuChz8zClkSjEaocaXMsdM9t0AepURK+vqCkXstiXre+zumg4y9iwjTeUcJXYEdzuAUWpG+LeFtWE702Ng6BeJpd5onRcu1Zx1etRnvqPIpfaoghG8NBLT7af3LD+fGVltfyJ3P8U0zxBuqab1L6NyLc6/AbTg13DdgvRMt3fQWoHX2PWu5CN+d4qanFBJSvF3DBNdYIW4QtnVpbWkRvc529kL4PIyJOwXQ0c6cyXafTBCIKKcHjf+nT1UKFm1QAbjq6fGaFgW+qxE9K+7YqAC5913ZydQ3PZ6Z5ZVMJqRk1/9oWDBP8ei4YhP4U/ekvvbFmGti19dUG3ZFEgaXrcgElttVOL9LN2lw4SCfnOan0W3angpabzVqhnfq44/B2xL+vMVXtUNGzyPb4H03m80KKcTHTFUjxFL6uEXTcTj5R9yRbzL4hNCJTs/ne3f8YW0mJYzF3OvoRgXRlYFzO0pH6YaUKtHPBy+XEc6PgzXkNWQQupK/LR4dfOR+H7cvCxiyr9JHsE5J5nN8zNqfBQIbARmDzDU9+cvMGawkMi/6gwnpPTYv/jyxKMDN58DFBy2txCVaq5vYYiP9vK0z7cyBOZnth+HBwWaipAYge1GIvT8Kp9s+8YaSWqJJbDO/L2M3eEtMdD6cDEEky0xlSmHZahkUR+cayZjWWjDg== 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)(136003)(346002)(376002)(366004)(396003)(39830400003)(451199015)(186003)(26005)(6512007)(9686003)(83380400001)(86362001)(33716001)(38100700002)(316002)(6916009)(2906002)(15650500001)(4326008)(66946007)(41300700001)(8936002)(5660300002)(8676002)(66556008)(66476007)(478600001)(107886003)(6486002)(6506007)(22166006)(67856001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: esgI8lIATjbjoFxBgKRcJBeYYbfBBGlcGQ7FsHc4AfiZ24eFCKP34OXtmTTkX4SMFhoqpeobz6R32ubm2SY7fLYWSfraJrC+3iMrmvsL81qRfkh6zcsFO6gfMzmt0eY1WU1LjRwFUvKAkB9KFizOpT34blpE2FtIKeNMQboQU0bStmi7brNq1sbwDBe33x5L8eQMwevhivwfqLfFB2Y4+xcz63MW/NkXtp3Qn4hfPiIxRpPuv9ahEyWShl9GdSD3USn1EmSgaAGCOqWnWuMmHssCPaRlK1+3iYqpXVaeoMvKaUehIbsDUORRBDMqAnlCEaG0GG6LuWlw5cqBXjhvMk9Hw1ra2gJRrwkUstePBJrHUJsLSuGVeEysuWml0IzjVZNlDJ0bZ85IYVDxxs4BEdfVDQTwscNfw6gnlHUukiEVe1E6LKlxnq4u3Uxtb/Tq2YxcZ/Q+UjAmeOekUZmcGE9heB/5UCmw1EnHX7MvZULBP+cIJrHsK5Zngkrq4n2iEwFiO+UKIyY7t7NpBaIzr/y8UZCVYgsm8lAU6rTOdRJAZSoIZ722S+NJdhu5hGOWEZiJo7cvkKed/JW4/BGoALEuvwNfOwWzM93A3UBkuyTGEgGhV+TH1/35TZV4KeM3rcbY/ymBFkouzNAY2UxeTPhnsQCKA5s/whnzsr1dEeM9tQ44nYuwwRP+HOE1S/Ka7MVYvbORpd9uF/6A0v4BqG9yHowBqpeJhyLyfimf+swK/YN+f9iZKV8s8clU7MlN6bI5H5uKytbNhbXQ/yJhi0/nazGMb2AveHjwjFmMQTWWfVUhcPU6b56w8w7fRbU5rXCpjemuTU8+g/xyN9Upyw7kb/I08h/s5IHthPf+VvpuUHiYrmEVP6XlR9ZsFrGTuok/0uBwcf3Xw69EMNyVzteuA0oVcwiAbXIHvtbYU8OlgDAinmT5sZS7iUf8P9aonbnaeaGxsJt7MzX6V6CKqMFqXsBYsR72C2NFVEjAlkI6OZbcAi5p/iT6QGNpDR9cJNPdVANQA7+Y7b5zmzy7wqQPwQJOCZcDpzfIrJ+n1cYNatC2ni5lxsqGzPPA67vPuQ1DcP8RcLrQRFROhoYG6DTHaUQPh697akIsH4oG2mc/+EzRxpNntOxJHTnfbeFRHF+b5F7w8WYWLyuklIM8vgDLV61DfsmkdBPyD8Nsda1xeIgKPV4BKPyk1WQyMBnBeXRMf0ZYATLo8XqYNvpVeE2EWEkRQnKKQUU96TYU3EGO2y+f96HVbNzC3DPLcFxx9A7kTwvtiim8gbAniArA6axnIAAcjyVkKUcc1ziAJntTH9Bjs43AZ+g6zVmlhbt/HFCHdpejhpahqPOam9og/Tb5mK3Z4QEhO1ockG11qElVx7/bFZr2xH6omiY2dhjyKRqd1/aoKvTldmv0i3llsFenCe9ft+gHdSQ3G7SictZX4Xb4ZU2rUlCPZGAESaSJDKbiIrdrO4BGj+W5JbQlPjsk3iUr/Ir1xU59SsWXzYwiBd51z2ecn/3pFVFNt20NEWJH8dLvgG1T+O82sIkkEkxv5yXUoN2gWovHrdcUIm4r6Jo8WZTwgpzlMs8lceub X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85dd109d-e5bb-4aa2-b736-08daedb43f02 X-MS-Exchange-CrossTenant-AuthSource: SN4PR0801MB3774.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 17:59:23.4635 (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: sQBhUyJfb4cVrN9pP8aOVHSynkSGIFnAVvOFVWwrOOCAdxISPd8lWLW0ABvbHG49ErAiziVUHoU6ynsw0gMZKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR08MB6592 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 --- Changes in v2: - Added Reviewed-by 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 1530efd301c2..814d1a898e7f 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; @@ -767,17 +763,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) @@ -1005,6 +990,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) { @@ -1687,59 +1683,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); @@ -1750,43 +1717,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 Jan 3 17:59:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff LaBundy X-Patchwork-Id: 13087785 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 5832FC46467 for ; Tue, 3 Jan 2023 18:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238203AbjACSAM (ORCPT ); Tue, 3 Jan 2023 13:00:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238434AbjACR7n (ORCPT ); Tue, 3 Jan 2023 12:59:43 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060.outbound.protection.outlook.com [40.107.93.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 645C311474 for ; Tue, 3 Jan 2023 09:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ICLm3V7CNE8WMZy4qLFQZV9bmT7Vcbb+3gVBjdB6jr7Vz6HBkDs9cDs8Ei5HD20k4Xc7+fqYuJbEhVHd/KFb5XGmlvEsyiQ77q0LNibTAEi2+PutAHQT9zAWgcQiMnGn39Zrf6vmnzEAdLQ/Vurwo2TRZRR1lifrhPNOA6rjXl0pe8YU4LX75ghgupFf45fg15SvXvGBGAIFSW5021AAUVCbT1QcuBpufFyViKvWyVAkMJtweJnadnYB4z5CyTI6v61PiGhQ4iA3yhE15klt1UL1urpT3sYfNkPV/v0PUUTulUqXXn8BVc8VMPpfC6QRJZvGnQaJkLystnn65njUEg== 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=3IsUcineFaX6YbpxMopOtJLpV9QYnHIlps8mGLCO4S8=; b=hfmxyB6yE7KaKKSKJcAlf1uPoJruOsXWX3o/fmIMGVTC5bGEnuNibHlHHZ0xSbwAANtFYHs221sfC2Ws2iRyQ3n9dRmhJEK2JV2xNkgBRBbXiAwW89axk6uenm64MgNWGit8W0WuQcTYmlRamKMOTACMAKLhgDEX8zWaJIqDP4nqGbVaiyPxGArO/Q/ulbU7oyOOdjP9ZSZcIyEFawgInjebI9eeRQ4+FQRAEvijqRHVICYn4mIaQsqZE0dDaQOHSILnMsAdE603tjmURoiFL5eeX4yIzdDpvpDG8WYD+k2PcmwKLcZV5bgb19uZe+4wzBLXqgjHoLRS3o7AnaNe+Q== 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=3IsUcineFaX6YbpxMopOtJLpV9QYnHIlps8mGLCO4S8=; b=ZcR7MSJ0CoewIjuqGi0a5pgpz86mVCUjLyi9Yv/UEQYdsC8lINq+KaL9sIgNJoOp4A6tXZ/4O14kiRdV0W1CiwIWdIu29i6YtiyjsutaxKUmQI/u89cWPhuvAQ2jqB2QKi8B8PbSX4jb6QK+lZHSpq9e5CW3N/xuQUiCjz5/AVE= 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 BYAPR08MB6005.namprd08.prod.outlook.com (2603:10b6:a03:c3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 17:59:37 +0000 Received: from SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c]) by SN4PR0801MB3774.namprd08.prod.outlook.com ([fe80::ea42:ebaf:dd18:6a4c%6]) with mapi id 15.20.5944.019; Tue, 3 Jan 2023 17:59:36 +0000 Date: Tue, 3 Jan 2023 11:59:35 -0600 From: Jeff LaBundy To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, jeff@labundy.com Subject: [PATCH v2 5/5] Input: iqs269a - do not poll during ATI Message-ID: Content-Disposition: inline In-Reply-To: References: X-ClientProxiedBy: SN6PR01CA0013.prod.exchangelabs.com (2603:10b6:805:b6::26) To SN4PR0801MB3774.namprd08.prod.outlook.com (2603:10b6:803:43::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR0801MB3774:EE_|BYAPR08MB6005:EE_ X-MS-Office365-Filtering-Correlation-Id: abfc37ba-7298-45dc-6c5a-08daedb446dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QgIVlUnVeitXG/kE99hhA+F3rbkDzw+5W+Gn90zJ4gEM6LlP7z2CN9ZzhHXMkxvW26qehL392GGpZB0JYI1Ca0yK+hnE6r3jk/byg542SeeOCPqWNslgZd1zGQaaazxTI7B5gUUQKGew+D/smBA+rZsvzwi71e2vy/VcQURgLIOdA+jTxaUbt58E/O+GgyPyGLGvP+39yec/ouUNFqAl7Fnue4LepmWN52uSZkZ9JCGn1aiEc7qPhwo5tH9+G91y0OKoe2zZYpw313EAyJO64cn0jMGwm9TQkN/YwJIqDenkOQnU1haZCzAqLhwqZCthNadeaAjPV+yv7wagUCCLEX1lFCtJ8Di1r/5x6+WUlAtREJU2q/NW/iir7SHH0o09jmLK7n1HzEsgE/Jku7hP3xCQsaMN1WU7xvZ4lcdASum6IiP3LeS2rfaIUXo2RRsweF5vGi/72RYGLEuaN56I6rG4/JlhpXAdV0ceT010WPmPcuyDvYfvI7ibb7nLl52Pv6+e1yO6nIPtJCWTMLnGWhd9XLqC/b2og25pb8MkMAb86by5V4TEGYN4wityCu0tdKMghKoBffzPzeXIgsqXPHGQ1424w4dG4T+aXCCk8wFM4KQXQ43Q1YRHlPmodrRTZVvBJ9TmGHko0ay7Z3/8QdA3TVURgIP/Q9gt0yFHm1OauEhfkZMa1p/PFoQl5nxX 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)(366004)(346002)(39830400003)(376002)(136003)(396003)(451199015)(86362001)(4326008)(66556008)(2906002)(66946007)(66476007)(8676002)(5660300002)(38100700002)(83380400001)(478600001)(316002)(6916009)(6486002)(41300700001)(33716001)(8936002)(107886003)(6506007)(9686003)(6512007)(186003)(26005)(22166006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FouSlR7OTtktdsQoaiLGL8NxszreeEfn8Sv4jSCj92faSBOqygYD41dxmosVVVmCZGj/588HxXpgy0zgd2pgyzz3Q/EyUjslzlNEX68GrfQseL4vnxcND2xVl09bMm39FSWHZTdOnpcfF1IgbjYWmMmhbPh/qy1xVkKiGXspI04qbLZsYtavtvXeBPMPrUyVNwA+3zKgQlgKShONutAxo3aK/RyDdWu9Ik6kwdv+xARc0CbHrSU6cyh9PYVbs/s65jdGzaSvBSmDax66XtGOqf2mAUsrgNZRNNyFXKqvoMWNrp+LZNcGT8LY1E8PUqTFKZ6ZEgWPKs6Y7YiNbQk3Q0uxP1c3I6m1y07yubnFgp6qXKuhnbUdOq7+st3BR0oe2Zjz+FughH7TI5IDl+Px22DfzQIFCAjbGkGyYxxch3oyOGt49OelWSyzE8PRw/Q3vgghaTwQ/GyYeDjwtQn4W5xfbw8SrPIKCsNS0zIa9Fw7Vn0XX7LClQZvjIrQlT6hwNDxOHMTcKWsI3GvWVCwLgRRsZDF19Y9XtkKmsQ0VoMFvd6NX/XUK1sD0MiKi5Sb9ARIHSXrveyiib5zBbkXy0TkcHgMyGyXer1ESAVY57OPBwOKz8R7UgUifRyjXYDjVDd/LYhsiOC5cKvKwq5I13nhRyxua2HHZy77tLxL6n3p4KGWl25J9Ohn0ivSCMXaKfp6aofF0eZssNe0lx5aS6+1TZw4OLtJgpWolAky/AhFoZj4BkKN5mDznaIom8/rpakLXpcscjHwCoSB1i+ySx9d8DMvNRsKK6y4HYPJ+qfLFKxfLh7dBf+1nuEWSH2KuZnZSswYh/j8x6yOHS+nD+ZVZCajGq2adrxvCT1onPIVU1EOZA33PfIn+uyuflgIxzZclZq/zH365hvKnsxS5kqKWmAwAOEaIM9sSVhDYXZI1gjiBTJqWf2+eqlC496XIrS9FzdcXlKDxr5LPDTXwvfCmJdzbIYxmm49MB2efyIvLf2D5DObWXjF4hNUp9dGuCHgKBMx2x7XArc9HnMZV+xcW3WSfBSXPqRXRfAiRD/Nz1EwofOyc5CTTRIxt2Q8EKh5Gwls9q0UyNOCPcmqFntEFqh2n26QKBa+nLPxwYKUTXvfZlO7kyMEqUL/zb0/fHvn7J1uFFOCp6Pic1bD73r3XaHL2WOe/ttYS3+9RLWePc477w7zeek6QkzbMj1d/WR26Bcx2a5IW/ZGMHXMbq6J3pI5TzoP6nAcxGEy2A1LHo0gdH7ZkqF5IYQ5PF2W6Zz0MeVlshA8zcTH+7sK3KiCZeNFQTgChFSseIRBTWY2VHJjXqbkaLKp6eDAvtho74k3FaHOZH6dsZ7yJLALelhNTKHQTK90tRhsJ2M62DJ+wszn6r38IH7BfHJhqxPGaP8a8hQLYYQxVhLiaWrhNPm83GHQlZwNBTnnrNMs/q+Hq54pbPFi4pcOAlBJIxTcK/GZtoqn3LbSAdgvqpURqmlnylRGDXPS+JMbwAYSjkXAgFvhaCUwBWMOICpN9xCUEsm/BG6d0js6o1sIluoXf1Laemt3M7WAMHFkPfQt5AzaxdU5BA5OJQHbbYs592en X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: abfc37ba-7298-45dc-6c5a-08daedb446dc X-MS-Exchange-CrossTenant-AuthSource: SN4PR0801MB3774.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 17:59:36.6655 (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: f8aYUuij8fO24uiek/1dGGmLEi6eQ+0/HtHpByuiaYhZ0YDTK9KEmUTSUjzR7ZXDXbgXeowrYqnzHvZctkfVTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR08MB6005 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 --- Changes in v2: - Added Reviewed-by 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 814d1a898e7f..8b30c911f789 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; @@ -973,13 +970,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- @@ -1036,7 +1028,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); @@ -1052,14 +1043,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: @@ -1071,10 +1060,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) @@ -1087,23 +1074,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++) { @@ -1116,13 +1087,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: @@ -1138,14 +1105,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; @@ -1205,6 +1164,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) { @@ -1267,6 +1229,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; } @@ -1298,6 +1266,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 @@ -1554,7 +1525,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, @@ -1574,6 +1547,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); @@ -1583,6 +1557,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; } @@ -1641,6 +1619,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)); @@ -1676,6 +1655,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);