History

dma-mapping: remove dma_zalloc_coherent()

dma_zalloc_coherent() is no longer needed as it has no users because dma_alloc_coherent() already zeroes out memory for us. The Coccinelle grammar rule that used to check for dma_alloc_coherent() + memset() is modified so that it just tells the user that the memset is not needed anymore.

Luis Chamberlain committed 7 years ago

Commit dfd32ca1 parent 07a85fe3 files · +5 −23Browse files

Unified · Split

3 files
  1. include/linux/dma-mapping.h +0 −9
  2. scripts/coccinelle/api/alloc/alloc_cast.cocci +4 −4
  3. scripts/coccinelle/api/alloc/zalloc-simple.cocci +1 −10
include/linux/dma-mapping.h+0−9
@@ -717,15 +717,6 @@ static inline unsigned long dma_max_pfn(struct device *dev) · 716 unmodified lines
717717 }
718718 #endif
719719
720−/*
721− * Please always use dma_alloc_coherent instead as it already zeroes the memory!
722− */
723−static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
724− dma_addr_t *dma_handle, gfp_t flag)
725−{
726− return dma_alloc_coherent(dev, size, dma_handle, flag);
727−}
728−
729720 static inline int dma_get_cache_alignment(void)
730721 {
731722 #ifdef ARCH_DMA_MINALIGN
scripts/coccinelle/api/alloc/alloc_cast.cocci+4−4
@@ -32,7 +32,7 @@ type T; · 31 unmodified lines
3232 (T *)
3333 \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
3434 kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
35− dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\|
35+ dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
3636 kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
3737 pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
3838 kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
@@ -55,7 +55,7 @@ type r1.T; · 16 unmodified lines
5555 * (T *)
5656 \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
5757 kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
58− dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\|
58+ dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
5959 kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
6060 pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
6161 kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
@@ -78,7 +78,7 @@ type r1.T; · 16 unmodified lines
7878 - (T *)
7979 \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
8080 kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
81− dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\|
81+ dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
8282 kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
8383 pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
8484 kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
@@ -95,7 +95,7 @@ position p; · 10 unmodified lines
9595 (T@p *)
9696 \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
9797 kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
98− dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\|
98+ dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
9999 kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
100100 pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
101101 kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
scripts/coccinelle/api/alloc/zalloc-simple.cocci+1−10
@@ -69,15 +69,6 @@ statement S; · 68 unmodified lines
6969 - x = (T)vmalloc(E1);
7070 + x = (T)vzalloc(E1);
7171 |
72−- x = dma_alloc_coherent(E2,E1,E3,E4);
73−+ x = dma_zalloc_coherent(E2,E1,E3,E4);
74−|
75−- x = (T *)dma_alloc_coherent(E2,E1,E3,E4);
76−+ x = dma_zalloc_coherent(E2,E1,E3,E4);
77−|
78−- x = (T)dma_alloc_coherent(E2,E1,E3,E4);
79−+ x = (T)dma_zalloc_coherent(E2,E1,E3,E4);
80−|
8172 - x = kmalloc_node(E1,E2,E3);
8273 + x = kzalloc_node(E1,E2,E3);
8374 |
@@ -225,7 +216,7 @@ p << r2.p; · 141 unmodified lines
225216 x << r2.x;
226217 @@
227218
228−msg="WARNING: dma_zalloc_coherent should be used for %s, instead of dma_alloc_coherent/memset" % (x)
219+msg="WARNING: dma_alloc_coherent use in %s already zeroes out memory, so memset is not needed" % (x)
229220 coccilib.report.print_report(p[0], msg)
230221
231222 //-----------------------------------------------------------------