* [PATCH] drivers/soc/tegra: Replace dev_node refcount management
@ 2024-04-24 1:53 Miguel Miranda
2024-04-25 15:35 ` Thierry Reding
0 siblings, 1 reply; 2+ messages in thread
From: Miguel Miranda @ 2024-04-24 1:53 UTC (permalink / raw)
To: thierry.reding, jonathanh, linux-tegra, linux-kernel
Cc: skhan, javier.carrasco.cruz, julia.lawall
Remove the manual refcount management of device_node
and instead, use scope-based resource management.
While the pointer never gets out of scope it reduces
somehow the risk of missing the of_node_put() call.
Suggested-by: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: Miguel Miranda <mmikernel@gmail.com>
---
I only have a deprecated jetson nano dev-kit, but need
to test this on hardware. I am exploring options to
build a rootfs to test this using qemu-system-aarch64.
---
drivers/soc/tegra/common.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/soc/tegra/common.c b/drivers/soc/tegra/common.c
index dff6d5ef4e46..94d11102d90f 100644
--- a/drivers/soc/tegra/common.c
+++ b/drivers/soc/tegra/common.c
@@ -28,14 +28,12 @@ static const struct of_device_id tegra_machine_match[] = {
bool soc_is_tegra(void)
{
const struct of_device_id *match;
- struct device_node *root;
+ struct device_node *root __free(device_node) = of_find_node_by_path("/");
- root = of_find_node_by_path("/");
if (!root)
return false;
match = of_match_node(tegra_machine_match, root);
- of_node_put(root);
return match != NULL;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drivers/soc/tegra: Replace dev_node refcount management
2024-04-24 1:53 [PATCH] drivers/soc/tegra: Replace dev_node refcount management Miguel Miranda
@ 2024-04-25 15:35 ` Thierry Reding
0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2024-04-25 15:35 UTC (permalink / raw)
To: Miguel Miranda, jonathanh, linux-tegra, linux-kernel
Cc: skhan, javier.carrasco.cruz, julia.lawall
[-- Attachment #1: Type: text/plain, Size: 1743 bytes --]
On Wed Apr 24, 2024 at 3:53 AM CEST, Miguel Miranda wrote:
> Remove the manual refcount management of device_node
> and instead, use scope-based resource management.
>
> While the pointer never gets out of scope it reduces
> somehow the risk of missing the of_node_put() call.
I don't understand what you're trying to say here.
> Suggested-by: Julia Lawall <julia.lawall@inria.fr>
> Signed-off-by: Miguel Miranda <mmikernel@gmail.com>
> ---
> I only have a deprecated jetson nano dev-kit, but need
> to test this on hardware. I am exploring options to
> build a rootfs to test this using qemu-system-aarch64.
It doesn't look like it'll be necessary to extensively test this. Just
by inspecting this we can see that it doesn't change behaviour. There
isn't really a big advantage to employ the __free() mechanism here since
we have exactly one of_node_put() to clean up, but I guess why not. So
maybe reword that commit message to be less confusing.
Thierry
> ---
> drivers/soc/tegra/common.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/soc/tegra/common.c b/drivers/soc/tegra/common.c
> index dff6d5ef4e46..94d11102d90f 100644
> --- a/drivers/soc/tegra/common.c
> +++ b/drivers/soc/tegra/common.c
> @@ -28,14 +28,12 @@ static const struct of_device_id tegra_machine_match[] = {
> bool soc_is_tegra(void)
> {
> const struct of_device_id *match;
> - struct device_node *root;
> + struct device_node *root __free(device_node) = of_find_node_by_path("/");
>
> - root = of_find_node_by_path("/");
> if (!root)
> return false;
>
> match = of_match_node(tegra_machine_match, root);
> - of_node_put(root);
>
> return match != NULL;
> }
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-25 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-24 1:53 [PATCH] drivers/soc/tegra: Replace dev_node refcount management Miguel Miranda
2024-04-25 15:35 ` Thierry Reding
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).