* [PATCH v1] usb: dwc3: add device put function to decrement the ref-counted reference
@ 2023-11-07 9:12 Stanley Chang
2023-11-10 2:34 ` Thinh Nguyen
2023-11-11 10:45 ` Johan Hovold
0 siblings, 2 replies; 6+ messages in thread
From: Stanley Chang @ 2023-11-07 9:12 UTC (permalink / raw)
To: Thinh Nguyen
Cc: Stanley Chang, Christophe JAILLET, Greg Kroah-Hartman, linux-usb,
linux-kernel
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);
+ of_node_put(dwc3_node);
return 0;
err_pdev_put:
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] usb: dwc3: add device put function to decrement the ref-counted reference
2023-11-07 9:12 [PATCH v1] usb: dwc3: add device put function to decrement the ref-counted reference Stanley Chang
@ 2023-11-10 2:34 ` Thinh Nguyen
2023-11-10 2:43 ` Stanley Chang[昌育德]
2023-11-11 10:45 ` Johan Hovold
1 sibling, 1 reply; 6+ messages in thread
From: Thinh Nguyen @ 2023-11-10 2:34 UTC (permalink / raw)
To: Stanley Chang
Cc: Thinh Nguyen, Christophe JAILLET, Greg Kroah-Hartman, linux-usb,
linux-kernel
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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v1] usb: dwc3: add device put function to decrement the ref-counted reference
2023-11-10 2:34 ` Thinh Nguyen
@ 2023-11-10 2:43 ` Stanley Chang[昌育德]
2023-11-10 22:54 ` Thinh Nguyen
0 siblings, 1 reply; 6+ messages in thread
From: Stanley Chang[昌育德] @ 2023-11-10 2:43 UTC (permalink / raw)
To: Thinh Nguyen
Cc: Christophe JAILLET, Greg Kroah-Hartman, linux-usb, linux-kernel
> -----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
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] usb: dwc3: add device put function to decrement the ref-counted reference
2023-11-10 2:43 ` Stanley Chang[昌育德]
@ 2023-11-10 22:54 ` Thinh Nguyen
0 siblings, 0 replies; 6+ messages in thread
From: Thinh Nguyen @ 2023-11-10 22:54 UTC (permalink / raw)
To: Stanley Chang[昌育德]
Cc: Thinh Nguyen, Christophe JAILLET, Greg Kroah-Hartman, linux-usb,
linux-kernel
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] usb: dwc3: add device put function to decrement the ref-counted reference
2023-11-07 9:12 [PATCH v1] usb: dwc3: add device put function to decrement the ref-counted reference Stanley Chang
2023-11-10 2:34 ` Thinh Nguyen
@ 2023-11-11 10:45 ` Johan Hovold
2023-11-14 7:04 ` Stanley Chang[昌育德]
1 sibling, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2023-11-11 10:45 UTC (permalink / raw)
To: Stanley Chang
Cc: Thinh Nguyen, Christophe JAILLET, Greg Kroah-Hartman, linux-usb,
linux-kernel
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v1] usb: dwc3: add device put function to decrement the ref-counted reference
2023-11-11 10:45 ` Johan Hovold
@ 2023-11-14 7:04 ` Stanley Chang[昌育德]
0 siblings, 0 replies; 6+ messages in thread
From: Stanley Chang[昌育德] @ 2023-11-14 7:04 UTC (permalink / raw)
To: Johan Hovold
Cc: Thinh Nguyen, Christophe JAILLET, Greg Kroah-Hartman, linux-usb,
linux-kernel
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-14 7:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-07 9:12 [PATCH v1] usb: dwc3: add device put function to decrement the ref-counted reference Stanley Chang
2023-11-10 2:34 ` Thinh Nguyen
2023-11-10 2:43 ` Stanley Chang[昌育德]
2023-11-10 22:54 ` Thinh Nguyen
2023-11-11 10:45 ` Johan Hovold
2023-11-14 7:04 ` Stanley Chang[昌育德]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®