Skip to content

Commit 78d584c

Browse files
David Kozubnonapode
authored andcommitted
block: sed-opal: close parameter list in cmd_finalize
Every step ends by calling cmd_finalize (via finalize_and_send) yet every step adds the token OPAL_ENDLIST on its own. Moving this into cmd_finalize decreases code duplication. Co-authored-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de> Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz> Signed-off-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de> Reviewed-by: Scott Bauer <sbauer@plzdonthack.me> Reviewed-by: Christoph Hellwig <hch@lst.de> Acked-by: Jon Derrick <jonathan.derrick@intel.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e2821a5 commit 78d584c

1 file changed

Lines changed: 3 additions & 22 deletions

File tree

‎block/sed-opal.c‎

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,9 @@ static int cmd_finalize(struct opal_dev *cmd, u32 hsn, u32 tsn)
655655
struct opal_header *hdr;
656656
int err = 0;
657657

658+
/* close parameter list */
659+
add_token_u8(&err, cmd, OPAL_ENDLIST);
660+
658661
add_token_u8(&err, cmd, OPAL_ENDOFDATA);
659662
add_token_u8(&err, cmd, OPAL_STARTLIST);
660663
add_token_u8(&err, cmd, 0);
@@ -1073,7 +1076,6 @@ static int gen_key(struct opal_dev *dev, void *data)
10731076
add_token_bytestring(&err, dev, opalmethod[OPAL_GENKEY],
10741077
OPAL_UID_LENGTH);
10751078
add_token_u8(&err, dev, OPAL_STARTLIST);
1076-
add_token_u8(&err, dev, OPAL_ENDLIST);
10771079

