* [PATCH] arch/powerpc: Drop unnecessary of_node_put
@ 2010-08-03 19:50 Julia Lawall
2010-08-05 0:01 ` Grant Likely
0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2010-08-03 19:50 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Grant Likely,
linuxppc-dev, linux-kernel, devicetree-discuss, kernel-janitors
From: Julia Lawall <julia@diku.dk>
for_each_node_by_name only exits when its first argument is NULL, and a
subsequent call to of_node_put on that argument is unnecessary.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
iterator name for_each_node_by_name;
expression np,E;
identifier l;
@@
for_each_node_by_name(np,...) {
... when != break;
when != goto l;
}
... when != np = E
- of_node_put(np);
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
arch/powerpc/platforms/powermac/feature.c | 1 -
arch/powerpc/platforms/powermac/pci.c | 2 --
2 files changed, 3 deletions(-)
diff -u -p a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -2872,7 +2872,6 @@ set_initial_features(void)
core99_airport_enable(np, 0, 0);
}
}
- of_node_put(np);
}
/* On all machines that support sound PM, switch sound off */
diff -u -p a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -1155,13 +1155,11 @@ void __init pmac_pcibios_after_init(void
pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, nd, 0, 0);
}
}
- of_node_put(nd);
for_each_node_by_name(nd, "ethernet") {
if (nd->parent && of_device_is_compatible(nd, "gmac")
&& of_device_is_compatible(nd->parent, "uni-north"))
pmac_call_feature(PMAC_FTR_GMAC_ENABLE, nd, 0, 0);
}
- of_node_put(nd);
}
void pmac_pci_fixup_cardbus(struct pci_dev* dev)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] arch/powerpc: Drop unnecessary of_node_put
2010-08-03 19:50 [PATCH] arch/powerpc: Drop unnecessary of_node_put Julia Lawall
@ 2010-08-05 0:01 ` Grant Likely
0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2010-08-05 0:01 UTC (permalink / raw)
To: Julia Lawall
Cc: devicetree-discuss, kernel-janitors, linux-kernel, linuxppc-dev,
Paul Mackerras
On Tue, Aug 3, 2010 at 1:50 PM, Julia Lawall <julia@diku.dk> wrote:
> From: Julia Lawall <julia@diku.dk>
>
> for_each_node_by_name only exits when its first argument is NULL, and a
> subsequent call to of_node_put on that argument is unnecessary.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> iterator name for_each_node_by_name;
> expression np,E;
> identifier l;
> @@
>
> for_each_node_by_name(np,...) {
> =A0... when !=3D break;
> =A0 =A0 =A0when !=3D goto l;
> }
> ... when !=3D np =3D E
> - of_node_put(np);
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>
Looks correct to me:
Reviewed-by: Grant Likely <grant.likely@secretlab.ca>
>
> ---
> =A0arch/powerpc/platforms/powermac/feature.c | =A0 =A01 -
> =A0arch/powerpc/platforms/powermac/pci.c =A0 =A0 | =A0 =A02 --
> =A02 files changed, 3 deletions(-)
>
> diff -u -p a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/pla=
tforms/powermac/feature.c
> --- a/arch/powerpc/platforms/powermac/feature.c
> +++ b/arch/powerpc/platforms/powermac/feature.c
> @@ -2872,7 +2872,6 @@ set_initial_features(void)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0core99_air=
port_enable(np, 0, 0);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 of_node_put(np);
> =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0/* On all machines that support sound PM, switch sound off=
*/
> diff -u -p a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platfor=
ms/powermac/pci.c
> --- a/arch/powerpc/platforms/powermac/pci.c
> +++ b/arch/powerpc/platforms/powermac/pci.c
> @@ -1155,13 +1155,11 @@ void __init pmac_pcibios_after_init(void
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pmac_call_feature(PMAC_FTR=
_1394_CABLE_POWER, nd, 0, 0);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0}
> - =A0 =A0 =A0 of_node_put(nd);
> =A0 =A0 =A0 =A0for_each_node_by_name(nd, "ethernet") {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (nd->parent && of_device_is_compatible(=
nd, "gmac")
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&& of_device_is_compatible(nd->par=
ent, "uni-north"))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pmac_call_feature(PMAC_FTR=
_GMAC_ENABLE, nd, 0, 0);
> =A0 =A0 =A0 =A0}
> - =A0 =A0 =A0 of_node_put(nd);
> =A0}
>
> =A0void pmac_pci_fixup_cardbus(struct pci_dev* dev)
>
--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-08-05 0:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-03 19:50 [PATCH] arch/powerpc: Drop unnecessary of_node_put Julia Lawall
2010-08-05 0:01 ` Grant Likely
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).