* [PATCH 16/16] block: sed-opal: rename next to execute_steps
@ 2019-01-03 22:59 David Kozub
0 siblings, 0 replies; 2+ messages in thread
From: David Kozub @ 2019-01-03 22:59 UTC (permalink / raw)
To: Jens Axboe, Scott Bauer, Jonathan Derrick, linux-block, linux-kernel
Cc: Jonas Rabenstein
As the function is responsible for executing the individual steps supplied
in the steps argument, execute_steps is a more descriptive name than the
rather generic next.
Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz>
---
block/sed-opal.c | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/block/sed-opal.c b/block/sed-opal.c
index cedf4d12138d..f2bd16de8764 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -401,8 +401,8 @@ static int execute_step(struct opal_dev *dev,
return error;
}
-static int next(struct opal_dev *dev, const struct opal_step *steps,
- size_t n_steps)
+static int execute_steps(struct opal_dev *dev,
+ const struct opal_step *steps, size_t n_steps)
{
size_t state;
int error;
@@ -2032,7 +2032,7 @@ static int opal_secure_erase_locking_range(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, erase_steps, ARRAY_SIZE(erase_steps));
+ ret = execute_steps(dev, erase_steps, ARRAY_SIZE(erase_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2049,7 +2049,7 @@ static int opal_erase_locking_range(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, erase_steps, ARRAY_SIZE(erase_steps));
+ ret = execute_steps(dev, erase_steps, ARRAY_SIZE(erase_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2075,7 +2075,7 @@ static int opal_enable_disable_shadow_mbr(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, mbr_steps, ARRAY_SIZE(mbr_steps));
+ ret = execute_steps(dev, mbr_steps, ARRAY_SIZE(mbr_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2097,7 +2097,7 @@ static int opal_mbr_status(struct opal_dev *dev, struct opal_mbr_data *opal_mbr)
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, mbr_steps, ARRAY_SIZE(mbr_steps));
+ ret = execute_steps(dev, mbr_steps, ARRAY_SIZE(mbr_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2120,7 +2120,7 @@ static int opal_write_shadow_mbr(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, mbr_steps, ARRAY_SIZE(mbr_steps));
+ ret = execute_steps(dev, mbr_steps, ARRAY_SIZE(mbr_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2172,7 +2172,7 @@ static int opal_add_user_to_lr(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, steps, ARRAY_SIZE(steps));
+ ret = execute_steps(dev, steps, ARRAY_SIZE(steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2187,7 +2187,7 @@ static int opal_reverttper(struct opal_dev *dev, struct opal_key *opal)
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, revert_steps, ARRAY_SIZE(revert_steps));
+ ret = execute_steps(dev, revert_steps, ARRAY_SIZE(revert_steps));
mutex_unlock(&dev->dev_lock);
/*
@@ -2215,10 +2215,11 @@ static int __opal_lock_unlock(struct opal_dev *dev,
};
if (lk_unlk->session.sum)
- return next(dev, unlock_sum_steps,
- ARRAY_SIZE(unlock_sum_steps));
+ return execute_steps(dev, unlock_sum_steps,
+ ARRAY_SIZE(unlock_sum_steps));
else
- return next(dev, unlock_steps, ARRAY_SIZE(unlock_steps));
+ return execute_steps(dev, unlock_steps,
+ ARRAY_SIZE(unlock_steps));
}
static int __opal_set_mbr_done(struct opal_dev *dev, struct opal_key *key)
@@ -2230,7 +2231,7 @@ static int __opal_set_mbr_done(struct opal_dev *dev, struct opal_key *key)
{ end_opal_session, }
};
- return next(dev, mbrdone_step, ARRAY_SIZE(mbrdone_step));
+ return execute_steps(dev, mbrdone_step, ARRAY_SIZE(mbrdone_step));
}
static int opal_lock_unlock(struct opal_dev *dev,
@@ -2265,7 +2266,7 @@ static int opal_take_ownership(struct opal_dev *dev, struct opal_key *opal)
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, owner_steps, ARRAY_SIZE(owner_steps));
+ ret = execute_steps(dev, owner_steps, ARRAY_SIZE(owner_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2286,7 +2287,7 @@ static int opal_activate_lsp(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, active_steps, ARRAY_SIZE(active_steps));
+ ret = execute_steps(dev, active_steps, ARRAY_SIZE(active_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2303,7 +2304,7 @@ static int opal_setup_locking_range(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, lr_steps, ARRAY_SIZE(lr_steps));
+ ret = execute_steps(dev, lr_steps, ARRAY_SIZE(lr_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2325,7 +2326,7 @@ static int opal_set_new_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw)
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, pw_steps, ARRAY_SIZE(pw_steps));
+ ret = execute_steps(dev, pw_steps, ARRAY_SIZE(pw_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2349,7 +2350,7 @@ static int opal_activate_user(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, act_steps, ARRAY_SIZE(act_steps));
+ ret = execute_steps(dev, act_steps, ARRAY_SIZE(act_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 00/16] sed-opal: fix shadow MBR enable/disable and clean up code
@ 2019-02-14 0:15 David Kozub
2019-02-14 0:16 ` [PATCH 16/16] block: sed-opal: rename next to execute_steps David Kozub
0 siblings, 1 reply; 2+ messages in thread
From: David Kozub @ 2019-02-14 0:15 UTC (permalink / raw)
To: Jens Axboe, Jonathan Derrick, Scott Bauer, linux-block, linux-kernel
Cc: Jonas Rabenstein, David Kozub
This patch series contains various code cleanup and fixes for Opal SED support.
It's been created by taking a part of the original patch series by Jonas and me
(PATCHv4 block: sed-opal: support shadow MBR done flag and write) [1], as
suggested by Christoph in [2].
The most important patch is the first one where I tried to fix the shadow MBR
enable/disable issue we discussed in [3]. This change goes against Christoph's
original propsal in [4] but I think - in light of the issue and keeping in mind
the planned addition of an IOCTL specifically for toggling the done flag - that
passing just OPAL_TRUE or OPAL_FALSE to set_mbr_done and set_mbr_enable_disable
is more useful and also more understandable. Maybe this change is superfluous if
Scott found the time to submit his take on the fix. (?)
I tried to include all the feedback from the v4 review[1]. I also added some
more trivial changes (11/16 as suggested in [4]) and also 13/16 motivated by the
same idea - that's why I again reached the magical number of 16 patches.
I kept the reviewed-by/acked-by tags where the changes were trivial but I
removed them where I thought a re-review would be useful.
I plan to submit the remaining patches from the original series (these that add
new Opal IOCTLs) after this fix and cleanup is accepted.
I did a brief test toggling shadow MBR and unlocking a locking range. I will try
to do more thorough tests - but I will not get to it before the beginning of the
next week. It would be great if this could get some more testing. Especially the
unlock from suspend part - that's something I don't have set up and I have not
tested.
The series applies on v5.0-rc6.
[1] https://lore.kernel.org/lkml/1549054223-12220-1-git-send-email-zub@linux.fjfi.cvut.cz/
[2] https://lore.kernel.org/lkml/20190204150415.GO31132@infradead.org/
[3] https://lore.kernel.org/lkml/alpine.LRH.2.21.1902072247060.29258@linux.fjfi.cvut.cz/
[4] https://lore.kernel.org/lkml/20190204145244.GJ31132@infradead.org/
David Kozub (12):
block: sed-opal: fix IOC_OPAL_ENABLE_DISABLE_MBR
block: sed-opal: fix typos and formatting
block: sed-opal: close parameter list in cmd_finalize
block: sed-opal: unify cmd start
block: sed-opal: unify error handling of responses
block: sed-opal: reuse response_get_token to decrease code duplication
block: sed-opal: add token for OPAL_LIFECYCLE
block: sed-opal: unify retrieval of table columns
block: sed-opal: use named Opal tokens instead of integer literals
block: sed-opal: pass steps via argument rather than via opal_dev
block: sed-opal: don't repeat opal_discovery0 in each steps array
block: sed-opal: rename next to execute_steps
Jonas Rabenstein (4):
block: sed-opal: use correct macro for method length
block: sed-opal: unify space check in add_token_*
block: sed-opal: print failed function address
block: sed-opal: split generation of bytestring header and content
block/opal_proto.h | 2 +
block/sed-opal.c | 716 ++++++++++++++--------------------
include/uapi/linux/sed-opal.h | 2 +-
3 files changed, 287 insertions(+), 433 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 16/16] block: sed-opal: rename next to execute_steps
2019-02-14 0:15 [PATCH 00/16] sed-opal: fix shadow MBR enable/disable and clean up code David Kozub
@ 2019-02-14 0:16 ` David Kozub
0 siblings, 0 replies; 2+ messages in thread
From: David Kozub @ 2019-02-14 0:16 UTC (permalink / raw)
To: Jens Axboe, Jonathan Derrick, Scott Bauer, linux-block, linux-kernel
Cc: Jonas Rabenstein, David Kozub
As the function is responsible for executing the individual steps supplied
in the steps argument, execute_steps is a more descriptive name than the
rather generic next.
Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz>
Reviewed-by: Scott Bauer <sbauer@plzdonthack.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jon Derrick <jonathan.derrick@intel.com>
---
block/sed-opal.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/block/sed-opal.c b/block/sed-opal.c
index b947efd6d4d9..b1aa0cc25803 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -396,8 +396,8 @@ static int execute_step(struct opal_dev *dev,
return error;
}
-static int next(struct opal_dev *dev, const struct opal_step *steps,
- size_t n_steps)
+static int execute_steps(struct opal_dev *dev,
+ const struct opal_step *steps, size_t n_steps)
{
size_t state = 0;
int error;
@@ -1937,7 +1937,7 @@ static int opal_secure_erase_locking_range(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, erase_steps, ARRAY_SIZE(erase_steps));
+ ret = execute_steps(dev, erase_steps, ARRAY_SIZE(erase_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -1954,7 +1954,7 @@ static int opal_erase_locking_range(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, erase_steps, ARRAY_SIZE(erase_steps));
+ ret = execute_steps(dev, erase_steps, ARRAY_SIZE(erase_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -1981,7 +1981,7 @@ static int opal_enable_disable_shadow_mbr(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, mbr_steps, ARRAY_SIZE(mbr_steps));
+ ret = execute_steps(dev, mbr_steps, ARRAY_SIZE(mbr_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2033,7 +2033,7 @@ static int opal_add_user_to_lr(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, steps, ARRAY_SIZE(steps));
+ ret = execute_steps(dev, steps, ARRAY_SIZE(steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2048,7 +2048,7 @@ static int opal_reverttper(struct opal_dev *dev, struct opal_key *opal)
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, revert_steps, ARRAY_SIZE(revert_steps));
+ ret = execute_steps(dev, revert_steps, ARRAY_SIZE(revert_steps));
mutex_unlock(&dev->dev_lock);
/*
@@ -2076,10 +2076,11 @@ static int __opal_lock_unlock(struct opal_dev *dev,
};
if (lk_unlk->session.sum)
- return next(dev, unlock_sum_steps,
- ARRAY_SIZE(unlock_sum_steps));
+ return execute_steps(dev, unlock_sum_steps,
+ ARRAY_SIZE(unlock_sum_steps));
else
- return next(dev, unlock_steps, ARRAY_SIZE(unlock_steps));
+ return execute_steps(dev, unlock_steps,
+ ARRAY_SIZE(unlock_steps));
}
static int __opal_set_mbr_done(struct opal_dev *dev, struct opal_key *key)
@@ -2091,7 +2092,7 @@ static int __opal_set_mbr_done(struct opal_dev *dev, struct opal_key *key)
{ end_opal_session, }
};
- return next(dev, mbrdone_step, ARRAY_SIZE(mbrdone_step));
+ return execute_steps(dev, mbrdone_step, ARRAY_SIZE(mbrdone_step));
}
static int opal_lock_unlock(struct opal_dev *dev,
@@ -2126,7 +2127,7 @@ static int opal_take_ownership(struct opal_dev *dev, struct opal_key *opal)
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, owner_steps, ARRAY_SIZE(owner_steps));
+ ret = execute_steps(dev, owner_steps, ARRAY_SIZE(owner_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2147,7 +2148,7 @@ static int opal_activate_lsp(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, active_steps, ARRAY_SIZE(active_steps));
+ ret = execute_steps(dev, active_steps, ARRAY_SIZE(active_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2164,7 +2165,7 @@ static int opal_setup_locking_range(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, lr_steps, ARRAY_SIZE(lr_steps));
+ ret = execute_steps(dev, lr_steps, ARRAY_SIZE(lr_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2186,7 +2187,7 @@ static int opal_set_new_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw)
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, pw_steps, ARRAY_SIZE(pw_steps));
+ ret = execute_steps(dev, pw_steps, ARRAY_SIZE(pw_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
@@ -2210,7 +2211,7 @@ static int opal_activate_user(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev);
- ret = next(dev, act_steps, ARRAY_SIZE(act_steps));
+ ret = execute_steps(dev, act_steps, ARRAY_SIZE(act_steps));
mutex_unlock(&dev->dev_lock);
return ret;
}
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-15 16:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-03 22:59 [PATCH 16/16] block: sed-opal: rename next to execute_steps David Kozub
2019-02-14 0:15 [PATCH 00/16] sed-opal: fix shadow MBR enable/disable and clean up code David Kozub
2019-02-14 0:16 ` [PATCH 16/16] block: sed-opal: rename next to execute_steps David Kozub
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®