Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3232818imw; Mon, 18 Jul 2022 04:40:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uZv68BpfnewsDSa+MU1C2uheih4Wt+1nUZ/OHs3y2UqhHU39X4vk696VR9MxYrhPdfzMDy X-Received: by 2002:aa7:d30b:0:b0:43a:4bea:75c6 with SMTP id p11-20020aa7d30b000000b0043a4bea75c6mr36390198edq.12.1658144456715; Mon, 18 Jul 2022 04:40:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658144456; cv=none; d=google.com; s=arc-20160816; b=aJjXXA1qWE4N30Np7WSuNG+VqIEtPw8FcWKNp0EVOnTumwGQdph/k1wV6tIBJNVCMf clOZam4pVimixTqu6ddB8ES/Hu8JYaJQm4FC7fllKGkiME3D/rIPr6mutsEhVe6qIRt9 VbSdprMi0T5KALFwIRM+REwsbG0qmkZD5l2bqo0Pts8/3075h8ADjQS/tbgOWF9Yt+SJ jAW0Myvci+pNAONS1mRASNYekbNLCxHcH/O+bwTepiRFsUKHJavthrKvQ2JzwiBDC55Q hnWoTMdKSPJMXS1My3K2pXCHFLGM8ztEdNcaQh6tS5/fo9HuYiEpkoxrk8ec+phTJ/uk IOXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=WM+zWzeYAitwMFZLUVsc8lp6MA3Zpo/kJcizrD/8ssk=; b=iZakOzfkHcCsE3CwWc5fEaNA/PeZJuvffkOfOsrWB6EU+z93GhwIlg6c04WM2sA7cU wnOlv0eH38KheDvbnHF/1/6AuPSnXJp7Llgo1OfHZyaTU0opTpAPCjWkZOVaKoKia0PJ 5BcZ+47gqhCDZ8Xb/WIytZD6mRitB+Gnd0sUngBTiXncwXUHSyVHgepFhNGdn5XLtcFy RQYD0LPdcnYcjuRo4BW8fk3uEK3nGmILGTa1o5Hnnk6aj+kMOIfgyrroWqbej43+bTqj Q1sm24MA9plZhFLYK6KYyUnCwJLgLv6bdp7gae6/ENaxB2hnOrDIJbgVmUpPgChtkR2g 31bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OvcuKUIj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s20-20020aa7d794000000b0043ad5430053si13528008edq.448.2022.07.18.04.40.30; Mon, 18 Jul 2022 04:40:56 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=OvcuKUIj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234459AbiGRLjT (ORCPT + 99 others); Mon, 18 Jul 2022 07:39:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234469AbiGRLjQ (ORCPT ); Mon, 18 Jul 2022 07:39:16 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C2292704; Mon, 18 Jul 2022 04:39:13 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id m8so1395959edd.9; Mon, 18 Jul 2022 04:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WM+zWzeYAitwMFZLUVsc8lp6MA3Zpo/kJcizrD/8ssk=; b=OvcuKUIjR4uhqpfL8lpsxLQ88mCYxcDOZ5lSaz8YMU5SyNSpWm2LhWIoS9CC+qDuiX DI/fnwo811XGeH4U+R290EOyJleoAHOZMLhaBd4hEdDGJHO0ZVerBEE3gVl6te9BpcT4 KyyXCEIlVZI9vzIm3Fjqb3WD+Kz4vqa72ux+kIiV8AtKAdtI87dFPLp0/j+Mpfxof+su lev/A8157qmlXkCgs9+5cRS0ruqiTC3/PHuZcO3JHcb+eMLKX823Z/MyUYWDhywL+lc6 ZEQD7h68BhRbIcXy5EQnFOo4JXLrkrtrSYjrBnXa5BTwwYZFNpiLwNcI86j6oai3JcHf Kb7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WM+zWzeYAitwMFZLUVsc8lp6MA3Zpo/kJcizrD/8ssk=; b=ZPzABo93bnWSf4CHpIJ+mtevlCaIMyi7sdL5NY4HacH09HwL/vR97GBSlDS+1DG8rV erOe41DsfrcUEupmTUtssvzTrh1gKVWrWy0VFcWJvVKMRSfCcEkkBuQAMn44WF313Y9R arEIWomj3UU/9Ovtv6mkXJoewEKSYBA4AbafY23LQuwrKOyuemF3J6NIBha+d7+Ld/54 F6dasTaUobv1LSoXbrt4+9VnLcnQjtNZl3h86Yc3dynIom83ihN96OQTJvXPB/hyXR7c QpcNqr2IeD72plYgLjRyitIL06HvknE1D7W8WYrlYG6JuMcD7NNYZPyEBZODQ7ekPGDh GdGw== X-Gm-Message-State: AJIora/VW1UdhFwT2CeR9JblilLwjoIjTf3Bf7NsF//p2OnvnZF/o1EY 2XgXIlJJtj44+Fcj+HE7hdoVxBc8a4VUQoJ6dcE= X-Received: by 2002:a05:6402:34c5:b0:43a:8f90:e643 with SMTP id w5-20020a05640234c500b0043a8f90e643mr35599070edc.88.1658144351737; Mon, 18 Jul 2022 04:39:11 -0700 (PDT) MIME-Version: 1.0 References: <20220715112607.591-1-peterwu.pub@gmail.com> <20220715112607.591-9-peterwu.pub@gmail.com> <20220718080831.GA31509@cyhuang-hp-elitebook-840-g3.rt> In-Reply-To: <20220718080831.GA31509@cyhuang-hp-elitebook-840-g3.rt> From: Andy Shevchenko Date: Mon, 18 Jul 2022 13:38:35 +0200 Message-ID: Subject: Re: [PATCH v5 08/13] usb: typec: tcpci_mt6370: Add MediaTek MT6370 tcpci driver To: ChiYuan Huang Cc: ChiaEn Wu , Lee Jones , Daniel Thompson , Jingoo Han , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Matthias Brugger , Sebastian Reichel , Chunfeng Yun , Greg Kroah-Hartman , Jonathan Cameron , Lars-Peter Clausen , Liam Girdwood , Mark Brown , Guenter Roeck , "Krogerus, Heikki" , Helge Deller , ChiaEn Wu , Alice Chen , cy_huang , dri-devel , Linux LED Subsystem , devicetree , linux-arm Mailing List , "moderated list:ARM/Mediatek SoC support" , Linux Kernel Mailing List , Linux PM , USB , linux-iio , "open list:FRAMEBUFFER LAYER" , szuni chen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 18, 2022 at 10:08 AM ChiYuan Huang wrote: > On Fri, Jul 15, 2022 at 03:10:42PM +0200, Andy Shevchenko wrote: > > On Fri, Jul 15, 2022 at 1:28 PM ChiaEn Wu wrote: ... > > > This commit add support for the Type-C & Power Delivery controller in > > > > This commit add -> Add > > > Upper case? Or rewrite it as 'This commit is to add .....'? Please, read this documentation [1] for better understanding. It should clarify this and perhaps other possible questions. [1]: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes > > > MediaTek MT6370 IC. ... > > > + ret = devm_request_threaded_irq(dev, priv->irq, NULL, > > > + mt6370_irq_handler, IRQF_ONESHOT, > > > + dev_name(dev), priv); > > > + if (ret) { > > > > > + tcpci_unregister_port(priv->tcpci); > > > > This is wrong. > > You mixed devm_ with non-devm. Either drop devm_ *after* the first > > non-devm_ call, or convert everything to be managed. > > > How about to add 'devm_add_action_or_reset' for tcpci_unregister_port? > This will convert all as 'devm_' version. I think it would work, that wrapper was designed to cover cases like this. > > > + return dev_err_probe(dev, ret, "Failed to allocate irq\n"); > > > + } ... > > > +static int mt6370_tcpc_remove(struct platform_device *pdev) > > > +{ > > > + struct mt6370_priv *priv = platform_get_drvdata(pdev); > > > > > + disable_irq(priv->irq); > > > > Why? > > An ugly workaround due to ordering issues in ->probe()? > > > Yes, due to the ordering in probe. > 'bus remove' will be called before device resource releases. > > Like as you said, another way is to convert all as non-devm > version after 'tcpci_unregister_port'. > > If to keep the original order, 'disable_irq' before > 'tcpci_unregister_port' can make the flow more safe. > > Or you can think one case if irq triggers after > 'tcpci_unregister_port'. Null pointer occurs. > > Anyway, in next revision, I'll convert all to be 'devm_' version. > For this remove callback, only 'dev_pm_clear_wake_irq' and > 'device_init_wakeup' will be kept. > > Is this better? Sounds like a plan! > > > + tcpci_unregister_port(priv->tcpci); > > > + dev_pm_clear_wake_irq(&pdev->dev); > > > + device_init_wakeup(&pdev->dev, false); > > > + > > > + return 0; > > > +} -- With Best Regards, Andy Shevchenko