mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
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. Suggested-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
07a85fe142
commit
dfd32cad14
@ -717,15 +717,6 @@ static inline unsigned long dma_max_pfn(struct device *dev)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Please always use dma_alloc_coherent instead as it already zeroes the memory!
|
||||
*/
|
||||
static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
|
||||
dma_addr_t *dma_handle, gfp_t flag)
|
||||
{
|
||||
return dma_alloc_coherent(dev, size, dma_handle, flag);
|
||||
}
|
||||
|
||||
static inline int dma_get_cache_alignment(void)
|
||||
{
|
||||
#ifdef ARCH_DMA_MINALIGN
|
||||
|
@ -32,7 +32,7 @@ type T;
|
||||
(T *)
|
||||
\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
|
||||
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
|
||||
dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\|
|
||||
dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
|
||||
kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
|
||||
pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
|
||||
kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
|
||||
@ -55,7 +55,7 @@ type r1.T;
|
||||
* (T *)
|
||||
\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
|
||||
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
|
||||
dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\|
|
||||
dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
|
||||
kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
|
||||
pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
|
||||
kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
|
||||
@ -78,7 +78,7 @@ type r1.T;
|
||||
- (T *)
|
||||
\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
|
||||
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
|
||||
dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\|
|
||||
dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
|
||||
kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
|
||||
pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
|
||||
kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
|
||||
@ -95,7 +95,7 @@ position p;
|
||||
(T@p *)
|
||||
\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
|
||||
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
|
||||
dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\|
|
||||
dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
|
||||
kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
|
||||
pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
|
||||
kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
|
||||
|
@ -69,15 +69,6 @@ statement S;
|
||||
- x = (T)vmalloc(E1);
|
||||
+ x = (T)vzalloc(E1);
|
||||
|
|
||||
- x = dma_alloc_coherent(E2,E1,E3,E4);
|
||||
+ x = dma_zalloc_coherent(E2,E1,E3,E4);
|
||||
|
|
||||
- x = (T *)dma_alloc_coherent(E2,E1,E3,E4);
|
||||
+ x = dma_zalloc_coherent(E2,E1,E3,E4);
|
||||
|
|
||||
- x = (T)dma_alloc_coherent(E2,E1,E3,E4);
|
||||
+ x = (T)dma_zalloc_coherent(E2,E1,E3,E4);
|
||||
|
|
||||
- x = kmalloc_node(E1,E2,E3);
|
||||
+ x = kzalloc_node(E1,E2,E3);
|
||||
|
|
||||
@ -225,7 +216,7 @@ p << r2.p;
|
||||
x << r2.x;
|
||||
@@
|
||||
|
||||
msg="WARNING: dma_zalloc_coherent should be used for %s, instead of dma_alloc_coherent/memset" % (x)
|
||||
msg="WARNING: dma_alloc_coherent use in %s already zeroes out memory, so memset is not needed" % (x)
|
||||
coccilib.report.print_report(p[0], msg)
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user