Commit b3582ed4 authored by Stefan Wahren's avatar Stefan Wahren Committed by Greg Kroah-Hartman
Browse files

staging: vchiq_core: Exit early in 2 functions



Exit early allow us to reduce the indention in vchiq_open_service_internal()
and vchiq_set_service_option(). Btw we can avoid the multi-line assignments
of quota.

Signed-off-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1618164700-21150-5-git-send-email-stefan.wahren@i2se.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 32129ec0
Loading
Loading
Loading
Loading
+74 −77
Original line number Diff line number Diff line
@@ -2525,7 +2525,10 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id)
			       &payload,
			       sizeof(payload),
			       QMFLAGS_IS_BLOCKING);
	if (status == VCHIQ_SUCCESS) {

	if (status != VCHIQ_SUCCESS)
		return status;

	/* Wait for the ACK/NAK */
	if (wait_for_completion_interruptible(&service->remove_event)) {
		status = VCHIQ_RETRY;
@@ -2542,7 +2545,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id)
		VCHIQ_SERVICE_STATS_INC(service, error_count);
		vchiq_release_service_internal(service);
	}
	}

	return status;
}

@@ -3359,7 +3362,9 @@ vchiq_set_service_option(unsigned int handle,
	enum vchiq_status status = VCHIQ_ERROR;
	struct vchiq_service_quota *quota;

	if (service) {
	if (!service)
		return VCHIQ_ERROR;

	switch (option) {
	case VCHIQ_SERVICE_OPTION_AUTOCLOSE:
		service->auto_close = value;
@@ -3367,38 +3372,32 @@ vchiq_set_service_option(unsigned int handle,
		break;

	case VCHIQ_SERVICE_OPTION_SLOT_QUOTA:
			quota = &service->state->service_quotas[
					service->localport];
		quota = &service->state->service_quotas[service->localport];
		if (value == 0)
			value = service->state->default_slot_quota;
		if ((value >= quota->slot_use_count) &&
		    (value < (unsigned short)~0)) {
			quota->slot_quota = value;
			if ((value >= quota->slot_use_count) &&
					(quota->message_quota >=
					 quota->message_use_count)) {
			    (quota->message_quota >= quota->message_use_count))
				/*
				 * Signal the service that it may have
				 * dropped below its quota
				 */
				complete(&quota->quota_event);
				}
			status = VCHIQ_SUCCESS;
		}
		break;

	case VCHIQ_SERVICE_OPTION_MESSAGE_QUOTA:
			quota = &service->state->service_quotas[
					service->localport];
		quota = &service->state->service_quotas[service->localport];
		if (value == 0)
			value = service->state->default_message_quota;
		if ((value >= quota->message_use_count) &&
		    (value < (unsigned short)~0)) {
			quota->message_quota = value;
				if ((value >=
					quota->message_use_count) &&
					(quota->slot_quota >=
					quota->slot_use_count))
			if ((value >= quota->message_use_count) &&
			    (quota->slot_quota >= quota->slot_use_count))
				/*
				 * Signal the service that it may have
				 * dropped below its quota
@@ -3410,8 +3409,7 @@ vchiq_set_service_option(unsigned int handle,

	case VCHIQ_SERVICE_OPTION_SYNCHRONOUS:
		if ((service->srvstate == VCHIQ_SRVSTATE_HIDDEN) ||
				(service->srvstate ==
				VCHIQ_SRVSTATE_LISTENING)) {
		    (service->srvstate == VCHIQ_SRVSTATE_LISTENING)) {
			service->sync = value;
			status = VCHIQ_SUCCESS;
		}
@@ -3426,7 +3424,6 @@ vchiq_set_service_option(unsigned int handle,
		break;
	}
	unlock_service(service);
	}

	return status;
}