[POWERPC] Change rheap functions to use ulongs instead of pointers
The rheap allocation functions return a pointer, but the actual value is based on how the heap was initialized, and so it can be anything, e.g. an offset into a buffer. A ulong is a better representation of the value returned by the allocation functions. This patch changes all of the relevant rheap functions to use a unsigned long integers instead of a pointer. In case of an error, the value returned is a negative error code that has been cast to an unsigned long. The caller can use the IS_ERR_VALUE() macro to check for this. All code which calls the rheap functions is updated accordingly. Macros IS_MURAM_ERR() and IS_DPERR(), have been deleted in favor of IS_ERR_VALUE(). Also added error checking to rh_attach_region(). Signed-off-by: Timur Tabi <timur@freescale.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
This commit is contained in:
@ -244,7 +244,7 @@ EXPORT_SYMBOL(qe_put_snum);
|
||||
static int qe_sdma_init(void)
|
||||
{
|
||||
struct sdma *sdma = &qe_immr->sdma;
|
||||
u32 sdma_buf_offset;
|
||||
unsigned long sdma_buf_offset;
|
||||
|
||||
if (!sdma)
|
||||
return -ENODEV;
|
||||
@ -252,10 +252,10 @@ static int qe_sdma_init(void)
|
||||
/* allocate 2 internal temporary buffers (512 bytes size each) for
|
||||
* the SDMA */
|
||||
sdma_buf_offset = qe_muram_alloc(512 * 2, 4096);
|
||||
if (IS_MURAM_ERR(sdma_buf_offset))
|
||||
if (IS_ERR_VALUE(sdma_buf_offset))
|
||||
return -ENOMEM;
|
||||
|
||||
out_be32(&sdma->sdebcr, sdma_buf_offset & QE_SDEBCR_BA_MASK);
|
||||
out_be32(&sdma->sdebcr, (u32) sdma_buf_offset & QE_SDEBCR_BA_MASK);
|
||||
out_be32(&sdma->sdmr, (QE_SDMR_GLB_1_MSK |
|
||||
(0x1 << QE_SDMR_CEN_SHIFT)));
|
||||
|
||||
@ -291,33 +291,32 @@ static void qe_muram_init(void)
|
||||
if ((np = of_find_node_by_name(NULL, "data-only")) != NULL) {
|
||||
address = *of_get_address(np, 0, &size, &flags);
|
||||
of_node_put(np);
|
||||
rh_attach_region(&qe_muram_info,
|
||||
(void *)address, (int)size);
|
||||
rh_attach_region(&qe_muram_info, address, (int) size);
|
||||
}
|
||||
}
|
||||
|
||||
/* This function returns an index into the MURAM area.
|
||||
*/
|
||||
u32 qe_muram_alloc(u32 size, u32 align)
|
||||
unsigned long qe_muram_alloc(int size, int align)
|
||||
{
|
||||
void *start;
|
||||
unsigned long start;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&qe_muram_lock, flags);
|
||||
start = rh_alloc_align(&qe_muram_info, size, align, "QE");
|
||||
spin_unlock_irqrestore(&qe_muram_lock, flags);
|
||||
|
||||
return (u32) start;
|
||||
return start;
|
||||
}
|
||||
EXPORT_SYMBOL(qe_muram_alloc);
|
||||
|
||||
int qe_muram_free(u32 offset)
|
||||
int qe_muram_free(unsigned long offset)
|
||||
{
|
||||
int ret;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&qe_muram_lock, flags);
|
||||
ret = rh_free(&qe_muram_info, (void *)offset);
|
||||
ret = rh_free(&qe_muram_info, offset);
|
||||
spin_unlock_irqrestore(&qe_muram_lock, flags);
|
||||
|
||||
return ret;
|
||||
@ -325,16 +324,16 @@ int qe_muram_free(u32 offset)
|
||||
EXPORT_SYMBOL(qe_muram_free);
|
||||
|
||||
/* not sure if this is ever needed */
|
||||
u32 qe_muram_alloc_fixed(u32 offset, u32 size)
|
||||
unsigned long qe_muram_alloc_fixed(unsigned long offset, int size)
|
||||
{
|
||||
void *start;
|
||||
unsigned long start;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&qe_muram_lock, flags);
|
||||
start = rh_alloc_fixed(&qe_muram_info, (void *)offset, size, "commproc");
|
||||
start = rh_alloc_fixed(&qe_muram_info, offset, size, "commproc");
|
||||
spin_unlock_irqrestore(&qe_muram_lock, flags);
|
||||
|
||||
return (u32) start;
|
||||
return start;
|
||||
}
|
||||
EXPORT_SYMBOL(qe_muram_alloc_fixed);
|
||||
|
||||
@ -344,7 +343,7 @@ void qe_muram_dump(void)
|
||||
}
|
||||
EXPORT_SYMBOL(qe_muram_dump);
|
||||
|
||||
void *qe_muram_addr(u32 offset)
|
||||
void *qe_muram_addr(unsigned long offset)
|
||||
{
|
||||
return (void *)&qe_immr->muram[offset];
|
||||
}
|
||||
|
Reference in New Issue
Block a user