Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: jonathan.derrick@intel.com (Jon Derrick)
Subject: [PATCHv2 5/5] block/sed: Eliminate state variable
Date: Fri, 17 Feb 2017 17:00:29 -0700	[thread overview]
Message-ID: <1487376029-22662-6-git-send-email-jonathan.derrick@intel.com> (raw)
In-Reply-To: <1487376029-22662-1-git-send-email-jonathan.derrick@intel.com>

Now that the function data is embedded with the function, there is no
need to carry a device state variable.

Signed-off-by: Jon Derrick <jonathan.derrick at intel.com>
---
 block/sed-opal.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/block/sed-opal.c b/block/sed-opal.c
index e2e3228..791a40a 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -85,7 +85,6 @@ struct opal_dev {
 	sec_send_recv *send_recv;
 
 	opal_step *funcs;
-	int state;
 	struct mutex dev_lock;
 	u16 comid;
 	u32 hsn;
@@ -377,17 +376,17 @@ static void check_geometry(struct opal_dev *dev, const void *data)
 static int next(struct opal_dev *dev)
 {
 	opal_step *func;
-	int error = 0;
+	int state = 0, error = 0;
 
 	do {
-		func = &dev->funcs[dev->state];
+		func = &dev->funcs[state];
 		if (!func->fn)
 			break;
 
 		error = func->fn(dev, func->data);
 		if (error) {
 			pr_err("Error on step function: %d with error %d: %s\n",
-			       dev->state, error,
+			       state, error,
 			       opal_error_to_human(error));
 
 			/* For each OPAL command we do a discovery0 then we
@@ -397,10 +396,10 @@ static int next(struct opal_dev *dev)
 			 * session. Therefore we shouldn't attempt to terminate
 			 * a session, as one has not yet been created.
 			 */
-			if (dev->state > 1)
+			if (state > 1)
 				return end_opal_session_error(dev);
 		}
-		dev->state++;
+		state++;
 	} while (!error);
 
 	return error;
@@ -1967,14 +1966,12 @@ static int end_opal_session_error(struct opal_dev *dev)
 		{ NULL, }
 	};
 	dev->funcs = error_end_session;
-	dev->state = 0;
 	return next(dev);
 }
 
 static inline void setup_opal_dev(struct opal_dev *dev,
 				  opal_step *funcs)
 {
-	dev->state = 0;
 	dev->funcs = funcs;
 	dev->tsn = 0;
 	dev->hsn = 0;
@@ -2320,7 +2317,6 @@ bool opal_unlock_from_suspend(struct opal_dev *dev)
 	setup_opal_dev(dev, NULL);
 
 	list_for_each_entry(suspend, &dev->unlk_lst, node) {
-		dev->state = 0;
 		dev->tsn = 0;
 		dev->hsn = 0;
 
-- 
1.8.3.1

  parent reply	other threads:[~2017-02-18  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-18  0:00 [PATCHv2 0/5] OPAL patche'd cont'd Jon Derrick
2017-02-18  0:00 ` [PATCHv2 1/5] block/sed: Use ssize_t on atom parsers to return errors Jon Derrick
2017-02-18  0:00 ` [PATCHv2 2/5] block/sed: Add helper to qualify response tokens Jon Derrick
2017-02-18  0:00 ` [PATCHv2 3/5] block/sed: Check received header lengths Jon Derrick
2017-02-18  0:00 ` [PATCHv2 4/5] block/sed: Embed function data into the function sequence Jon Derrick
2017-02-18  8:36   ` Christoph Hellwig
2017-02-18 15:52     ` Scott Bauer
2017-02-18 16:22       ` Christoph Hellwig
2017-02-18  0:00 ` Jon Derrick [this message]
2017-02-18  8:36   ` [PATCHv2 5/5] block/sed: Eliminate state variable Christoph Hellwig
2017-02-18  8:24 ` [PATCHv2 0/5] OPAL patche'd cont'd Christoph Hellwig

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=1487376029-22662-6-git-send-email-jonathan.derrick@intel.com \
    --to=jonathan.derrick@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox