Skip to content

Commit c1ce6c2

Browse files
geertuChristoph Hellwig
authored andcommitted
mm: Add NO_DMA dummies for DMA pool API
Add dummies for dma{,m}_pool_{create,destroy,alloc,free}(), to allow compile-testing if NO_DMA=y. This prevents the following from showing up later: ERROR: "dma_pool_destroy" [drivers/usb/mtu3/mtu3.ko] undefined! ERROR: "dma_pool_free" [drivers/usb/mtu3/mtu3.ko] undefined! ERROR: "dma_pool_alloc" [drivers/usb/mtu3/mtu3.ko] undefined! ERROR: "dma_pool_create" [drivers/usb/mtu3/mtu3.ko] undefined! ERROR: "dma_pool_destroy" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined! ERROR: "dma_pool_free" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined! ERROR: "dma_pool_alloc" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined! ERROR: "dma_pool_create" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined! ERROR: "dma_pool_alloc" [drivers/mailbox/bcm-pdc-mailbox.ko] undefined! ERROR: "dma_pool_free" [drivers/mailbox/bcm-pdc-mailbox.ko] undefined! ERROR: "dma_pool_create" [drivers/mailbox/bcm-pdc-mailbox.ko] undefined! ERROR: "dma_pool_destroy" [drivers/mailbox/bcm-pdc-mailbox.ko] undefined! Signed-off-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Mark Brown <[email protected]> Acked-by: Robin Murphy <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent ab642e9 commit c1ce6c2

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

include/linux/dmapool.h

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,15 @@
1616

1717
struct device;
1818

19+
#ifdef CONFIG_HAS_DMA
20+
1921
struct dma_pool *dma_pool_create(const char *name, struct device *dev,
2022
size_t size, size_t align, size_t allocation);
2123

2224
void dma_pool_destroy(struct dma_pool *pool);
2325

2426
void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
2527
dma_addr_t *handle);
26-
27-
static inline void *dma_pool_zalloc(struct dma_pool *pool, gfp_t mem_flags,
28-
dma_addr_t *handle)
29-
{
30-
return dma_pool_alloc(pool, mem_flags | __GFP_ZERO, handle);
31-
}
32-
3328
void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr);
3429

3530
/*
@@ -39,5 +34,26 @@ struct dma_pool *dmam_pool_create(const char *name, struct device *dev,
3934
size_t size, size_t align, size_t allocation);
4035
void dmam_pool_destroy(struct dma_pool *pool);
4136

37+
#else /* !CONFIG_HAS_DMA */
38+
static inline struct dma_pool *dma_pool_create(const char *name,
39+
struct device *dev, size_t size, size_t align, size_t allocation)
40+
{ return NULL; }
41+
static inline void dma_pool_destroy(struct dma_pool *pool) { }
42+
static inline void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
43+
dma_addr_t *handle) { return NULL; }
44+
static inline void dma_pool_free(struct dma_pool *pool, void *vaddr,
45+
dma_addr_t addr) { }
46+
static inline struct dma_pool *dmam_pool_create(const char *name,
47+
struct device *dev, size_t size, size_t align, size_t allocation)
48+
{ return NULL; }
49+
static inline void dmam_pool_destroy(struct dma_pool *pool) { }
50+
#endif /* !CONFIG_HAS_DMA */
51+
52+
static inline void *dma_pool_zalloc(struct dma_pool *pool, gfp_t mem_flags,
53+
dma_addr_t *handle)
54+
{
55+
return dma_pool_alloc(pool, mem_flags | __GFP_ZERO, handle);
56+
}
57+
4258
#endif
4359

0 commit comments

Comments
 (0)