Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: vchiq_core: Simplify bulk transfer queue message function

vchiq_bulk_xfer_queue_msg_killable() is a common function between
various bulk transfer code paths (blocking, callback and no-callback).
These code paths were simplified earlier by passing a populated
struct vchiq_bulk pointer in order to avoid open-coding the parameters
required to initiate a bulk transfer.

Now simplify the vchiq_bulk_xfer_queue_msg_killable() in a similar way
i.e. avoid open-coding the function parameters and pass the struct
vchiq_bulk pointer directly, coming from the various bulk transfer code
paths.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20241017133629.216672-6-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Umang Jain and committed by
Greg Kroah-Hartman
643f2e8a b7a0b111

+16 -23
+16 -23
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
··· 3022 3022 */ 3023 3023 static int 3024 3024 vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service, 3025 - void *offset, void __user *uoffset, 3026 - int size, void *userdata, 3027 - enum vchiq_bulk_mode mode, 3028 - enum vchiq_bulk_dir dir) 3025 + struct vchiq_bulk *bulk_params) 3029 3026 { 3030 3027 struct vchiq_bulk_queue *queue; 3031 3028 struct bulk_waiter *bulk_waiter = NULL; 3032 3029 struct vchiq_bulk *bulk; 3033 3030 struct vchiq_state *state = service->state; 3034 - const char dir_char = (dir == VCHIQ_BULK_TRANSMIT) ? 't' : 'r'; 3035 - const int dir_msgtype = (dir == VCHIQ_BULK_TRANSMIT) ? 3031 + const char dir_char = (bulk_params->dir == VCHIQ_BULK_TRANSMIT) ? 't' : 'r'; 3032 + const int dir_msgtype = (bulk_params->dir == VCHIQ_BULK_TRANSMIT) ? 3036 3033 VCHIQ_MSG_BULK_TX : VCHIQ_MSG_BULK_RX; 3037 3034 int status = -EINVAL; 3038 3035 int payload[2]; 3039 3036 3040 - if (mode == VCHIQ_BULK_MODE_BLOCKING) { 3041 - bulk_waiter = userdata; 3037 + if (bulk_params->mode == VCHIQ_BULK_MODE_BLOCKING) { 3038 + bulk_waiter = bulk_params->userdata; 3042 3039 init_completion(&bulk_waiter->event); 3043 3040 bulk_waiter->actual = 0; 3044 3041 bulk_waiter->bulk = NULL; 3045 3042 } 3046 3043 3047 - queue = (dir == VCHIQ_BULK_TRANSMIT) ? 3044 + queue = (bulk_params->dir == VCHIQ_BULK_TRANSMIT) ? 3048 3045 &service->bulk_tx : &service->bulk_rx; 3049 3046 3050 3047 if (mutex_lock_killable(&service->bulk_mutex)) ··· 3061 3064 3062 3065 bulk = &queue->bulks[BULK_INDEX(queue->local_insert)]; 3063 3066 3064 - bulk->mode = mode; 3065 - bulk->dir = dir; 3066 - bulk->userdata = userdata; 3067 - bulk->size = size; 3067 + /* Initiliaze the 'bulk' slot with bulk parameters passed in. */ 3068 + bulk->mode = bulk_params->mode; 3069 + bulk->dir = bulk_params->dir; 3070 + bulk->userdata = bulk_params->userdata; 3071 + bulk->size = bulk_params->size; 3072 + bulk->offset = bulk_params->offset; 3073 + bulk->uoffset = bulk_params->uoffset; 3068 3074 bulk->actual = VCHIQ_BULK_ACTUAL_ABORTED; 3069 - bulk->offset = offset; 3070 - bulk->uoffset = uoffset; 3071 3075 3072 3076 if (vchiq_prepare_bulk_data(service->instance, bulk)) 3073 3077 goto unlock_error_exit; ··· 3081 3083 3082 3084 dev_dbg(state->dev, "core: %d: bt (%d->%d) %cx %x@%pad %pK\n", 3083 3085 state->id, service->localport, service->remoteport, 3084 - dir_char, size, &bulk->data, userdata); 3086 + dir_char, bulk->size, &bulk->data, bulk->userdata); 3085 3087 3086 3088 /* 3087 3089 * The slot mutex must be held when the service is being closed, so ··· 3487 3489 goto error_exit; 3488 3490 3489 3491 3490 - status = vchiq_bulk_xfer_queue_msg_killable(service, bulk_params->offset, 3491 - bulk_params->uoffset, bulk_params->size, 3492 - bulk_params->userdata, bulk_params->mode, 3493 - bulk_params->dir); 3492 + status = vchiq_bulk_xfer_queue_msg_killable(service, bulk_params); 3494 3493 3495 3494 error_exit: 3496 3495 vchiq_service_put(service); ··· 3518 3523 if (vchiq_check_service(service)) 3519 3524 goto error_exit; 3520 3525 3521 - status = vchiq_bulk_xfer_queue_msg_killable(service, bulk_params->offset, bulk_params->uoffset, 3522 - bulk_params->size, bulk_params->userdata, 3523 - bulk_params->mode, bulk_params->dir); 3526 + status = vchiq_bulk_xfer_queue_msg_killable(service, bulk_params); 3524 3527 3525 3528 error_exit: 3526 3529 vchiq_service_put(service);