10781080
if (err) {
10791081
pr_debug("Error building gen key command\n");
@@ -1136,7 +1138,6 @@ static int get_active_key(struct opal_dev *dev, void *data)
11361138
add_token_u8(&err, dev, 10); /* ActiveKey */
11371139
add_token_u8(&err, dev, OPAL_ENDNAME);
11381140
add_token_u8(&err, dev, OPAL_ENDLIST);
1139-
add_token_u8(&err, dev, OPAL_ENDLIST);
11401141
if (err) {
11411142
pr_debug("Error building get active key command\n");
11421143
return err;
@@ -1182,7 +1183,6 @@ static int generic_lr_enable_disable(struct opal_dev *dev,
11821183

11831184
add_token_u8(&err, dev, OPAL_ENDLIST);
11841185
add_token_u8(&err, dev, OPAL_ENDNAME);
1185-
add_token_u8(&err, dev, OPAL_ENDLIST);
11861186
return err;
11871187
}
11881188

@@ -1248,8 +1248,6 @@ static int setup_locking_range(struct opal_dev *dev, void *data)
12481248

12491249
add_token_u8(&err, dev, OPAL_ENDLIST);
12501250
add_token_u8(&err, dev, OPAL_ENDNAME);
1251-
add_token_u8(&err, dev, OPAL_ENDLIST);
1252-
12531251
}
12541252
if (err) {
12551253
pr_debug("Error building Setup Locking range command.\n");
@@ -1289,7 +1287,6 @@ static int start_generic_opal_session(struct opal_dev *dev,
12891287

12901288
switch (auth) {
12911289
case OPAL_ANYBODY_UID:
1292-
add_token_u8(&err, dev, OPAL_ENDLIST);
12931290
break;
12941291
case OPAL_ADMIN1_UID:
12951292
case OPAL_SID_UID:
@@ -1302,7 +1299,6 @@ static int start_generic_opal_session(struct opal_dev *dev,
13021299
add_token_bytestring(&err, dev, opaluid[auth],
13031300
OPAL_UID_LENGTH);
13041301
add_token_u8(&err, dev, OPAL_ENDNAME);
1305-
add_token_u8(&err, dev, OPAL_ENDLIST);
13061302
break;
13071303
default:
13081304
pr_debug("Cannot start Admin SP session with auth %d\n", auth);
@@ -1400,7 +1396,6 @@ static int start_auth_opal_session(struct opal_dev *dev, void *data)
14001396
add_token_u8(&err, dev, 3);
14011397
add_token_bytestring(&err, dev, lk_ul_user, OPAL_UID_LENGTH);
14021398
add_token_u8(&err, dev, OPAL_ENDNAME);
1403-
add_token_u8(&err, dev, OPAL_ENDLIST);
14041399

14051400
if (err) {
14061401
pr_debug("Error building STARTSESSION command.\n");
@@ -1423,7 +1418,6 @@ static int revert_tper(struct opal_dev *dev, void *data)
14231418
add_token_bytestring(&err, dev, opalmethod[OPAL_REVERT],
14241419
OPAL_UID_LENGTH);
14251420
add_token_u8(&err, dev, OPAL_STARTLIST);
1426-
add_token_u8(&err, dev, OPAL_ENDLIST);
14271421
if (err) {
14281422
pr_debug("Error building REVERT TPER command.\n");
14291423
return err;
@@ -1457,7 +1451,6 @@ static int internal_activate_user(struct opal_dev *dev, void *data)
14571451
add_token_u8(&err, dev, OPAL_ENDNAME);
14581452
add_token_u8(&err, dev, OPAL_ENDLIST);
14591453
add_token_u8(&err, dev, OPAL_ENDNAME);
1460-
add_token_u8(&err, dev, OPAL_ENDLIST);
14611454

14621455
if (err) {
14631456
pr_debug("Error building Activate UserN command.\n");
@@ -1484,7 +1477,6 @@ static int erase_locking_range(struct opal_dev *dev, void *data)
14841477
add_token_bytestring(&err, dev, opalmethod[OPAL_ERASE],
14851478
OPAL_UID_LENGTH);
14861479
add_token_u8(&err, dev, OPAL_STARTLIST);
1487-
add_token_u8(&err, dev, OPAL_ENDLIST);
14881480

14891481
if (err) {
14901482
pr_debug("Error building Erase Locking Range Command.\n");
@@ -1515,7 +1507,6 @@ static int set_mbr_done(struct opal_dev *dev, void *data)
15151507
add_token_u8(&err, dev, OPAL_ENDNAME);
15161508
add_token_u8(&err, dev, OPAL_ENDLIST);
15171509
add_token_u8(&err, dev, OPAL_ENDNAME);
1518-
add_token_u8(&err, dev, OPAL_ENDLIST);
15191510

15201511
if (err) {
15211512
pr_debug("Error Building set MBR Done command\n");
@@ -1547,7 +1538,6 @@ static int set_mbr_enable_disable(struct opal_dev *dev, void *data)
15471538
add_token_u8(&err, dev, OPAL_ENDNAME);
15481539
add_token_u8(&err, dev, OPAL_ENDLIST);
15491540
add_token_u8(&err, dev, OPAL_ENDNAME);
1550-
add_token_u8(&err, dev, OPAL_ENDLIST);
15511541

15521542
if (err) {
15531543
pr_debug("Error Building set MBR done command\n");
@@ -1579,7 +1569,6 @@ static int generic_pw_cmd(u8 *key, size_t key_len, u8 *cpin_uid,
15791569
add_token_u8(&err, dev, OPAL_ENDNAME);
15801570
add_token_u8(&err, dev, OPAL_ENDLIST);
15811571
add_token_u8(&err, dev, OPAL_ENDNAME);
1582-
add_token_u8(&err, dev, OPAL_ENDLIST);
15831572

15841573
return err;
15851574
}
@@ -1688,7 +1677,6 @@ static int add_user_to_lr(struct opal_dev *dev, void *data)
16881677
add_token_u8(&err, dev, OPAL_ENDNAME);
16891678
add_token_u8(&err, dev, OPAL_ENDLIST);
16901679
add_token_u8(&err, dev, OPAL_ENDNAME);
1691-
add_token_u8(&err, dev, OPAL_ENDLIST);
16921680

16931681
if (err) {
16941682
pr_debug("Error building add user to locking range command.\n");
@@ -1749,7 +1737,6 @@ static int lock_unlock_locking_range(struct opal_dev *dev, void *data)
17491737

17501738
add_token_u8(&err, dev, OPAL_ENDLIST);
17511739
add_token_u8(&err, dev, OPAL_ENDNAME);
1752-
add_token_u8(&err, dev, OPAL_ENDLIST);
17531740

17541741
if (err) {
17551742
pr_debug("Error building SET command.\n");
@@ -1837,11 +1824,8 @@ static int activate_lsp(struct opal_dev *dev, void *data)
18371824
}
18381825
add_token_u8(&err, dev, OPAL_ENDLIST);
18391826
add_token_u8(&err, dev, OPAL_ENDNAME);
1840-
add_token_u8(&err, dev, OPAL_ENDLIST);
1841-
18421827
} else {
18431828
add_token_u8(&err, dev, OPAL_STARTLIST);
1844-
add_token_u8(&err, dev, OPAL_ENDLIST);
18451829
}
18461830

18471831
if (err) {
@@ -1898,7 +1882,6 @@ static int get_lsp_lifecycle(struct opal_dev *dev, void *data)
18981882
add_token_u8(&err, dev, 6); /* Lifecycle Column */
18991883
add_token_u8(&err, dev, OPAL_ENDNAME);
19001884

1901-
add_token_u8(&err, dev, OPAL_ENDLIST);
19021885
add_token_u8(&err, dev, OPAL_ENDLIST);
19031886

19041887
if (err) {
@@ -1958,8 +1941,6 @@ static int get_msid_cpin_pin(struct opal_dev *dev, void *data)
19581941
add_token_u8(&err, dev, 4); /* End Column */
19591942
add_token_u8(&err, dev, 3); /* Lifecycle Column */
19601943
add_token_u8(&err, dev, OPAL_ENDNAME);
1961-
1962-
add_token_u8(&err, dev, OPAL_ENDLIST);
19631944
add_token_u8(&err, dev, OPAL_ENDLIST);
19641945

19651946
if (err) {

0 commit comments

Comments
 (0)