nvme/opal: merge two revert tper command function into one

Also rename it with *build* which is more meaningful.

Change-Id: I6e81e1b641ffdd04a7420e93e67448dc430f5168
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1668
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Changpeng Liu 2020-04-03 23:25:31 +08:00 committed by Tomasz Zawadzki
parent 4f7f0f0986
commit 2728b774aa

View File

@ -1818,7 +1818,7 @@ struct spdk_opal_dev *
}
static int
opal_revert_tper(struct spdk_opal_dev *dev, struct opal_session *sess)
opal_build_revert_tper_cmd(struct spdk_opal_dev *dev, struct opal_session *sess)
{
int err = 0;
@ -1834,9 +1834,10 @@ opal_revert_tper(struct spdk_opal_dev *dev, struct opal_session *sess)
opal_add_token_u8(&err, sess, SPDK_OPAL_ENDLIST);
if (err) {
SPDK_ERRLOG("Error building REVERT TPER command.\n");
return -ERANGE;
}
return err;
return opal_cmd_finalize(sess, sess->hsn, sess->tsn, true);
}
static int
@ -2028,15 +2029,10 @@ spdk_opal_cmd_revert_tper(struct spdk_opal_dev *dev, const char *passwd)
return ret;
}
ret = opal_revert_tper(dev, sess);
ret = opal_build_revert_tper_cmd(dev, sess);
if (ret) {
opal_end_session(dev, sess, dev->comid);
SPDK_ERRLOG("Error on reverting TPer with error %d\n", ret);
goto end;
}
ret = opal_cmd_finalize(sess, sess->hsn, sess->tsn, true);
if (ret) {
SPDK_ERRLOG("Build revert tper command with error %d\n", ret);
goto end;
}