From patchwork Mon Nov 13 14:45:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 118802 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1132254edl; Mon, 13 Nov 2017 06:48:07 -0800 (PST) X-Google-Smtp-Source: AGs4zMYr/Z2nwqEPolhx3QhjOgQ8hiWhl/v8VJdnkTjoXZs3/1AtCMlyh+XkL6DaFeFCYJe71WOl X-Received: by 10.99.96.87 with SMTP id u84mr9005159pgb.424.1510584487553; Mon, 13 Nov 2017 06:48:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510584487; cv=none; d=google.com; s=arc-20160816; b=G0tdfmghIj52pDxWnRSOlDD3XBO6fosLgK0zrMeQyqWCHVMcj1ZtECRTGDM+UPX16F VU0EZQ7oAaYHWe50+0oKzYxzVRJjB+fNHVUq4EgEHJzSxnMoil/GxM/oq1VT/feF5rOU OkMXXUz8J9ZfKo8ekCpEM7kVR1Q0skJoxfHnxwE+5/hNFXodukCzpj0EFYNVYGYlbWWx rEF+VA4O9ta6aj4EPEoc+9qK93o1MllcEiWrdXyZsHFcjvvjewgRsAzZC96jv/XYiYzC YAkY0nVcCaYlON/5aGHNrsTc0HsmpgY2dQRKoaL3HjITZsuu/5CyXc1f/TWbkFGyI5Ot k/LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=LuigOJkQ6DIb8uzydyCsaYqD2V/zoQ/UHBRN8ytUHx0=; b=hiq+ov8wNfKtpBic7xqnRiSkBkl1olVun5v7WC/uz4pPvdjDmzl1R+dbhglRempxrw outPhmRUDdXiSfK2Hp+J3MmvCPP8HTyNWvvrxv/mi553cMzMExG7uQxYnf8795RjsFvc /7QeIpKmf4iGJKrkSpMFeoEktI07PhxBm02Ox6z4c2PvmRJ8vjufNlY2vE2hwHoCSIVC 6cNWx4Mbq69pHgjg99UT+rQIyZ6WDWw5BpfILPx9KQhKvcYAK2PIlDjYg63oeVG9kBne 2O+TAaAm3hdLtMQBl38takpsK1lqC3t5XyyaKF6rWG8JvHyCQ/ntmeOWQNGT65aMdTMt 1uRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si3502354pgt.668.2017.11.13.06.48.07; Mon, 13 Nov 2017 06:48:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753480AbdKMOsF (ORCPT + 27 others); Mon, 13 Nov 2017 09:48:05 -0500 Received: from foss.arm.com ([217.140.101.70]:47428 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752929AbdKMOsC (ORCPT ); Mon, 13 Nov 2017 09:48:02 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 51EC51435; Mon, 13 Nov 2017 06:48:02 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B3B9F3F318; Mon, 13 Nov 2017 06:48:00 -0800 (PST) From: Gilad Ben-Yossef To: Greg Kroah-Hartman Cc: Ofir Drang , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/24] staging: ccree: refactor code with local vars Date: Mon, 13 Nov 2017 14:45:45 +0000 Message-Id: <1510584358-29473-18-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510584358-29473-1-git-send-email-gilad@benyossef.com> References: <1510584358-29473-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor the queue handling loop using local variables for better code readability. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_request_mgr.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index 001bbe9..a2a82ef 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -476,6 +476,8 @@ static void proc_completions(struct ssi_drvdata *drvdata) struct device *dev = drvdata_to_dev(drvdata); struct ssi_request_mgr_handle *request_mgr_handle = drvdata->request_mgr_handle; + unsigned int *tail = &request_mgr_handle->req_queue_tail; + unsigned int *head = &request_mgr_handle->req_queue_head; #if defined(CONFIG_PM) int rc = 0; #endif @@ -484,18 +486,17 @@ static void proc_completions(struct ssi_drvdata *drvdata) request_mgr_handle->axi_completed--; /* Dequeue request */ - if (unlikely(request_mgr_handle->req_queue_head == - request_mgr_handle->req_queue_tail)) { + if (unlikely(*head == *tail)) { /* We are supposed to handle a completion but our * queue is empty. This is not normal. Return and * hope for the best. */ dev_err(dev, "Request queue is empty head == tail %u\n", - request_mgr_handle->req_queue_head); + *head); break; } - ssi_req = &request_mgr_handle->req_queue[request_mgr_handle->req_queue_tail]; + ssi_req = &request_mgr_handle->req_queue[*tail]; #ifdef FLUSH_CACHE_ALL flush_cache_all(); @@ -516,11 +517,8 @@ static void proc_completions(struct ssi_drvdata *drvdata) if (likely(ssi_req->user_cb)) ssi_req->user_cb(dev, ssi_req->user_arg); - request_mgr_handle->req_queue_tail = - (request_mgr_handle->req_queue_tail + 1) & - (MAX_REQUEST_QUEUE_SIZE - 1); - dev_dbg(dev, "Dequeue request tail=%u\n", - request_mgr_handle->req_queue_tail); + *tail = (*tail + 1) & (MAX_REQUEST_QUEUE_SIZE - 1); + dev_dbg(dev, "Dequeue request tail=%u\n", *tail); dev_dbg(dev, "Request completed. axi_completed=%d\n", request_mgr_handle->axi_completed); #if defined(CONFIG_PM)