staging: vc04_services: Simplify (no)callback bulk transfer code paths

The (no)callback mode bulk transfer tends to open-code every function
parameter needed to initiate the bulk transfer. Instead of doing that,
simply pass a populated struct vchiq_bulk down the function chain.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20241017133629.216672-5-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Umang Jain
2024-10-17 19:06:27 +05:30
committed by Greg Kroah-Hartman
parent 72406c8a7a
commit b7a0b11170
4 changed files with 31 additions and 21 deletions

View File

@@ -497,9 +497,14 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, const
switch (mode) {
case VCHIQ_BULK_MODE_NOCALLBACK:
case VCHIQ_BULK_MODE_CALLBACK:
ret = vchiq_bulk_xfer_callback(instance, handle, (void *)data,
NULL, size, mode, userdata,
VCHIQ_BULK_TRANSMIT);
bulk_params.offset = (void *)data;
bulk_params.mode = mode;
bulk_params.size = size;
bulk_params.userdata = userdata;
bulk_params.dir = VCHIQ_BULK_TRANSMIT;
ret = vchiq_bulk_xfer_callback(instance, handle, &bulk_params);
break;
case VCHIQ_BULK_MODE_BLOCKING:
bulk_params.offset = (void *)data;
@@ -527,8 +532,14 @@ int vchiq_bulk_receive(struct vchiq_instance *instance, unsigned int handle,
switch (mode) {
case VCHIQ_BULK_MODE_NOCALLBACK:
case VCHIQ_BULK_MODE_CALLBACK:
ret = vchiq_bulk_xfer_callback(instance, handle, (void *)data, NULL,
size, mode, userdata, VCHIQ_BULK_RECEIVE);
bulk_params.offset = (void *)data;
bulk_params.mode = mode;
bulk_params.size = size;
bulk_params.userdata = userdata;
bulk_params.dir = VCHIQ_BULK_RECEIVE;
ret = vchiq_bulk_xfer_callback(instance, handle, &bulk_params);
break;
case VCHIQ_BULK_MODE_BLOCKING:
bulk_params.offset = (void *)data;

View File

@@ -3502,9 +3502,7 @@ vchiq_bulk_xfer_blocking(struct vchiq_instance *instance, unsigned int handle,
int
vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int handle,
void *offset, void __user *uoffset, int size,
enum vchiq_bulk_mode mode, void *userdata,
enum vchiq_bulk_dir dir)
struct vchiq_bulk *bulk_params)
{
struct vchiq_service *service = find_service_by_handle(instance, handle);
int status = -EINVAL;
@@ -3512,21 +3510,22 @@ vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int handle,
if (!service)
return -EINVAL;
if (mode != VCHIQ_BULK_MODE_CALLBACK &&
mode != VCHIQ_BULK_MODE_NOCALLBACK)
if (bulk_params->mode != VCHIQ_BULK_MODE_CALLBACK &&
bulk_params->mode != VCHIQ_BULK_MODE_NOCALLBACK)
goto error_exit;
if (service->srvstate != VCHIQ_SRVSTATE_OPEN)
goto error_exit;
if (!offset && !uoffset)
if (!bulk_params->offset && !bulk_params->uoffset)
goto error_exit;
if (vchiq_check_service(service))
goto error_exit;
status = vchiq_bulk_xfer_queue_msg_killable(service, offset, uoffset,
size, userdata, mode, dir);
status = vchiq_bulk_xfer_queue_msg_killable(service, bulk_params->offset, bulk_params->uoffset,
bulk_params->size, bulk_params->userdata,
bulk_params->mode, bulk_params->dir);
error_exit:
vchiq_service_put(service);

View File

@@ -505,9 +505,7 @@ vchiq_bulk_xfer_blocking(struct vchiq_instance *instance, unsigned int handle,
extern int
vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int handle,
void *offset, void __user *uoffset, int size,
enum vchiq_bulk_mode mode, void *userdata,
enum vchiq_bulk_dir dir);
struct vchiq_bulk *bulk);
extern void
vchiq_dump_state(struct seq_file *f, struct vchiq_state *state);

View File

@@ -335,12 +335,14 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
status = vchiq_bulk_xfer_waiting(instance, args->handle, userdata);
} else {
userdata = args->userdata;
status = vchiq_bulk_xfer_callback(instance, args->handle, NULL,
args->data, args->size,
args->mode, userdata, dir);
bulk_params.uoffset = args->data;
bulk_params.mode = args->mode;
bulk_params.size = args->size;
bulk_params.dir = dir;
bulk_params.userdata = args->userdata;
status = vchiq_bulk_xfer_callback(instance, args->handle,
&bulk_params);
}
if (!waiter) {