mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
83c4a4eec0
of_dev_get() and of_dev_put are just wrappers for get_device()/put_device() on a platform_device. There's also already platform_device_{get,put}() wrappers for this purpose. Let's update the few users and remove of_dev_{get,put}(). Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Frank Rowand <frowand.list@gmail.com> Cc: Patrice Chotard <patrice.chotard@st.com> Cc: Felipe Balbi <balbi@kernel.org> Cc: Julia Lawall <Julia.Lawall@inria.fr> Cc: Gilles Muller <Gilles.Muller@inria.fr> Cc: Nicolas Palix <nicolas.palix@imag.fr> Cc: Michal Marek <michal.lkml@markovi.net> Cc: linuxppc-dev@lists.ozlabs.org Cc: netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-usb@vger.kernel.org Cc: cocci@systeme.lip6.fr Signed-off-by: Rob Herring <robh@kernel.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20210211232745.1498137-2-robh@kernel.org
56 lines
1.3 KiB
Plaintext
56 lines
1.3 KiB
Plaintext
// SPDX-License-Identifier: GPL-2.0
|
|
/// Find missing put_device for every of_find_device_by_node.
|
|
///
|
|
// Confidence: Moderate
|
|
// Copyright: (C) 2018-2019 Wen Yang, ZTE.
|
|
// Comments:
|
|
// Options: --no-includes --include-headers
|
|
|
|
virtual report
|
|
virtual org
|
|
|
|
@search exists@
|
|
local idexpression id;
|
|
expression x,e,e1;
|
|
position p1,p2;
|
|
type T,T1,T2,T3;
|
|
@@
|
|
|
|
id = of_find_device_by_node@p1(x)
|
|
... when != e = id
|
|
if (id == NULL || ...) { ... return ...; }
|
|
... when != put_device(&id->dev)
|
|
when != platform_device_put(id)
|
|
when != if (id) { ... put_device(&id->dev) ... }
|
|
when != e1 = (T)id
|
|
when != e1 = (T)(&id->dev)
|
|
when != e1 = get_device(&id->dev)
|
|
when != e1 = (T1)platform_get_drvdata(id)
|
|
(
|
|
return
|
|
( id
|
|
| (T2)dev_get_drvdata(&id->dev)
|
|
| (T3)platform_get_drvdata(id)
|
|
| &id->dev
|
|
);
|
|
| return@p2 ...;
|
|
)
|
|
|
|
@script:python depends on report@
|
|
p1 << search.p1;
|
|
p2 << search.p2;
|
|
@@
|
|
|
|
coccilib.report.print_report(p2[0],
|
|
"ERROR: missing put_device; call of_find_device_by_node on line "
|
|
+ p1[0].line
|
|
+ ", but without a corresponding object release within this function.")
|
|
|
|
@script:python depends on org@
|
|
p1 << search.p1;
|
|
p2 << search.p2;
|
|
@@
|
|
|
|
cocci.print_main("of_find_device_by_node", p1)
|
|
cocci.print_secs("needed put_device", p2)
|