* [PATCH] usb/dwc3: replace of_node_put with __free
@ 2024-04-06 2:48 Andrew Ballance
2024-04-09 0:20 ` Thinh Nguyen
2024-04-09 15:19 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Andrew Ballance @ 2024-04-06 2:48 UTC (permalink / raw)
To: linux-kernel
Cc: linux-usb, gregkh, Thinh.Nguyen, linux-kernel-mentees, skhan,
Andrew Ballance
this relaces instances of of_node_put with __free(device_node)
in drivers/usb/dwc3/core.c
Signed-off-by: Andrew Ballance <andrewjballance@gmail.com>
---
drivers/usb/dwc3/core.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 31684cdaaae3..795a572d46cf 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1762,7 +1762,7 @@ static void dwc3_check_params(struct dwc3 *dwc)
static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
{
struct device *dev = dwc->dev;
- struct device_node *np_phy;
+ struct device_node *np_phy __free(device_node);
struct extcon_dev *edev = NULL;
const char *name;
@@ -1797,14 +1797,12 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
*/
np_phy = of_parse_phandle(dev->of_node, "phys", 0);
if (of_graph_is_present(np_phy)) {
- struct device_node *np_conn;
+ struct device_node *np_conn __free(device_node);
np_conn = of_graph_get_remote_node(np_phy, -1, -1);
if (np_conn)
edev = extcon_find_edev_by_node(np_conn);
- of_node_put(np_conn);
}
- of_node_put(np_phy);
return edev;
}
@@ -1915,14 +1913,13 @@ static int dwc3_probe(struct platform_device *pdev)
dwc_res.start += DWC3_GLOBALS_REGS_START;
if (dev->of_node) {
- struct device_node *parent = of_get_parent(dev->of_node);
+ struct device_node *parent __free(device_node) = of_get_parent(dev->of_node);
if (of_device_is_compatible(parent, "realtek,rtd-dwc3")) {
dwc_res.start -= DWC3_GLOBALS_REGS_START;
dwc_res.start += DWC3_RTK_RTD_GLOBALS_REGS_START;
}
- of_node_put(parent);
}
regs = devm_ioremap_resource(dev, &dwc_res);
--
2.44.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb/dwc3: replace of_node_put with __free
2024-04-06 2:48 [PATCH] usb/dwc3: replace of_node_put with __free Andrew Ballance
@ 2024-04-09 0:20 ` Thinh Nguyen
2024-04-09 15:19 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2024-04-09 0:20 UTC (permalink / raw)
To: Andrew Ballance
Cc: linux-kernel, linux-usb, gregkh, Thinh Nguyen,
linux-kernel-mentees, skhan
On Fri, Apr 05, 2024, Andrew Ballance wrote:
> this relaces instances of of_node_put with __free(device_node)
this relaces -> Replace
Also, fix the prefix to the $subject as "usb: dwc3: xxx"
> in drivers/usb/dwc3/core.c
Any particular reason why?
The recent cleanup addition to device_node to introduce this new cleanup
__free() is for a more complex error handling in cases such as get/put
in a loop. For a simple usage here, it breaks the typical code flow
making review not obvious when/whether of_node_put() is called IMO. So,
let's not do it here.
BR,
Thinh
>
> Signed-off-by: Andrew Ballance <andrewjballance@gmail.com>
> ---
> drivers/usb/dwc3/core.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 31684cdaaae3..795a572d46cf 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1762,7 +1762,7 @@ static void dwc3_check_params(struct dwc3 *dwc)
> static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
> {
> struct device *dev = dwc->dev;
> - struct device_node *np_phy;
> + struct device_node *np_phy __free(device_node);
> struct extcon_dev *edev = NULL;
> const char *name;
>
> @@ -1797,14 +1797,12 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
> */
> np_phy = of_parse_phandle(dev->of_node, "phys", 0);
> if (of_graph_is_present(np_phy)) {
> - struct device_node *np_conn;
> + struct device_node *np_conn __free(device_node);
>
> np_conn = of_graph_get_remote_node(np_phy, -1, -1);
> if (np_conn)
> edev = extcon_find_edev_by_node(np_conn);
> - of_node_put(np_conn);
> }
> - of_node_put(np_phy);
>
> return edev;
> }
> @@ -1915,14 +1913,13 @@ static int dwc3_probe(struct platform_device *pdev)
> dwc_res.start += DWC3_GLOBALS_REGS_START;
>
> if (dev->of_node) {
> - struct device_node *parent = of_get_parent(dev->of_node);
> + struct device_node *parent __free(device_node) = of_get_parent(dev->of_node);
>
> if (of_device_is_compatible(parent, "realtek,rtd-dwc3")) {
> dwc_res.start -= DWC3_GLOBALS_REGS_START;
> dwc_res.start += DWC3_RTK_RTD_GLOBALS_REGS_START;
> }
>
> - of_node_put(parent);
> }
>
> regs = devm_ioremap_resource(dev, &dwc_res);
> --
> 2.44.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb/dwc3: replace of_node_put with __free
2024-04-06 2:48 [PATCH] usb/dwc3: replace of_node_put with __free Andrew Ballance
2024-04-09 0:20 ` Thinh Nguyen
@ 2024-04-09 15:19 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2024-04-09 15:19 UTC (permalink / raw)
To: Andrew Ballance
Cc: linux-kernel, linux-usb, Thinh.Nguyen, linux-kernel-mentees, skhan
On Fri, Apr 05, 2024 at 09:48:38PM -0500, Andrew Ballance wrote:
> this relaces instances of of_node_put with __free(device_node)
> in drivers/usb/dwc3/core.c
Why? You need to always describe _why_ you do something, not _what_ you
do.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-09 15:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-06 2:48 [PATCH] usb/dwc3: replace of_node_put with __free Andrew Ballance
2024-04-09 0:20 ` Thinh Nguyen
2024-04-09 15:19 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).