@@ -594,7 +594,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
* Cancel the signal when the transfer completes.
*/
spin_lock(&service->state->bulk_waiter_spinlock);
- bulk->userdata = NULL;
+ bulk->waiter = NULL;
spin_unlock(&service->state->bulk_waiter_spinlock);
}
}
@@ -604,7 +604,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
return -ENOMEM;
}
- bulk_params->userdata = &waiter->bulk_waiter;
+ bulk_params->waiter = &waiter->bulk_waiter;
ret = vchiq_bulk_xfer_blocking(instance, handle, bulk_params);
if ((ret != -EAGAIN) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) {
@@ -613,7 +613,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
if (bulk) {
/* Cancel the signal when the transfer completes. */
spin_lock(&service->state->bulk_waiter_spinlock);
- bulk->userdata = NULL;
+ bulk->waiter = NULL;
spin_unlock(&service->state->bulk_waiter_spinlock);
}
kfree(waiter);
@@ -1330,7 +1330,7 @@ static int service_notify_bulk(struct vchiq_service *service,
struct bulk_waiter *waiter;
spin_lock(&service->state->bulk_waiter_spinlock);
- waiter = bulk->userdata;
+ waiter = bulk->waiter;
if (waiter) {
waiter->actual = bulk->actual;
complete(&waiter->event);
@@ -3035,7 +3035,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service,
int payload[2];
if (bulk_params->mode == VCHIQ_BULK_MODE_BLOCKING) {
- bulk_waiter = bulk_params->userdata;
+ bulk_waiter = bulk_params->waiter;
init_completion(&bulk_waiter->event);
bulk_waiter->actual = 0;
bulk_waiter->bulk = NULL;
@@ -3064,6 +3064,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service,
/* Initiliaze the 'bulk' slot with bulk parameters passed in. */
bulk->mode = bulk_params->mode;
bulk->dir = bulk_params->dir;
+ bulk->waiter = bulk_params->waiter;
bulk->userdata = bulk_params->userdata;
bulk->size = bulk_params->size;
bulk->offset = bulk_params->offset;
@@ -3533,7 +3534,7 @@ vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int handle,
*/
int
vchiq_bulk_xfer_waiting(struct vchiq_instance *instance,
- unsigned int handle, struct bulk_waiter *userdata)
+ unsigned int handle, struct bulk_waiter *waiter)
{
struct vchiq_service *service = find_service_by_handle(instance, handle);
struct bulk_waiter *bulk_waiter;
@@ -3542,7 +3543,7 @@ vchiq_bulk_xfer_waiting(struct vchiq_instance *instance,
if (!service)
return -EINVAL;
- if (!userdata)
+ if (!waiter)
goto error_exit;
if (service->srvstate != VCHIQ_SRVSTATE_OPEN)
@@ -3551,7 +3552,7 @@ vchiq_bulk_xfer_waiting(struct vchiq_instance *instance,
if (vchiq_check_service(service))
goto error_exit;
- bulk_waiter = userdata;
+ bulk_waiter = waiter;
vchiq_service_put(service);
@@ -115,6 +115,7 @@ struct vchiq_bulk {
short mode;
short dir;
void *userdata;
+ struct bulk_waiter *waiter;
dma_addr_t dma_addr;
int size;
void *remote_data;
@@ -307,7 +307,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
bulk_params.mode = args->mode;
bulk_params.size = args->size;
bulk_params.dir = dir;
- bulk_params.userdata = &waiter->bulk_waiter;
+ bulk_params.waiter = &waiter->bulk_waiter;
status = vchiq_bulk_xfer_blocking(instance, args->handle,
&bulk_params);
@@ -354,7 +354,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
if (waiter->bulk_waiter.bulk) {
/* Cancel the signal when the transfer completes. */
spin_lock(&service->state->bulk_waiter_spinlock);
- waiter->bulk_waiter.bulk->userdata = NULL;
+ waiter->bulk_waiter.bulk->waiter = NULL;
spin_unlock(&service->state->bulk_waiter_spinlock);
}
kfree(waiter);
Currently, struct bulk_waiter is allocated for VCHIQ_BULK_MODE_BLOCKING bulk transfer and its pointer is assigned to vchiq_bulk->userdata. Avoid this kind of piggybacking and introduce a dedicate 'waiter' member in struct vchiq_bulk. The 'userdata' is meant for VCHIQ_BULK_MODE_CALLBACK mode, to pass user specified parameter to the actual callback function. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 +++--- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 11 ++++++----- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 1 + .../vc04_services/interface/vchiq_arm/vchiq_dev.c | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-)