Commit 001943e8 authored by Narcisa Ana Maria Vasile's avatar Narcisa Ana Maria Vasile Committed by Greg Kroah-Hartman

staging: vc04_services: Refactor conditionals

Refactor conditionals to reduce one level of indentation and improve
code readability.
Signed-off-by: default avatarNarcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 41831482
...@@ -2574,9 +2574,14 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state, ...@@ -2574,9 +2574,14 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state,
VCHIQ_INSTANCE_T instance, VCHIQ_USERDATA_TERM_T userdata_term) VCHIQ_INSTANCE_T instance, VCHIQ_USERDATA_TERM_T userdata_term)
{ {
VCHIQ_SERVICE_T *service; VCHIQ_SERVICE_T *service;
VCHIQ_SERVICE_T **pservice = NULL;
VCHIQ_SERVICE_QUOTA_T *service_quota;
int i;
service = kmalloc(sizeof(VCHIQ_SERVICE_T), GFP_KERNEL); service = kmalloc(sizeof(VCHIQ_SERVICE_T), GFP_KERNEL);
if (service) { if (!service)
return service;
service->base.fourcc = params->fourcc; service->base.fourcc = params->fourcc;
service->base.callback = params->callback; service->base.callback = params->callback;
service->base.userdata = params->userdata; service->base.userdata = params->userdata;
...@@ -2606,11 +2611,6 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state, ...@@ -2606,11 +2611,6 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state,
sema_init(&service->bulk_remove_event, 0); sema_init(&service->bulk_remove_event, 0);
mutex_init(&service->bulk_mutex); mutex_init(&service->bulk_mutex);
memset(&service->stats, 0, sizeof(service->stats)); memset(&service->stats, 0, sizeof(service->stats));
}
if (service) {
VCHIQ_SERVICE_T **pservice = NULL;
int i;
/* Although it is perfectly possible to use service_spinlock /* Although it is perfectly possible to use service_spinlock
** to protect the creation of services, it is overkill as it ** to protect the creation of services, it is overkill as it
...@@ -2675,11 +2675,8 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state, ...@@ -2675,11 +2675,8 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state,
kfree(service); kfree(service);
service = NULL; service = NULL;
} }
}
if (service) { service_quota = &state->service_quotas[service->localport];
VCHIQ_SERVICE_QUOTA_T *service_quota =
&state->service_quotas[service->localport];
service_quota->slot_quota = state->default_slot_quota; service_quota->slot_quota = state->default_slot_quota;
service_quota->message_quota = state->default_message_quota; service_quota->message_quota = state->default_message_quota;
if (service_quota->slot_use_count == 0) if (service_quota->slot_use_count == 0)
...@@ -2696,7 +2693,6 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state, ...@@ -2696,7 +2693,6 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state,
? "Open" : "Add", ? "Open" : "Add",
VCHIQ_FOURCC_AS_4CHARS(params->fourcc), VCHIQ_FOURCC_AS_4CHARS(params->fourcc),
service->localport); service->localport);
}
/* Don't unlock the service - leave it with a ref_count of 1. */ /* Don't unlock the service - leave it with a ref_count of 1. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment