All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilad Ben-Yossef <gilad@benyossef.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	driverdev-devel@linuxdriverproject.org,
	linux-crypto@vger.kernel.org, Ofir Drang <ofir.drang@arm.com>
Subject: [PATCH 17/24] staging: ccree: refactor code with local vars
Date: Mon, 13 Nov 2017 14:45:45 +0000	[thread overview]
Message-ID: <1510584358-29473-18-git-send-email-gilad@benyossef.com> (raw)
In-Reply-To: <1510584358-29473-1-git-send-email-gilad@benyossef.com>

Refactor the queue handling loop using local variables for better
code readability.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_request_mgr.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

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)
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: Gilad Ben-Yossef <gilad@benyossef.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ofir Drang <ofir.drang@arm.com>,
	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	[thread overview]
Message-ID: <1510584358-29473-18-git-send-email-gilad@benyossef.com> (raw)
In-Reply-To: <1510584358-29473-1-git-send-email-gilad@benyossef.com>

Refactor the queue handling loop using local variables for better
code readability.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_request_mgr.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

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)
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: Gilad Ben-Yossef <gilad@benyossef.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	driverdev-devel@linuxdriverproject.org,
	linux-crypto@vger.kernel.org, Ofir Drang <ofir.drang@arm.com>
Subject: [PATCH 17/24] staging: ccree: refactor code with local vars
Date: Mon, 13 Nov 2017 14:45:45 +0000	[thread overview]
Message-ID: <1510584358-29473-18-git-send-email-gilad@benyossef.com> (raw)
In-Reply-To: <1510584358-29473-1-git-send-email-gilad@benyossef.com>

Refactor the queue handling loop using local variables for better
code readability.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_request_mgr.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

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)
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  parent reply	other threads:[~2017-11-13 14:45 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-13 14:45 [PATCH 00/24] staging: ccree: more cleanup patches Gilad Ben-Yossef
2017-11-13 14:45 ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 01/24] staging: ccree: fix typos Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 02/24] staging: ccree: alloc by instance not type Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 03/24] staging: ccree: remove unnecessary parentheses Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 04/24] staging: ccree: remove MIN/MAX macros Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 05/24] staging: ccree: move logical cont. to 1st line Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 06/24] staging: ccree: remove unneeded empty lines Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 07/24] staging: ccree: remove unneeded cast Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 15:41   ` Joe Perches
2017-11-13 15:41     ` Joe Perches
2017-11-14  9:30     ` Gilad Ben-Yossef
2017-11-14  9:30       ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 08/24] staging: ccree: make mem barrier per request Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 09/24] staging: ccree: replace open coded loop with for Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 10/24] staging: ccree: document spinlock usage Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 11/24] staging: ccree: constify help string Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 12/24] staging: ccree: fix code indent Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 13/24] staging: ccree: Replace CONFIG_PM_RUNTIME with CONFIG_PM Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 14/24] staging: ccree: replace macro with inline func Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 15/24] staging: ccree: trim long lines for readability Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 16/24] staging: ccree: remove dead defs and decls Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` Gilad Ben-Yossef [this message]
2017-11-13 14:45   ` [PATCH 17/24] staging: ccree: refactor code with local vars Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 18/24] staging: ccree: rename func for readability Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 19/24] staging: ccree: rename long define " Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 20/24] staging: ccree: remove unneeded wrapper function Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 21/24] staging: ccree: remove unused field Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 22/24] staging: ccree: replace msleep with a completion Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 23/24] staging: ccree: use local vars for readability Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45 ` [PATCH 24/24] staging: ccree: drop unused macro Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 14:45   ` Gilad Ben-Yossef
2017-11-13 18:33 ` [PATCH 00/24] staging: ccree: more cleanup patches Dan Carpenter
2017-11-13 18:33   ` Dan Carpenter
2017-11-13 18:33   ` Dan Carpenter
2017-11-14  9:33   ` Gilad Ben-Yossef
2017-11-14  9:33     ` Gilad Ben-Yossef
2017-11-14  9:48     ` Dan Carpenter
2017-11-14  9:48       ` Dan Carpenter
2017-11-15  6:35       ` Gilad Ben-Yossef

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1510584358-29473-18-git-send-email-gilad@benyossef.com \
    --to=gilad@benyossef.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ofir.drang@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.