Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

coccinelle: add patch rule for dma_alloc_coherent

Commit dfd32cad146e ("dma-mapping: remove dma_zalloc_coherent()")
removed the definition of dma_zalloc_coherent() and also removed the
corresponding patch rule for replacing instances of dma_alloc_coherent +
memset in zalloc-simple.cocci (though left the report rule).

Add a new patch rule to remove unnecessary calls to memset after
allocating with dma_alloc_coherent. While we're at it, fix a couple of
typos.

Fixes: dfd32cad146e ("dma-mapping: remove dma_zalloc_coherent()")
Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

authored by

Alex Dewar and committed by
Julia Lawall
7a2624e6 4b2bd20c

+13 -3
+13 -3
scripts/coccinelle/api/alloc/zalloc-simple.cocci
··· 127 127 if ((x==NULL) || ...) S 128 128 - memset((T2)x,0,E1); 129 129 130 + @depends on patch@ 131 + type T, T2; 132 + expression x; 133 + expression E1,E2,E3,E4; 134 + statement S; 135 + @@ 136 + x = (T)dma_alloc_coherent(E1, E2, E3, E4); 137 + if ((x==NULL) || ...) S 138 + - memset((T2)x, 0, E2); 139 + 130 140 //---------------------------------------------------------- 131 141 // For org mode 132 142 //---------------------------------------------------------- ··· 209 199 position p; 210 200 @@ 211 201 212 - x = (T)dma_alloc_coherent@p(E2,E1,E3,E4); 202 + x = (T)dma_alloc_coherent@p(E1,E2,E3,E4); 213 203 if ((x==NULL) || ...) S 214 - memset((T2)x,0,E1); 204 + memset((T2)x,0,E2); 215 205 216 206 @script:python depends on org@ 217 207 p << r2.p; ··· 227 217 x << r2.x; 228 218 @@ 229 219 230 - msg="WARNING: dma_alloc_coherent use in %s already zeroes out memory, so memset is not needed" % (x) 220 + msg="WARNING: dma_alloc_coherent used in %s already zeroes out memory, so memset is not needed" % (x) 231 221 coccilib.report.print_report(p[0], msg) 232 222 233 223 //-----------------------------------------------------------------