From patchwork Fri Jun 21 13:19:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13707602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16C3AC27C4F for ; Fri, 21 Jun 2024 13:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=s6Qd0JBwNqeO6s8Qewv27s50XwpHo8PayS9pYHQ6hRI=; b=CxsPLngNtTDSJ5//TFmd0pvBHO kd8qBM1qXO4VyJ8/FRCOCjOhs1An/XGGcg+jgb6/JOGxlZb9rfS2rKmZy+AkRuXas2qwgp5vOjf64 +ktPCEeLrjrg9hLXl7agn2Q2devddbDlp6j+Dj4HLFJpe84CJWumRMChhqERLYNuwQQLIaZgi7xZU vhHL91EBOdQWX6eWE7zbU0gp527BxU/pWQ/MoASzaQRRzn3+Xcs7LoMNkgVUcuFBSNb4Zux/9l5J8 FqSFFQQNb142bBrRc3BT7znQ9khW8PFr1jJGN2RXpvKZYgsHSSLfkQZxTPKht74v4nAaNA1bGjBAN qW+XXq2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKeBy-00000009JDA-1CTW; Fri, 21 Jun 2024 13:20:38 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKeBh-00000009J1P-2Nto for linux-arm-kernel@lists.infradead.org; Fri, 21 Jun 2024 13:20:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1718976017; x=1719580817; i=wahrenst@gmx.net; bh=s6Qd0JBwNqeO6s8Qewv27s50XwpHo8PayS9pYHQ6hRI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=eYzh8RAACH9tym3MALu+lGlrQ45ddpM5BGO3inXvM9Mf4p548q9A5dzG3/HP+Bkx wkvthWp2Z1zjGPIcRNUh90yDJ9vZGBrfHmmwG6g8nL2RJlsBL3Se8e1eepJ9iB5mK ybslRcHV2hsWzn+XmI7sPIbivT71ChQcET9Gnba4BRdQsAdpD4jVCsau6CvV4bjTU cwF3HplrfdSQ3eLA/2udT36HBB38VYDuoNfG/LYP3830hoVJaoxn+R3/ewdNm8eGA N01AkSJxFYo7gD9KZuzHb+qrqWJo24Ttw6QdKC0It3qEr2njT4j+/dpIFSp5v41kc OJThj3mg5pn6qXiiQQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MJmKh-1s4tgm1v1l-00LtW9; Fri, 21 Jun 2024 15:20:17 +0200 From: Stefan Wahren To: Greg Kroah-Hartman , Florian Fainelli Cc: Umang Jain , Laurent Pinchart , linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH V3 07/10] staging: vchiq_arm: Reduce indentation of service_callback Date: Fri, 21 Jun 2024 15:19:55 +0200 Message-Id: <20240621131958.98208-8-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240621131958.98208-1-wahrenst@gmx.net> References: <20240621131958.98208-1-wahrenst@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:M70WieD8RdT4wTe5a8IcnsIHrr1N5koPOebEp7xzUC1xpgRKw/c ZwAJiOrFF3RMc3w/JZ9+ing9xHaeOki3s8g5KlgryQnr9g2tEyfW+cP6Fz4J83cHBAtnUDy iHt5rDkoqk8L4kQku8+QQ6aOioNAOX6KkY99FA5mqdCUSDqb7YVLxM/pTc2mj7YtVZXFlEC XqDty6PH8jL1areO4Yi9g== UI-OutboundReport: notjunk:1;M01:P0:IPCd3hcT67Q=;Dmjt61wtU7tXNO7GXMPHDSKHySo oMw48qoKSKg/2yMxDzhcPEhc+7OEyjpq6YFHgKP8dUYE/vpbHy3kJY069pWFIZQOmaFJB1DNV 4UNQvVaJdJcR8aBJCpmR90SzPhSZzNIy2+TDAl6UuSq9TCipXtmXfFbYsvAtaisLwAtmIblD8 f/ib7Q2WuTOvO8OXyT4xhHWvr2qY9Hb+0rbF4LJXL098yvK1tsCqEnD44GpVix4228GaEPrtC sMiPFHkzFNiE47DmSej+kgRT6fHh7hU0XVyxnfMV+tGYLSGGzmpi7ye9aChu40jGbKVp+dEZ8 y1sVmjzngK86on5TOmnT9W5ZPms4OGKp8nwTCwLYJBTZ90BytVrQwJJHSerbO2jf3na7woeAk 9G8iHy83vsczSezkMUDGQEqBngOYDcAY8VOh0+xwSxkICiDlFzkA81o5TfgJv/A0mwEgIYqIB Bvonc/TGOk6ClCg91PvBf11gSEKGSdhnTxoKuCVDdn9KE9WLxpvaZWYjc2P1vHtEGx7NrBYw2 NOuowC1RbS9i8Xa+OquZVTght57A0fqz9dosJ8Om/eJG6IL4u5xlAwDQtzt0Po/JaemWAxTJP D7w9c/GDAr0Qq93TvJ2unP/LERqjp0OdQjlUAa7wKQtgsDhx6MuIec3RDopQ86uDjvrlEH80r uh0x8sbTc9MOhwJvRqUutbex/+d6OxPuyPSmL6yDJPTp4fc2CFSKfCkIc1j5Scv2F8dgq8BjZ +qhp0ZJrC1eYeux4U+8CpI6zCbbPr0rt9meZcfXjnWAQB89wfQp32TjI24xDLdiVaO4nBtW2d 5rAGEJ3pDiaDNV6EDJs+U1C5Yt+cl4THEm3mgCtcwGJXg= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240621_062021_924724_DF1E59B6 X-CRM114-Status: GOOD ( 13.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The service_callback has 5 levels of indentation, which makes it hard to read. Reduce this by splitting the code in a new function service_single_message() as suggested by Laurent Pinchart. Signed-off-by: Stefan Wahren --- .../interface/vchiq_arm/vchiq_arm.c | 72 +++++++++++-------- 1 file changed, 43 insertions(+), 29 deletions(-) -- 2.34.1 diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index cb37da7d8085..e3d49d4bdb1d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1055,6 +1055,43 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, return 0; } +static int +service_single_message(struct vchiq_instance *instance, + enum vchiq_reason reason, + struct vchiq_service *service, void *bulk_userdata) +{ + struct user_service *user_service; + + user_service = (struct user_service *)service->base.userdata; + + dev_dbg(service->state->dev, "arm: msg queue full\n"); + /* + * If there is no MESSAGE_AVAILABLE in the completion + * queue, add one + */ + if ((user_service->message_available_pos - + instance->completion_remove) < 0) { + int ret; + + dev_dbg(instance->state->dev, + "arm: Inserting extra MESSAGE_AVAILABLE\n"); + ret = add_completion(instance, reason, NULL, user_service, + bulk_userdata); + if (ret) + return ret; + } + + if (wait_for_completion_interruptible(&user_service->remove_event)) { + dev_dbg(instance->state->dev, "arm: interrupted\n"); + return -EAGAIN; + } else if (instance->closing) { + dev_dbg(instance->state->dev, "arm: closing\n"); + return -EINVAL; + } + + return 0; +} + int service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *bulk_userdata) @@ -1104,41 +1141,18 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, spin_lock(&service->state->msg_queue_spinlock); while (user_service->msg_insert == (user_service->msg_remove + MSG_QUEUE_SIZE)) { + int ret; + spin_unlock(&service->state->msg_queue_spinlock); DEBUG_TRACE(SERVICE_CALLBACK_LINE); DEBUG_COUNT(MSG_QUEUE_FULL_COUNT); - dev_dbg(service->state->dev, "arm: msg queue full\n"); - /* - * If there is no MESSAGE_AVAILABLE in the completion - * queue, add one - */ - if ((user_service->message_available_pos - - instance->completion_remove) < 0) { - int ret; - - dev_dbg(instance->state->dev, - "arm: Inserting extra MESSAGE_AVAILABLE\n"); - DEBUG_TRACE(SERVICE_CALLBACK_LINE); - ret = add_completion(instance, reason, NULL, user_service, - bulk_userdata); - if (ret) { - DEBUG_TRACE(SERVICE_CALLBACK_LINE); - vchiq_service_put(service); - return ret; - } - } - DEBUG_TRACE(SERVICE_CALLBACK_LINE); - if (wait_for_completion_interruptible(&user_service->remove_event)) { - dev_dbg(instance->state->dev, "arm: interrupted\n"); - DEBUG_TRACE(SERVICE_CALLBACK_LINE); - vchiq_service_put(service); - return -EAGAIN; - } else if (instance->closing) { - dev_dbg(instance->state->dev, "arm: closing\n"); + ret = service_single_message(instance, reason, + service, bulk_userdata); + if (ret) { DEBUG_TRACE(SERVICE_CALLBACK_LINE); vchiq_service_put(service); - return -EINVAL; + return ret; } DEBUG_TRACE(SERVICE_CALLBACK_LINE); spin_lock(&service->state->msg_queue_spinlock);