From 7a30a227c51472746defb60a5c1f2ba2aea8e806 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sun, 23 Jan 2022 21:02:13 +0100 Subject: [PATCH] staging: vchiq_core: simplify vchiq_add_service_internal Better use kzalloc to properly init vchiq_service with zero. As a result this saves us all the zero assignments. Reviewed-by: Nicolas Saenz Julienne Signed-off-by: Stefan Wahren Link: https://lore.kernel.org/r/1642968143-19281-9-git-send-email-stefan.wahren@i2se.com Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 23 +--------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 6fa9fee..a13a076 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2097,16 +2097,6 @@ sync_func(void *v) return 0; } -static void -init_bulk_queue(struct vchiq_bulk_queue *queue) -{ - queue->local_insert = 0; - queue->remote_insert = 0; - queue->process = 0; - queue->remote_notify = 0; - queue->remove = 0; -} - inline const char * get_conn_state_name(enum vchiq_connstate conn_state) { @@ -2371,7 +2361,7 @@ vchiq_add_service_internal(struct vchiq_state *state, if (ret) return NULL; - service = kmalloc(sizeof(*service), GFP_KERNEL); + service = kzalloc(sizeof(*service), GFP_KERNEL); if (!service) return service; @@ -2387,28 +2377,17 @@ vchiq_add_service_internal(struct vchiq_state *state, service->public_fourcc = (srvstate == VCHIQ_SRVSTATE_OPENING) ? VCHIQ_FOURCC_INVALID : params->fourcc; - service->client_id = 0; service->auto_close = 1; - service->sync = 0; - service->closing = 0; - service->trace = 0; atomic_set(&service->poll_flags, 0); service->version = params->version; service->version_min = params->version_min; service->state = state; service->instance = instance; - service->service_use_count = 0; - service->msg_queue_read = 0; - service->msg_queue_write = 0; - init_bulk_queue(&service->bulk_tx); - init_bulk_queue(&service->bulk_rx); init_completion(&service->remove_event); init_completion(&service->bulk_remove_event); init_completion(&service->msg_queue_pop); init_completion(&service->msg_queue_push); mutex_init(&service->bulk_mutex); - memset(&service->stats, 0, sizeof(service->stats)); - memset(&service->msg_queue, 0, sizeof(service->msg_queue)); /* * Although it is perfectly possible to use a spinlock -- 2.7.4