Message ID | 20231107091252.11783-1-stanley_chang@realtek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp108655vqo; Tue, 7 Nov 2023 01:13:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOkkr7irmM3wDxDjQQDNqHkyKNhqa5sK7tKudXHugcsfPl9M1uAkE0U4VrOkEWk8fdd1O+ X-Received: by 2002:a25:ab88:0:b0:d81:754a:7cb8 with SMTP id v8-20020a25ab88000000b00d81754a7cb8mr32498692ybi.65.1699348393195; Tue, 07 Nov 2023 01:13:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699348393; cv=none; d=google.com; s=arc-20160816; b=CnI7SxyVdjVdNp6XusW1e42ql45uQjbFsIgGnJPBaLAHZQKCshUWBKUvUguPu/W8gu 4rp3EdzGG4qiRnk+k4SoSwokrykWhNV4JJXIfXZeQAN/ZdfzYqzvJ5rWyDkWWTGIElyB jhOSr2W1yXNqQFFHzGCsaWU5J9fWEza6dOLLTA8bk3PMDrYqy+DogrXy6imvxdOXa42A 0aYUBL6/Rq8a9cu0zitkZiHof/gkLdDcMDWlfeQ+kNsxPCdx9u4s3w0Ymm4vaxnq+Pz1 yy61R0spn4hf2FnJmslFRD17lxCpSeF2Y87RQcSVsRGLWSjYIKPhuLqRKNqMaxsF0cMS llzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=eB3GvHo4GltZSjT1FHS/j03zPbZSJ+fMAEi6fvmlAvQ=; fh=kcQjMKul7xY+IjIpSZq48ayPICfL75TOdtZhrwm4LQU=; b=JDkzNzc/jtd8S05vOJw4B0ZtdhYDaVf8nI5CKXiYOhu6B9qEzgU8PZvvYm2Btrmuzl GjgFxd3Y2LDkyB94oZhm1tHTqewlE8mXy+/dnXYyqAkkxv4WvGHkQBv31G6Cg3EgJ5Qs cq+/zVYOLIHi2EQ0+2Zw7Ni/i2gU4ZXZ50YyvPTCODJ/J+tnS1LzLwEmAAQOovvr75kC aWlrij4cad3MIkGMQ/H50j0cGfUtFi2jBCNPzq/Je0G3Uvo3aa/spZmhtTGjomLgdOc5 m8TK1jqQW27274JVUIdsgfxvDtzst7HMc17GVbntQ8YacY7wRzjpSpeqecdoJniX0cso FTXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id k69-20020a638448000000b00578889362a2si1542293pgd.663.2023.11.07.01.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:13:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 60273812A97C; Tue, 7 Nov 2023 01:13:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233778AbjKGJNK (ORCPT <rfc822;lhua1029@gmail.com> + 33 others); Tue, 7 Nov 2023 04:13:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229776AbjKGJNJ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 7 Nov 2023 04:13:09 -0500 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 080D8FA; Tue, 7 Nov 2023 01:13:04 -0800 (PST) X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 3A79CrrpE4103429, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 3A79CrrpE4103429 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Nov 2023 17:12:53 +0800 Received: from RTEXMBS06.realtek.com.tw (172.21.6.99) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Tue, 7 Nov 2023 17:12:53 +0800 Received: from RTEXH36506.realtek.com.tw (172.21.6.27) by RTEXMBS06.realtek.com.tw (172.21.6.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 7 Nov 2023 17:12:52 +0800 Received: from localhost.localdomain (172.21.252.101) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Tue, 7 Nov 2023 17:12:52 +0800 From: Stanley Chang <stanley_chang@realtek.com> To: Thinh Nguyen <Thinh.Nguyen@synopsys.com> CC: Stanley Chang <stanley_chang@realtek.com>, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH v1] usb: dwc3: add device put function to decrement the ref-counted reference Date: Tue, 7 Nov 2023 17:12:51 +0800 Message-ID: <20231107091252.11783-1-stanley_chang@realtek.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-KSE-ServerInfo: RTEXMBS06.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 07 Nov 2023 01:13:12 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781895940844742859 X-GMAIL-MSGID: 1781895940844742859 |
Series |
[v1] usb: dwc3: add device put function to decrement the ref-counted reference
|
|
Commit Message
Stanley Chang[昌育德]
Nov. 7, 2023, 9:12 a.m. UTC
When the function exits, the count should be decremented via
platform_device_put and of_node_put.
Fixes: 34c200483569 ("usb: dwc3: add Realtek DHC RTD SoC dwc3 glue layer driver")
Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
---
drivers/usb/dwc3/dwc3-rtk.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On Tue, Nov 07, 2023, Stanley Chang wrote: > When the function exits, the count should be decremented via > platform_device_put and of_node_put. > > Fixes: 34c200483569 ("usb: dwc3: add Realtek DHC RTD SoC dwc3 glue layer driver") > Signed-off-by: Stanley Chang <stanley_chang@realtek.com> > --- > drivers/usb/dwc3/dwc3-rtk.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/usb/dwc3/dwc3-rtk.c b/drivers/usb/dwc3/dwc3-rtk.c > index 590028e8fdcb..9d6f2a8bd6ce 100644 > --- a/drivers/usb/dwc3/dwc3-rtk.c > +++ b/drivers/usb/dwc3/dwc3-rtk.c > @@ -187,6 +187,7 @@ static enum usb_device_speed __get_dwc3_maximum_speed(struct device_node *np) > > ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed); > > + of_node_put(dwc3_np); > return (ret < 0) ? USB_SPEED_UNKNOWN : ret; > } > > @@ -339,6 +340,8 @@ static int dwc3_rtk_probe_dwc3_core(struct dwc3_rtk *rtk) > > switch_usb2_role(rtk, rtk->cur_role); > > + platform_device_put(dwc3_pdev); Don't you use this after probe? Why put here and not on remove? BR, Thinh > + of_node_put(dwc3_node); > return 0; > > err_pdev_put: > -- > 2.34.1 >
> -----Original Message----- > From: Thinh Nguyen <Thinh.Nguyen@synopsys.com> > Sent: Friday, November 10, 2023 10:34 AM > To: Stanley Chang[昌育德] <stanley_chang@realtek.com> > Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>; Christophe JAILLET > <christophe.jaillet@wanadoo.fr>; Greg Kroah-Hartman > <gregkh@linuxfoundation.org>; linux-usb@vger.kernel.org; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH v1] usb: dwc3: add device put function to decrement the > ref-counted reference > > > External mail. > > > > On Tue, Nov 07, 2023, Stanley Chang wrote: > > When the function exits, the count should be decremented via > > platform_device_put and of_node_put. > > > > Fixes: 34c200483569 ("usb: dwc3: add Realtek DHC RTD SoC dwc3 glue > > layer driver") > > Signed-off-by: Stanley Chang <stanley_chang@realtek.com> > > --- > > drivers/usb/dwc3/dwc3-rtk.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/usb/dwc3/dwc3-rtk.c b/drivers/usb/dwc3/dwc3-rtk.c > > index 590028e8fdcb..9d6f2a8bd6ce 100644 > > --- a/drivers/usb/dwc3/dwc3-rtk.c > > +++ b/drivers/usb/dwc3/dwc3-rtk.c > > @@ -187,6 +187,7 @@ static enum usb_device_speed > > __get_dwc3_maximum_speed(struct device_node *np) > > > > ret = match_string(speed_names, ARRAY_SIZE(speed_names), > > maximum_speed); > > > > + of_node_put(dwc3_np); > > return (ret < 0) ? USB_SPEED_UNKNOWN : ret; } > > > > @@ -339,6 +340,8 @@ static int dwc3_rtk_probe_dwc3_core(struct > > dwc3_rtk *rtk) > > > > switch_usb2_role(rtk, rtk->cur_role); > > > > + platform_device_put(dwc3_pdev); > > Don't you use this after probe? Why put here and not on remove? I don't use dwc3_pdev in driver. I use rtk->dwc and dwc is removed by of_platform_depopulate on remove. So I think I don't need to keep the count of dwc3_pdev. Thanks, Stanley > > BR, > Thinh > > > + of_node_put(dwc3_node); > > return 0; > > > > err_pdev_put: > > -- > > 2.34.1 > >
On Fri, Nov 10, 2023, Stanley Chang[昌育德] wrote: > > > > -----Original Message----- > > From: Thinh Nguyen <Thinh.Nguyen@synopsys.com> > > Sent: Friday, November 10, 2023 10:34 AM > > To: Stanley Chang[昌育德] <stanley_chang@realtek.com> > > Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>; Christophe JAILLET > > <christophe.jaillet@wanadoo.fr>; Greg Kroah-Hartman > > <gregkh@linuxfoundation.org>; linux-usb@vger.kernel.org; > > linux-kernel@vger.kernel.org > > Subject: Re: [PATCH v1] usb: dwc3: add device put function to decrement the > > ref-counted reference > > > > > > External mail. > > > > > > > > On Tue, Nov 07, 2023, Stanley Chang wrote: > > > When the function exits, the count should be decremented via > > > platform_device_put and of_node_put. > > > > > > Fixes: 34c200483569 ("usb: dwc3: add Realtek DHC RTD SoC dwc3 glue > > > layer driver") > > > Signed-off-by: Stanley Chang <stanley_chang@realtek.com> > > > --- > > > drivers/usb/dwc3/dwc3-rtk.c | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/drivers/usb/dwc3/dwc3-rtk.c b/drivers/usb/dwc3/dwc3-rtk.c > > > index 590028e8fdcb..9d6f2a8bd6ce 100644 > > > --- a/drivers/usb/dwc3/dwc3-rtk.c > > > +++ b/drivers/usb/dwc3/dwc3-rtk.c > > > @@ -187,6 +187,7 @@ static enum usb_device_speed > > > __get_dwc3_maximum_speed(struct device_node *np) > > > > > > ret = match_string(speed_names, ARRAY_SIZE(speed_names), > > > maximum_speed); > > > > > > + of_node_put(dwc3_np); > > > return (ret < 0) ? USB_SPEED_UNKNOWN : ret; } > > > > > > @@ -339,6 +340,8 @@ static int dwc3_rtk_probe_dwc3_core(struct > > > dwc3_rtk *rtk) > > > > > > switch_usb2_role(rtk, rtk->cur_role); > > > > > > + platform_device_put(dwc3_pdev); > > > > Don't you use this after probe? Why put here and not on remove? > > I don't use dwc3_pdev in driver. > I use rtk->dwc and dwc is removed by of_platform_depopulate on remove. > So I think I don't need to keep the count of dwc3_pdev. > Thanks for the clarification. Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> BR, Thinh
On Tue, Nov 07, 2023 at 05:12:51PM +0800, Stanley Chang wrote: > When the function exits, the count should be decremented via > platform_device_put and of_node_put. This isn't really a self-contained commit message (and your use of 'count' is too vague). You're also changing two functions in two different ways here. > Fixes: 34c200483569 ("usb: dwc3: add Realtek DHC RTD SoC dwc3 glue layer driver") > Signed-off-by: Stanley Chang <stanley_chang@realtek.com> > --- > drivers/usb/dwc3/dwc3-rtk.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/usb/dwc3/dwc3-rtk.c b/drivers/usb/dwc3/dwc3-rtk.c > index 590028e8fdcb..9d6f2a8bd6ce 100644 > --- a/drivers/usb/dwc3/dwc3-rtk.c > +++ b/drivers/usb/dwc3/dwc3-rtk.c > @@ -187,6 +187,7 @@ static enum usb_device_speed __get_dwc3_maximum_speed(struct device_node *np) > > ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed); > > + of_node_put(dwc3_np); You're still leaking a reference in the of_property_read_string() error path just above. > return (ret < 0) ? USB_SPEED_UNKNOWN : ret; > } > > @@ -339,6 +340,8 @@ static int dwc3_rtk_probe_dwc3_core(struct dwc3_rtk *rtk) > > switch_usb2_role(rtk, rtk->cur_role); > > + platform_device_put(dwc3_pdev); > + of_node_put(dwc3_node); Please keep the new line before return for readability. > return 0; > > err_pdev_put: Johan
Hi Johan, > > On Tue, Nov 07, 2023 at 05:12:51PM +0800, Stanley Chang wrote: > > When the function exits, the count should be decremented via > > platform_device_put and of_node_put. > > This isn't really a self-contained commit message (and your use of 'count' is > too vague). You're also changing two functions in two different ways here. I will modify the commit message. > > Fixes: 34c200483569 ("usb: dwc3: add Realtek DHC RTD SoC dwc3 glue > > layer driver") > > Signed-off-by: Stanley Chang <stanley_chang@realtek.com> > > --- > > drivers/usb/dwc3/dwc3-rtk.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/usb/dwc3/dwc3-rtk.c b/drivers/usb/dwc3/dwc3-rtk.c > > index 590028e8fdcb..9d6f2a8bd6ce 100644 > > --- a/drivers/usb/dwc3/dwc3-rtk.c > > +++ b/drivers/usb/dwc3/dwc3-rtk.c > > @@ -187,6 +187,7 @@ static enum usb_device_speed > > __get_dwc3_maximum_speed(struct device_node *np) > > > > ret = match_string(speed_names, ARRAY_SIZE(speed_names), > > maximum_speed); > > > > + of_node_put(dwc3_np); I will fixed this. Thanks, Stanley > You're still leaking a reference in the of_property_read_string() error path just > above. > > > return (ret < 0) ? USB_SPEED_UNKNOWN : ret; } > > > > @@ -339,6 +340,8 @@ static int dwc3_rtk_probe_dwc3_core(struct > > dwc3_rtk *rtk) > > > > switch_usb2_role(rtk, rtk->cur_role); > > > > + platform_device_put(dwc3_pdev); > > + of_node_put(dwc3_node); > > Please keep the new line before return for readability. > > > return 0; > > > > err_pdev_put: > > Johan
diff --git a/drivers/usb/dwc3/dwc3-rtk.c b/drivers/usb/dwc3/dwc3-rtk.c index 590028e8fdcb..9d6f2a8bd6ce 100644 --- a/drivers/usb/dwc3/dwc3-rtk.c +++ b/drivers/usb/dwc3/dwc3-rtk.c @@ -187,6 +187,7 @@ static enum usb_device_speed __get_dwc3_maximum_speed(struct device_node *np) ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed); + of_node_put(dwc3_np); return (ret < 0) ? USB_SPEED_UNKNOWN : ret; } @@ -339,6 +340,8 @@ static int dwc3_rtk_probe_dwc3_core(struct dwc3_rtk *rtk) switch_usb2_role(rtk, rtk->cur_role); + platform_device_put(dwc3_pdev); + of_node_put(dwc3_node); return 0; err_pdev_put: