forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
coccinelle: api: add devm_platform_ioremap_resource script
Use recently introduced devm_platform_ioremap_resource helper which wraps platform_get_resource() and devm_ioremap_resource() together. This helps produce much cleaner code and remove local `struct resource` declaration. Signed-off-by: Himanshu Jha <[email protected]> Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
- Loading branch information
1 parent
4bd01de
commit d09778d
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
scripts/coccinelle/api/devm_platform_ioremap_resource.cocci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/// Use devm_platform_ioremap_resource helper which wraps | ||
/// platform_get_resource() and devm_ioremap_resource() together. | ||
/// | ||
// Confidence: High | ||
// Copyright: (C) 2019 Himanshu Jha GPLv2. | ||
// Copyright: (C) 2019 Julia Lawall, Inria/LIP6. GPLv2. | ||
// Keywords: platform_get_resource, devm_ioremap_resource, | ||
// Keywords: devm_platform_ioremap_resource | ||
|
||
virtual patch | ||
virtual report | ||
|
||
@r depends on patch && !report@ | ||
expression e1, e2, arg1, arg2, arg3; | ||
identifier id; | ||
@@ | ||
|
||
( | ||
- id = platform_get_resource(arg1, IORESOURCE_MEM, arg2); | ||
| | ||
- struct resource *id = platform_get_resource(arg1, IORESOURCE_MEM, arg2); | ||
) | ||
... when != id | ||
- e1 = devm_ioremap_resource(arg3, id); | ||
+ e1 = devm_platform_ioremap_resource(arg1, arg2); | ||
... when != id | ||
? id = e2 | ||
|
||
@r1 depends on patch && !report@ | ||
identifier r.id; | ||
type T; | ||
@@ | ||
|
||
- T *id; | ||
...when != id | ||
|
||
@r2 depends on report && !patch@ | ||
identifier id; | ||
expression e1, e2, arg1, arg2, arg3; | ||
position j0; | ||
@@ | ||
|
||
( | ||
id = platform_get_resource(arg1, IORESOURCE_MEM, arg2); | ||
| | ||
struct resource *id = platform_get_resource(arg1, IORESOURCE_MEM, arg2); | ||
) | ||
... when != id | ||
e1@j0 = devm_ioremap_resource(arg3, id); | ||
... when != id | ||
? id = e2 | ||
|
||
@script:python depends on report && !patch@ | ||
e1 << r2.e1; | ||
j0 << r2.j0; | ||
@@ | ||
msg = "WARNING: Use devm_platform_ioremap_resource for %s" % (e1) | ||
coccilib.report.print_report(j0[0], msg) |