1 /// Reimplement a call to devm_request_mem_region followed by a call to ioremap
2 /// or ioremap_nocache by a call to devm_request_and_ioremap.
3 /// Devm_request_and_ioremap was introduced in
4 /// 72f8c0bfa0de64c68ee59f40eb9b2683bffffbb0. It makes the code much more
9 // Copyright: (C) 2011 Julia Lawall, INRIA/LIP6. GPLv2.
10 // Copyright: (C) 2011 Gilles Muller, INRIA/LiP6. GPLv2.
11 // URL: http://coccinelle.lip6.fr/
13 // Options: --no-includes --include-headers
25 struct platform_driver i = { .driver = { .name = myname } };
28 expression dev,res,size;
31 -if (!devm_request_mem_region(dev, res->start, size,
32 - \(res->name\|dev_name(dev)\))) {
36 ... when != res->start
38 -devm_ioremap(dev,res->start,size)
39 +devm_request_and_ioremap(dev,res)
41 -devm_ioremap_nocache(dev,res->start,size)
42 +devm_request_and_ioremap(dev,res)
47 // this rule is separate from the previous one, because a single file can
48 // have multiple values of myname
50 expression dev,res,size;
54 -if (!devm_request_mem_region(dev, res->start, size,myname)) {
58 ... when != res->start
60 -devm_ioremap(dev,res->start,size)
61 +devm_request_and_ioremap(dev,res)
63 -devm_ioremap_nocache(dev,res->start,size)
64 +devm_request_and_ioremap(dev,res)
70 @pb depends on org || report || context@
71 expression dev,res,size;
77 (!devm_request_mem_region@p1(dev, res->start, size,
78 \(res->name\|dev_name(dev)\|myname\))) {
82 ... when != res->start
84 *devm_ioremap@p2(dev,res->start,size)
86 *devm_ioremap_nocache@p2(dev,res->start,size)
91 @script:python depends on org@
96 cocci.print_main("INFO: replace by devm_request_and_ioremap",p1)
97 cocci.print_secs("",p2)
99 @script:python depends on report@
104 msg = "INFO: devm_request_mem_region followed by ioremap on line %s can be replaced by devm_request_and_ioremap" % (p2[0].line)
105 coccilib.report.print_report(p1[0],msg)