* MEMORY ALLOCATOR.
*/
-#define sym_get_mem_cluster() \
- (void *) __get_free_pages(GFP_ATOMIC, SYM_MEM_PAGE_ORDER)
-#define sym_free_mem_cluster(p) \
- free_pages((unsigned long)p, SYM_MEM_PAGE_ORDER)
-
/*
* Link between free memory chunks of a given size.
*/
___sym_mfree(mp, ptr, size);
}
-/*
- * Default memory pool we donnot need to involve in DMA.
- *
- * With DMA abstraction, we use functions (methods), to
- * distinguish between non DMAable memory and DMAable memory.
- */
-static void *___mp0_get_mem_cluster(m_pool_p mp)
-{
- void *m = sym_get_mem_cluster();
- if (m)
- ++mp->nump;
- return m;
-}
-
-#ifdef SYM_MEM_FREE_UNUSED
-static void ___mp0_free_mem_cluster(m_pool_p mp, void *m)
-{
- sym_free_mem_cluster(m);
- --mp->nump;
-}
-#else
-#define ___mp0_free_mem_cluster NULL
-#endif
-
-static struct sym_m_pool mp0 = {
- NULL,
- ___mp0_get_mem_cluster,
- ___mp0_free_mem_cluster
-};
+static struct sym_m_pool *mempools = NULL;
/*
* Methods that maintains DMAable pools according to user allocations.
static inline m_pool_p ___get_dma_pool(m_pool_ident_t dev_dmat)
{
m_pool_p mp;
- for (mp = mp0.next;
- mp && !sym_m_pool_match(mp->dev_dmat, dev_dmat);
- mp = mp->next);
+ for (mp = mempools; mp; mp = mp->next)
+ if (sym_m_pool_match(mp->dev_dmat, dev_dmat))
+ break;
return mp;
}
#ifdef SYM_MEM_FREE_UNUSED
mp->free_mem_cluster = ___free_dma_mem_cluster;
#endif
- mp->next = mp0.next;
- mp0.next = mp;
+ mp->next = mempools;
+ mempools = mp;
return mp;
}
return NULL;
/* Destroy a DMAable memory pool (when got emptied) */
static void ___del_dma_pool(m_pool_p p)
{
- m_pool_p *pp = &mp0.next;
+ m_pool_p *pp = &mempools;
while (*pp && *pp != p)
pp = &(*pp)->next;