Message ID | 30cd9157-1850-b17f-bfd5-4c378990b81b@axentia.se |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2504253wrr; Mon, 12 Dec 2022 14:39:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf7e7YWIXrboaIQyjaUDZ4s2oTQFRs12udBVx7MYr4Rsmm7ZZeLdl5Lg5WB4vqx4ZNZHgZ4n X-Received: by 2002:a17:906:fa14:b0:7c0:c5b3:cb49 with SMTP id lo20-20020a170906fa1400b007c0c5b3cb49mr13765019ejb.31.1670884741243; Mon, 12 Dec 2022 14:39:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670884741; cv=pass; d=google.com; s=arc-20160816; b=kVGmmagA7MaOv7sneMweOFRmmrLhiU6nCemhPLXHtzrJq9VPry1DBLk+88qYuJF+BL 8FOlxLLb7QYGf8UT2H1qdU+C4UA6E3yL/BvVmU6YHhAr4YW5erU75QeITLs+D38pw/sP RKOUSvaZUDaZdH9gK37g6zMg5o/3XEHXJ9yuSJinVsOskcNju48O8tJv4d6q491T+kqV wL2vpdNqrPRlmgtsWeFRhJwRZyD9TBZgPY221O3U4iyijZdr23PKOyilskdM2qzjyMOB CSEufGfb7Nm2z6JgMEuhMQrZwB/I9TIinrUFblXFGRh9hac5GrB68RLmSFltRMOgyBBn /FYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding:subject :from:cc:to:content-language:user-agent:date:message-id :dkim-signature; bh=xg8oSwkP6YhLzQsk4Ameh5fiBn8hnqqh435JSW4uy64=; b=BYqL+/t4ZTo9mJbD8NoubS7S+8TDx8eKeWHrsdx8bWseQqn2f8rONmXlPClF19kbUl I7ympQNVOeOu0lTAkf3zr3YDycl07D4uR0SUKLWMKVwc5H0RG/YROM54s9lMmZ4sCSBg CLmG0BXRFdfDgQgyp9cvrdyYCR4ZncvUNnIXjFWf9X7D1dx8Be6uhf9QFRkAOdSS7oUU bCGz/W4cgjhNUi/i7lq5oFMKURQqw4HlrLZFV+Gf0nsTiYdiDm4F3yuLqs625Pya2aDY BR4eAGuDlQSwYYFzpp09GFgNhaVbBlzcTdp92eOAq9YjoC9Ya4sdWK8p1137hbZqqg+Z P7jw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@axentia.se header.s=selector2 header.b=jA3cAw5e; arc=pass (i=1 spf=pass spfdomain=axentia.se dkim=pass dkdomain=axentia.se dmarc=pass fromdomain=axentia.se); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w19-20020a50d793000000b0046c0e8b6cadsi145125edi.450.2022.12.12.14.38.36; Mon, 12 Dec 2022 14:39:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@axentia.se header.s=selector2 header.b=jA3cAw5e; arc=pass (i=1 spf=pass spfdomain=axentia.se dkim=pass dkdomain=axentia.se dmarc=pass fromdomain=axentia.se); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233842AbiLLWgZ (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Mon, 12 Dec 2022 17:36:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233786AbiLLWgU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 12 Dec 2022 17:36:20 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2127.outbound.protection.outlook.com [40.107.21.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9435514D22 for <linux-kernel@vger.kernel.org>; Mon, 12 Dec 2022 14:36:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n0t4i3sjOWmPYlAys7q46PeS835Yi5RPLqANrKV614XHJ7QpSwhUexhwB6glQlIxtHOGsSfG0f9bSdFOBGYarOWFOHdIZVsxYmrpSJWgm5tECpSwF07pKQth0V74cVViPeKgAuF/SZdOIrfteim1e7W/qlAG+EkC6lc4weyuc0ijLlGjeJPiJA66tq5Tmy3XK1MpENrZ/TKS/Zk99++ZlrqGuBr+lOA5r6ZIChCl1G9mIwlKMAAhjzIGFLAnA5NuHFWTqKJoXlY/rasaNytifJG0U4i6CVluu7P5VXngOmjxJhIQnFkyjRsXmBI0mCpE2z6LCG1A5VIJ2lnarPFQMA== 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=xg8oSwkP6YhLzQsk4Ameh5fiBn8hnqqh435JSW4uy64=; b=Rkos9N83/daCL4HAMwY7I68oVDCFfGDCfTY1A28h6IBQ4FGXU5aZrZpbqOm7AljSU0d5Ll/aA/nixCjRH6lm05jjjHbfZb1jeov+P5UokGtAmfWiyS3DZmrWDtbnL4NDPbihIFYH9yCKS2amhOXWmem4VehrE6N7ZrkZrdMkIrG2z+Y3zXxmCz4N0XdXXzbW3OB1sCAkZC5Kt2502Sjc6tC7C+DMsPk1Zy6leToDBi5jCAZJ6EVRX/7oy/gwyTSuEILQA1SuxYLLS+zL0DyBiK1OpxCGRnaN+G6PyzX38eF3gTL5zWid9bgcL1VH1IWEIZ0haAGdxec1IZvYeQ5pfQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=axentia.se; dmarc=pass action=none header.from=axentia.se; dkim=pass header.d=axentia.se; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xg8oSwkP6YhLzQsk4Ameh5fiBn8hnqqh435JSW4uy64=; b=jA3cAw5eVcRIYG6drvv9yaZ7S1EH4W7CjUZqsB5tDUr7hftdBeEFc/9im5dOyopllURq7dbT3wsmoWQSH6kmqvBFeCX+5nX0SCvutMavadWOdbfe4/kN0uHmUcjCSiLB2ujBTyXuoCl03B1hFH2YAUr0lLanFIcetmL9tv9hBwk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=axentia.se; Received: from AM0PR02MB4436.eurprd02.prod.outlook.com (2603:10a6:208:ed::15) by AS2PR02MB9320.eurprd02.prod.outlook.com (2603:10a6:20b:578::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10; Mon, 12 Dec 2022 22:36:15 +0000 Received: from AM0PR02MB4436.eurprd02.prod.outlook.com ([fe80::a30:dce8:eaa4:7687]) by AM0PR02MB4436.eurprd02.prod.outlook.com ([fe80::a30:dce8:eaa4:7687%4]) with mapi id 15.20.5880.019; Mon, 12 Dec 2022 22:36:15 +0000 Message-ID: <30cd9157-1850-b17f-bfd5-4c378990b81b@axentia.se> Date: Mon, 12 Dec 2022 23:36:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Content-Language: en-US To: LKML <linux-kernel@vger.kernel.org> Cc: MyungJoo Ham <myungjoo.ham@samsung.com>, Chanwoo Choi <cw00.choi@samsung.com>, Michael Auchter <michael.auchter@ni.com> From: Peter Rosin <peda@axentia.se> Subject: [PATCH v2] extcon: usbc-tusb320: make sure the state is initialized on probe Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MM0P280CA0031.SWEP280.PROD.OUTLOOK.COM (2603:10a6:190:b::19) To AM0PR02MB4436.eurprd02.prod.outlook.com (2603:10a6:208:ed::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR02MB4436:EE_|AS2PR02MB9320:EE_ X-MS-Office365-Filtering-Correlation-Id: cfd1fad5-c6ea-42be-675a-08dadc91475d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6wPfPijLnjiOquxP+rWPNEswMH9nDU3Nn/tvUUUlu+0KhKnrUf2uFn9daSLzXXKNJHz8k9pKkJ6oOLRcpZ0dcB1WTf22VuZmnfAqo0Tj39bCgqRcnBvgzdFcjabJleE4j+muz/xSzui1vWgvCYbWRL3i86600YzUDQnwhUjXJzuhzZ1Jg2ke20yjiP1EJw+NR96W2scjoFK/clevH9/h0Fy1stqEgHQP8uKvxI6VQ7v+oYbgA1Rp2edLcq0pDOKNoc2ep1Tus94aWDgftMjM29oBXm8CkaNiFBVZMF3Hi+ISxVcaR8S8q/tFF0OtfEJKevnHbv/qOfUyHs7HNoyZ9+CV3NaijGSLx930JqU6MXfdxFf45dKhZMKzChNIc/14vi8FAFqUlINw3sSyaF82l6S3NdlFpPTPp/Uyqq/pXvjyKF/pE0l/zQHkYqmd5w2NwH0wgCE1i3wnM4baU7eUZzxK2g2NRogxRE65lyXvW3Z6CKiOrnlE/Bv4XLVlVjsmSsOtq0OZxk1ELwFzd/JhAth+ci0GVVaqMghpAg1SVi9l0oohCPD0RCyQjQ17rfvnobI8Fu1FqluQfRmhBftDKflsQwZOmeQMlS/dL7A5MJvNcKJpom9+qbZzZJkkpN4sGmi4aWnxqZHEhP6XXCALzOaLg9R22mJwr9JoC09XsF7/J/UJSD+E61CKuSDkuYW+/4dOLID9H/TeVD5Weh3adLvk0tEParQrp4SWXgS4943QZ1YUe6bj2JxgegIKlFOr X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR02MB4436.eurprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(376002)(39840400004)(366004)(136003)(346002)(451199015)(5660300002)(2906002)(83380400001)(41300700001)(8936002)(186003)(31696002)(86362001)(38100700002)(36756003)(26005)(6512007)(6486002)(478600001)(966005)(316002)(6916009)(54906003)(6506007)(31686004)(66476007)(4326008)(8676002)(66556008)(66946007)(2616005)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?LyDleZGKswXqNf4qheKEHLrsUJDh?= =?utf-8?q?uYsqrK28d6IXqGgRbSAiyl9JuVtsoFLk9uCwqoA6HcDeh5FDABkHHBic87yYe3p02?= =?utf-8?q?XvJDMSJQzIgQygfa3lMDwJJVG50Lst4/KRsaQUggVjj244vFDqHkndxEDrbSrMg4v?= =?utf-8?q?aZtaVzKIC7Ryi4HC7M5X7hS3l2WV5QfEXjoNZWpycj448kpfUj7JZfwC9HQseb9My?= =?utf-8?q?nncvuzcEhieqxcg4fNz60gR4AR7AohgGKr8t9f4QxwtfIhOTOAqRfugIsdwhm3gno?= =?utf-8?q?AXwvNlQuU0Bh36m4vvEyQ83+MXJLPAqc9q/zNRNFgWdmtHvfobVSShBbc7nUxKeUP?= =?utf-8?q?erEKLJUX5wucq4fndqj/hMZdtG8X0341g/xGLuij/jV32ITu+xX4K2nLnsbBrIurj?= =?utf-8?q?xBSca/XfVe3aaiZ0LgNzMmdmFxsZgM74z5IW6Eeain3Hs1ZGDhbbF/pm7DML8tTFp?= =?utf-8?q?YPM66ilYl7D0VGXZ21jaK2fajSdEO3tR0Dtvb1yrgU0dl9bcU+InujL4JcA8YWj9B?= =?utf-8?q?S/L7754LRnZw0J0tMwOEjE4RwsVlvr3gFxRQ0FpIms/zmt8Yz03uhpNght38994Am?= =?utf-8?q?bMT/i9q8Y2YD6HyMPzRy0o0HPN44jmYfMMpGLuRndoikRq/BjoPQmAYlCOUvaekh0?= =?utf-8?q?mcAYpZTFX0sG4sxoBtVHdIOhKW/3ESoC7l1gme5nfVNilXREyIDb9yiIof9r4nuE9?= =?utf-8?q?zKlpkf5m5Pk1kPoqW2vEAgpj3XhZOfM0xt469CtTG31+yD6luovZiQ4zmKzFhqA3N?= =?utf-8?q?uI5COUjkwr5n2Ivoz7FT5NwgmdTr5z/43PrjEel34WemSDOJbXtkYAF0QWfsq4Kpy?= =?utf-8?q?qU2GCrAbNOJrKlNEqGAOU9F8cnTosI7Y7gs0JUAnT1cRktbAtm0rW6zPCn31fNRVn?= =?utf-8?q?aw3AXcMrxPxRpyM0hFFLBnsv5+mhbkcNYCDasJqBwyCnJSKn7PJRPFS+1VO7X3NhF?= =?utf-8?q?KG9uROUTtka+M0ObhSPeVVa0w+9ZBM0vGWrdNeiO4ANmtPILzZ302Uj81o9uJPRwI?= =?utf-8?q?q2XYQJEgJp9N+LJ9la2wOq+sq0QGYgHS03ZPPwyVjmn7PXUqCVkVCIsGCksWyPkd/?= =?utf-8?q?2MhnI1gvqP0NBt8dVRdvHk0e8dtb+p8V2bfQoF7N1kHsbHD/lHWjzCb6GpXAT78oR?= =?utf-8?q?Pp7nqfVzOhiRsG5A3nZBuPYM/C9zMarCovZ1FrZulTJtX49fKhvSQL1J5Bo91rizT?= =?utf-8?q?Unl/38AH9WtRj2NfdkbHhGvqU3Vwb6GVzRZKQjlccQiVzpvwT/KgZg2WH+OXZfy0c?= =?utf-8?q?B+FhN5hvAxclGLJc3S0BO53gN21q8v2Rgt0qF6kczf5OcD672wlL4fT0t+Bvm4yyp?= =?utf-8?q?n9rdPOZbaW9Wyuf13vdB0etDrDEVcQqmCSA5wMeKOve4gu3OUYu/SSTPeQ0BJe9Lc?= =?utf-8?q?mEuuiwINQfTcrn5A5bCkxMzHWFY+XpmyOVdLhwb2ahVSr07HrlIz4WCbTx2PtouU3?= =?utf-8?q?Uw2U6MeDOELFY9v5I5TyiSp7w372T7jBqv4U0eBa9jg1jm9WbbgWj4LPrtiDzWf4n?= =?utf-8?q?yRLp7TpL9vUm?= X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-Network-Message-Id: cfd1fad5-c6ea-42be-675a-08dadc91475d X-MS-Exchange-CrossTenant-AuthSource: AM0PR02MB4436.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2022 22:36:15.3737 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sgt7yWuXi0yeTW+xKy4xX4SVUOK1/oYgqf1+TIVLADbKnssHYftMqPVyqFwBkX4G X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR02MB9320 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752049638499635960?= X-GMAIL-MSGID: =?utf-8?q?1752049638499635960?= |
Series |
[v2] extcon: usbc-tusb320: make sure the state is initialized on probe
|
|
Commit Message
Peter Rosin
Dec. 12, 2022, 10:36 p.m. UTC
When the port is connected at boot, there is not necessarily
an interrupt flagged in the interrupt status register, causing
the IRQ handler to bail out early without reading the state when
it is invoked directly from probe.
Add a flag that overrides the interrupt status register and reads
the state regardless during probe.
Fixes: 06bc4ca115cd ("extcon: Add driver for TI TUSB320")
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/extcon/extcon-usbc-tusb320.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Hi!
This is basically a resend of v1, the patch has simply been adapted
to fit after the driver changes for type-c support.
Version 1 of the patch, with its brief "discussion", is here:
https://lore.kernel.org/lkml/ab1ad93b-4d39-8863-9704-da779fc4c426@axentia.se/
I cannot see how the patch can possibly affect detection of connector
changes *after* 'priv->initialized = true', so the comment from Chanwoo
Choi is still a mystery to me. The patch is about what happens *before*
'priv->initialized = true', i.e. when the IRQ handler is called directly
during probe. There is no change in behavior after the statement
'priv->initialized = true', and IRQs are handled exactly as before once
past that point.
Please look at this patch again.
Cheers,
Peter
Comments
Hi, On 22. 12. 13. 07:36, Peter Rosin wrote: > When the port is connected at boot, there is not necessarily > an interrupt flagged in the interrupt status register, causing > the IRQ handler to bail out early without reading the state when > it is invoked directly from probe. > > Add a flag that overrides the interrupt status register and reads > the state regardless during probe. > > Fixes: 06bc4ca115cd ("extcon: Add driver for TI TUSB320") > Signed-off-by: Peter Rosin <peda@axentia.se> > --- > drivers/extcon/extcon-usbc-tusb320.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > Hi! > > This is basically a resend of v1, the patch has simply been adapted > to fit after the driver changes for type-c support. > > Version 1 of the patch, with its brief "discussion", is here: > https://lore.kernel.org/lkml/ab1ad93b-4d39-8863-9704-da779fc4c426@axentia.se/ > > I cannot see how the patch can possibly affect detection of connector > changes *after* 'priv->initialized = true', so the comment from Chanwoo > Choi is still a mystery to me. The patch is about what happens *before* > 'priv->initialized = true', i.e. when the IRQ handler is called directly > during probe. There is no change in behavior after the statement > 'priv->initialized = true', and IRQs are handled exactly as before once > past that point. > > Please look at this patch again. > > Cheers, > Peter > > diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-usbc-tusb320.c > index 2a120d8d3c27..dc586e5e3c65 100644 > --- a/drivers/extcon/extcon-usbc-tusb320.c > +++ b/drivers/extcon/extcon-usbc-tusb320.c > @@ -78,6 +78,7 @@ struct tusb320_priv { > struct typec_capability cap; > enum typec_port_type port_type; > enum typec_pwr_opmode pwr_opmode; > + bool initialized; > }; > > static const char * const tusb_attached_states[] = { > @@ -323,7 +324,7 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id) > return IRQ_NONE; > } > > - if (!(reg & TUSB320_REG9_INTERRUPT_STATUS)) > + if (priv->initialized && !(reg & TUSB320_REG9_INTERRUPT_STATUS)) > return IRQ_NONE; > > tusb320_extcon_irq_handler(priv, reg); > @@ -479,6 +480,8 @@ static int tusb320_probe(struct i2c_client *client, > */ > tusb320_irq_handler(client->irq, priv); > > + priv->initialized = true; > + > ret = devm_request_threaded_irq(priv->dev, client->irq, NULL, > tusb320_irq_handler, > IRQF_TRIGGER_FALLING | IRQF_ONESHOT, I think that if priv->initialized=true on probe step, tusb32_irq_handler return the always IRQ_NONE because priv->initialized is never changed to false. Is it right to keep the 'priv->initialized=true' always?
Hi! 2023-01-10 at 15:14, Chanwoo Choi wrote: > Hi, > > On 22. 12. 13. 07:36, Peter Rosin wrote: >> When the port is connected at boot, there is not necessarily >> an interrupt flagged in the interrupt status register, causing >> the IRQ handler to bail out early without reading the state when >> it is invoked directly from probe. >> >> Add a flag that overrides the interrupt status register and reads >> the state regardless during probe. >> >> Fixes: 06bc4ca115cd ("extcon: Add driver for TI TUSB320") >> Signed-off-by: Peter Rosin <peda@axentia.se> >> --- >> drivers/extcon/extcon-usbc-tusb320.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> Hi! >> >> This is basically a resend of v1, the patch has simply been adapted >> to fit after the driver changes for type-c support. >> >> Version 1 of the patch, with its brief "discussion", is here: >> https://lore.kernel.org/lkml/ab1ad93b-4d39-8863-9704-da779fc4c426@axentia.se/ >> >> I cannot see how the patch can possibly affect detection of connector >> changes *after* 'priv->initialized = true', so the comment from Chanwoo >> Choi is still a mystery to me. The patch is about what happens *before* >> 'priv->initialized = true', i.e. when the IRQ handler is called directly >> during probe. There is no change in behavior after the statement >> 'priv->initialized = true', and IRQs are handled exactly as before once >> past that point. >> >> Please look at this patch again. >> >> Cheers, >> Peter >> >> diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-usbc-tusb320.c >> index 2a120d8d3c27..dc586e5e3c65 100644 >> --- a/drivers/extcon/extcon-usbc-tusb320.c >> +++ b/drivers/extcon/extcon-usbc-tusb320.c >> @@ -78,6 +78,7 @@ struct tusb320_priv { >> struct typec_capability cap; >> enum typec_port_type port_type; >> enum typec_pwr_opmode pwr_opmode; >> + bool initialized; >> }; >> >> static const char * const tusb_attached_states[] = { >> @@ -323,7 +324,7 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id) >> return IRQ_NONE; >> } >> >> - if (!(reg & TUSB320_REG9_INTERRUPT_STATUS)) >> + if (priv->initialized && !(reg & TUSB320_REG9_INTERRUPT_STATUS)) >> return IRQ_NONE; >> >> tusb320_extcon_irq_handler(priv, reg); >> @@ -479,6 +480,8 @@ static int tusb320_probe(struct i2c_client *client, >> */ >> tusb320_irq_handler(client->irq, priv); >> >> + priv->initialized = true; >> + >> ret = devm_request_threaded_irq(priv->dev, client->irq, NULL, >> tusb320_irq_handler, >> IRQF_TRIGGER_FALLING | IRQF_ONESHOT, > > I think that if priv->initialized=true on probe step, > tusb32_irq_handler return the always IRQ_NONE > because priv->initialized is never changed to false. The new behavior is to never return early when priv->initialized is false. When priv->initialized is true, the old behavior is retained through the right hand side of the && operator. > Is it right to keep the 'priv->initialized=true' always? Yes. However, this patch is no longer needed. I have since noticed that the problem was later solved by Marek Vasut with 581c848b610d ("extcon: usbc-tusb320: Update state on probe even if no IRQ pending") which does pretty much the same thing as this patch, but with force_update as a function argument (and inverted logic, so "if (!forced_update && ...)" in the above if-test instead of "if (priv->initialized && ...)".) Cheers, Peter
diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-usbc-tusb320.c index 2a120d8d3c27..dc586e5e3c65 100644 --- a/drivers/extcon/extcon-usbc-tusb320.c +++ b/drivers/extcon/extcon-usbc-tusb320.c @@ -78,6 +78,7 @@ struct tusb320_priv { struct typec_capability cap; enum typec_port_type port_type; enum typec_pwr_opmode pwr_opmode; + bool initialized; }; static const char * const tusb_attached_states[] = { @@ -323,7 +324,7 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id) return IRQ_NONE; } - if (!(reg & TUSB320_REG9_INTERRUPT_STATUS)) + if (priv->initialized && !(reg & TUSB320_REG9_INTERRUPT_STATUS)) return IRQ_NONE; tusb320_extcon_irq_handler(priv, reg); @@ -479,6 +480,8 @@ static int tusb320_probe(struct i2c_client *client, */ tusb320_irq_handler(client->irq, priv); + priv->initialized = true; + ret = devm_request_threaded_irq(priv->dev, client->irq, NULL, tusb320_irq_handler, IRQF_TRIGGER_FALLING | IRQF_ONESHOT,