diff options
Diffstat (limited to 'drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c')
-rw-r--r-- | drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index be08849175ea..eea2d78b0ec6 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -59,10 +59,10 @@ #define BELL0 0x00 #define BELL2 0x08 -typedef struct vchiq_2835_state_struct { +struct vchiq_2835_state { int inited; VCHIQ_ARM_STATE_T arm_state; -} VCHIQ_2835_ARM_STATE_T; +}; struct vchiq_pagelist_info { PAGELIST_T *pagelist; @@ -84,8 +84,6 @@ static char *g_free_fragments; static struct semaphore g_free_fragments_sema; static struct device *g_dev; -extern int vchiq_arm_log_level; - static DEFINE_SEMAPHORE(g_free_fragments_mutex); static irqreturn_t @@ -206,25 +204,31 @@ VCHIQ_STATUS_T vchiq_platform_init_state(VCHIQ_STATE_T *state) { VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + struct vchiq_2835_state *platform_state; + + state->platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL); + platform_state = (struct vchiq_2835_state *)state->platform_state; + + platform_state->inited = 1; + status = vchiq_arm_init_state(state, &platform_state->arm_state); - state->platform_state = kzalloc(sizeof(VCHIQ_2835_ARM_STATE_T), GFP_KERNEL); - ((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->inited = 1; - status = vchiq_arm_init_state(state, &((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->arm_state); if (status != VCHIQ_SUCCESS) - { - ((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->inited = 0; - } + platform_state->inited = 0; + return status; } VCHIQ_ARM_STATE_T* vchiq_platform_get_arm_state(VCHIQ_STATE_T *state) { - if (!((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->inited) - { + struct vchiq_2835_state *platform_state; + + platform_state = (struct vchiq_2835_state *)state->platform_state; + + if (!platform_state->inited) BUG(); - } - return &((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->arm_state; + + return &platform_state->arm_state; } void @@ -383,12 +387,12 @@ cleanup_pagelistinfo(struct vchiq_pagelist_info *pagelistinfo) } /* There is a potential problem with partial cache lines (pages?) -** at the ends of the block when reading. If the CPU accessed anything in -** the same line (page?) then it may have pulled old data into the cache, -** obscuring the new data underneath. We can solve this by transferring the -** partial cache lines separately, and allowing the ARM to copy into the -** cached area. -*/ + * at the ends of the block when reading. If the CPU accessed anything in + * the same line (page?) then it may have pulled old data into the cache, + * obscuring the new data underneath. We can solve this by transferring the + * partial cache lines separately, and allowing the ARM to copy into the + * cached area. + */ static struct vchiq_pagelist_info * create_pagelist(char __user *buf, size_t count, unsigned short type, @@ -415,15 +419,15 @@ create_pagelist(char __user *buf, size_t count, unsigned short type, sizeof(struct vchiq_pagelist_info); /* Allocate enough storage to hold the page pointers and the page - ** list - */ + * list + */ pagelist = dma_zalloc_coherent(g_dev, pagelist_size, &dma_addr, GFP_KERNEL); - vchiq_log_trace(vchiq_arm_log_level, "create_pagelist - %pK", - pagelist); + vchiq_log_trace(vchiq_arm_log_level, "%s - %pK", __func__, pagelist); + if (!pagelist) return NULL; @@ -483,9 +487,8 @@ create_pagelist(char __user *buf, size_t count, unsigned short type, if (actual_pages != num_pages) { vchiq_log_info(vchiq_arm_log_level, - "create_pagelist - only %d/%d pages locked", - actual_pages, - num_pages); + "%s - only %d/%d pages locked", + __func__, actual_pages, num_pages); /* This is probably due to the process being killed */ while (actual_pages > 0) |