* [PATCH 0/3] block: sed-opal: Code Cleanup Patches @ 2019-08-13 21:43 Revanth Rajashekar 2019-08-13 21:43 ` [PATCH 1/3] block: sed-opal: Add/remove spaces Revanth Rajashekar ` (3 more replies) 0 siblings, 4 replies; 12+ messages in thread From: Revanth Rajashekar @ 2019-08-13 21:43 UTC (permalink / raw) To: linux-block; +Cc: Jonathan Derrick, Scott Bauer This series of patch is a cleanup for sed-opal in kernel 5.4. It 1. Adds/removes spaces. 2. Eliminates dead error condition. 3. Eliminates definition defined twice. These cleanup patches are submitted with the intend to submit a new feature after this. Revanth Rajashekar (3): block: sed-opal: Add/remove spaces block: sed-opal: Eliminating the dead error block: sed-opal: OPAL_METHOD_LENGTH defined twice block/opal_proto.h | 5 +---- block/sed-opal.c | 49 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 12 deletions(-) -- 2.17.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] block: sed-opal: Add/remove spaces 2019-08-13 21:43 [PATCH 0/3] block: sed-opal: Code Cleanup Patches Revanth Rajashekar @ 2019-08-13 21:43 ` Revanth Rajashekar 2019-08-14 20:26 ` Derrick, Jonathan 2019-08-15 4:01 ` Scott Bauer 2019-08-13 21:43 ` [PATCH 2/3] block: sed-opal: Eliminating the dead error Revanth Rajashekar ` (2 subsequent siblings) 3 siblings, 2 replies; 12+ messages in thread From: Revanth Rajashekar @ 2019-08-13 21:43 UTC (permalink / raw) To: linux-block; +Cc: Jonathan Derrick, Scott Bauer, Revanth Rajashekar Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com> --- block/opal_proto.h | 3 +-- block/sed-opal.c | 45 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/block/opal_proto.h b/block/opal_proto.h index 466ec7be16ef..562b78f40824 100644 --- a/block/opal_proto.h +++ b/block/opal_proto.h @@ -167,7 +167,6 @@ enum opal_token { OPAL_TABLE_LASTID = 0x0A, OPAL_TABLE_MIN = 0x0B, OPAL_TABLE_MAX = 0x0C, - /* authority table */ OPAL_PIN = 0x03, /* locking tokens */ @@ -182,7 +181,7 @@ enum opal_token { OPAL_LIFECYCLE = 0x06, /* locking info table */ OPAL_MAXRANGES = 0x04, - /* mbr control */ + /* mbr control */ OPAL_MBRENABLE = 0x01, OPAL_MBRDONE = 0x02, /* properties */ diff --git a/block/sed-opal.c b/block/sed-opal.c index 7e1a444a25b2..d442f29e84f1 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -129,7 +129,6 @@ static const u8 opaluid[][OPAL_UID_LENGTH] = { { 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x84, 0x01 }, /* tables */ - [OPAL_TABLE_TABLE] { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01 }, [OPAL_LOCKINGRANGE_GLOBAL] = @@ -152,7 +151,6 @@ static const u8 opaluid[][OPAL_UID_LENGTH] = { { 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00 }, /* C_PIN_TABLE object ID's */ - [OPAL_C_PIN_MSID] = { 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x84, 0x02}, [OPAL_C_PIN_SID] = @@ -161,7 +159,6 @@ static const u8 opaluid[][OPAL_UID_LENGTH] = { { 0x00, 0x00, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x01}, /* half UID's (only first 4 bytes used) */ - [OPAL_HALF_UID_AUTHORITY_OBJ_REF] = { 0x00, 0x00, 0x0C, 0x05, 0xff, 0xff, 0xff, 0xff }, [OPAL_HALF_UID_BOOLEAN_ACE] = @@ -517,6 +514,7 @@ static int opal_discovery0(struct opal_dev *dev, void *data) ret = opal_recv_cmd(dev); if (ret) return ret; + return opal_discovery0_end(dev); } @@ -525,6 +523,7 @@ static int opal_discovery0_step(struct opal_dev *dev) const struct opal_step discovery0_step = { opal_discovery0, }; + return execute_step(dev, &discovery0_step, 0); } @@ -551,6 +550,7 @@ static void add_token_u8(int *err, struct opal_dev *cmd, u8 tok) { if (!can_add(err, cmd, 1)) return; + cmd->cmd[cmd->pos++] = tok; } @@ -577,6 +577,7 @@ static void add_medium_atom_header(struct opal_dev *cmd, bool bytestring, header0 |= bytestring ? MEDIUM_ATOM_BYTESTRING : 0; header0 |= has_sign ? MEDIUM_ATOM_SIGNED : 0; header0 |= (len >> 8) & MEDIUM_ATOM_LEN_MASK; + cmd->cmd[cmd->pos++] = header0; cmd->cmd[cmd->pos++] = len; } @@ -649,6 +650,7 @@ static int build_locking_range(u8 *buffer, size_t length, u8 lr) if (lr == 0) return 0; + buffer[5] = LOCKING_RANGE_NON_GLOBAL; buffer[7] = lr; @@ -945,6 +947,7 @@ static size_t response_get_string(const struct parsed_resp *resp, int n, } *store = tok->pos + skip; + return tok->len - skip; } @@ -1062,6 +1065,7 @@ static int start_opal_session_cont(struct opal_dev *dev) dev->hsn = hsn; dev->tsn = tsn; + return 0; } @@ -1084,6 +1088,7 @@ static int end_session_cont(struct opal_dev *dev) { dev->hsn = 0; dev->tsn = 0; + return parse_and_check_status(dev); } @@ -1172,6 +1177,7 @@ static int gen_key(struct opal_dev *dev, void *data) return err; } + return finalize_and_send(dev, parse_and_check_status); } @@ -1184,12 +1190,14 @@ static int get_active_key_cont(struct opal_dev *dev) error = parse_and_check_status(dev); if (error) return error; + keylen = response_get_string(&dev->parsed, 4, &activekey); if (!activekey) { pr_debug("%s: Couldn't extract the Activekey from the response\n", __func__); return OPAL_INVAL_PARAM; } + dev->prev_data = kmemdup(activekey, keylen, GFP_KERNEL); if (!dev->prev_data) @@ -1251,6 +1259,7 @@ static int generic_lr_enable_disable(struct opal_dev *dev, add_token_u8(&err, dev, OPAL_ENDLIST); add_token_u8(&err, dev, OPAL_ENDNAME); + return err; } @@ -1263,6 +1272,7 @@ static inline int enable_global_lr(struct opal_dev *dev, u8 *uid, 0, 0); if (err) pr_debug("Failed to create enable global lr command\n"); + return err; } @@ -1313,7 +1323,6 @@ static int setup_locking_range(struct opal_dev *dev, void *data) if (err) { pr_debug("Error building Setup Locking range command.\n"); return err; - } return finalize_and_send(dev, parse_and_check_status); @@ -1393,6 +1402,7 @@ static int start_SIDASP_opal_session(struct opal_dev *dev, void *data) kfree(key); dev->prev_data = NULL; } + return ret; } @@ -1518,6 +1528,7 @@ static int erase_locking_range(struct opal_dev *dev, void *data) pr_debug("Error building Erase Locking Range Command.\n"); return err; } + return finalize_and_send(dev, parse_and_check_status); } @@ -1636,6 +1647,7 @@ static int write_shadow_mbr(struct opal_dev *dev, void *data) off += len; } + return err; } @@ -1816,6 +1828,7 @@ static int lock_unlock_locking_range(struct opal_dev *dev, void *data) pr_debug("Error building SET command.\n"); return err; } + return finalize_and_send(dev, parse_and_check_status); } @@ -1857,6 +1870,7 @@ static int lock_unlock_locking_range_sum(struct opal_dev *dev, void *data) pr_debug("Error building SET command.\n"); return ret; } + return finalize_and_send(dev, parse_and_check_status); } @@ -1957,6 +1971,7 @@ static int end_opal_session(struct opal_dev *dev, void *data) if (err < 0) return err; + return finalize_and_send(dev, end_session_cont); } @@ -1965,6 +1980,7 @@ static int end_opal_session_error(struct opal_dev *dev) const struct opal_step error_end_session = { end_opal_session, }; + return execute_step(dev, &error_end_session, 0); } @@ -1984,6 +2000,7 @@ static int check_opal_support(struct opal_dev *dev) ret = opal_discovery0_step(dev); dev->supported = !ret; mutex_unlock(&dev->dev_lock); + return ret; } @@ -2004,6 +2021,7 @@ void free_opal_dev(struct opal_dev *dev) { if (!dev) return; + clean_opal_dev(dev); kfree(dev); } @@ -2026,6 +2044,7 @@ struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv) kfree(dev); return NULL; } + return dev; } EXPORT_SYMBOL(init_opal_dev); @@ -2045,6 +2064,7 @@ static int opal_secure_erase_locking_range(struct opal_dev *dev, setup_opal_dev(dev); ret = execute_steps(dev, erase_steps, ARRAY_SIZE(erase_steps)); mutex_unlock(&dev->dev_lock); + return ret; } @@ -2062,6 +2082,7 @@ static int opal_erase_locking_range(struct opal_dev *dev, setup_opal_dev(dev); ret = execute_steps(dev, erase_steps, ARRAY_SIZE(erase_steps)); mutex_unlock(&dev->dev_lock); + return ret; } @@ -2089,6 +2110,7 @@ static int opal_enable_disable_shadow_mbr(struct opal_dev *dev, setup_opal_dev(dev); ret = execute_steps(dev, mbr_steps, ARRAY_SIZE(mbr_steps)); mutex_unlock(&dev->dev_lock); + return ret; } @@ -2113,6 +2135,7 @@ static int opal_set_mbr_done(struct opal_dev *dev, setup_opal_dev(dev); ret = execute_steps(dev, mbr_steps, ARRAY_SIZE(mbr_steps)); mutex_unlock(&dev->dev_lock); + return ret; } @@ -2133,6 +2156,7 @@ static int opal_write_shadow_mbr(struct opal_dev *dev, setup_opal_dev(dev); ret = execute_steps(dev, mbr_steps, ARRAY_SIZE(mbr_steps)); mutex_unlock(&dev->dev_lock); + return ret; } @@ -2151,6 +2175,7 @@ static int opal_save(struct opal_dev *dev, struct opal_lock_unlock *lk_unlk) setup_opal_dev(dev); add_suspend_info(dev, suspend); mutex_unlock(&dev->dev_lock); + return 0; } @@ -2169,12 +2194,14 @@ static int opal_add_user_to_lr(struct opal_dev *dev, pr_debug("Locking state was not RO or RW\n"); return -EINVAL; } + if (lk_unlk->session.who < OPAL_USER1 || lk_unlk->session.who > OPAL_USER9) { pr_debug("Authority was not within the range of users: %d\n", lk_unlk->session.who); return -EINVAL; } + if (lk_unlk->session.sum) { pr_debug("%s not supported in sum. Use setup locking range\n", __func__); @@ -2185,6 +2212,7 @@ static int opal_add_user_to_lr(struct opal_dev *dev, setup_opal_dev(dev); ret = execute_steps(dev, steps, ARRAY_SIZE(steps)); mutex_unlock(&dev->dev_lock); + return ret; } @@ -2267,6 +2295,7 @@ static int opal_lock_unlock(struct opal_dev *dev, mutex_lock(&dev->dev_lock); ret = __opal_lock_unlock(dev, lk_unlk); mutex_unlock(&dev->dev_lock); + return ret; } @@ -2289,6 +2318,7 @@ static int opal_take_ownership(struct opal_dev *dev, struct opal_key *opal) setup_opal_dev(dev); ret = execute_steps(dev, owner_steps, ARRAY_SIZE(owner_steps)); mutex_unlock(&dev->dev_lock); + return ret; } @@ -2310,6 +2340,7 @@ static int opal_activate_lsp(struct opal_dev *dev, setup_opal_dev(dev); ret = execute_steps(dev, active_steps, ARRAY_SIZE(active_steps)); mutex_unlock(&dev->dev_lock); + return ret; } @@ -2327,6 +2358,7 @@ static int opal_setup_locking_range(struct opal_dev *dev, setup_opal_dev(dev); ret = execute_steps(dev, lr_steps, ARRAY_SIZE(lr_steps)); mutex_unlock(&dev->dev_lock); + return ret; } @@ -2347,6 +2379,7 @@ static int opal_set_new_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw) setup_opal_dev(dev); ret = execute_steps(dev, pw_steps, ARRAY_SIZE(pw_steps)); mutex_unlock(&dev->dev_lock); + return ret; } @@ -2371,6 +2404,7 @@ static int opal_activate_user(struct opal_dev *dev, setup_opal_dev(dev); ret = execute_steps(dev, act_steps, ARRAY_SIZE(act_steps)); mutex_unlock(&dev->dev_lock); + return ret; } @@ -2382,6 +2416,7 @@ bool opal_unlock_from_suspend(struct opal_dev *dev) if (!dev) return false; + if (!dev->supported) return false; @@ -2399,6 +2434,7 @@ bool opal_unlock_from_suspend(struct opal_dev *dev) suspend->unlk.session.sum); was_failure = true; } + if (dev->mbr_enabled) { ret = __opal_set_mbr_done(dev, &suspend->unlk.session.opal_key); if (ret) @@ -2406,6 +2442,7 @@ bool opal_unlock_from_suspend(struct opal_dev *dev) } } mutex_unlock(&dev->dev_lock); + return was_failure; } EXPORT_SYMBOL(opal_unlock_from_suspend); -- 2.17.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] block: sed-opal: Add/remove spaces 2019-08-13 21:43 ` [PATCH 1/3] block: sed-opal: Add/remove spaces Revanth Rajashekar @ 2019-08-14 20:26 ` Derrick, Jonathan 2019-08-15 4:01 ` Scott Bauer 1 sibling, 0 replies; 12+ messages in thread From: Derrick, Jonathan @ 2019-08-14 20:26 UTC (permalink / raw) To: Rajashekar, Revanth, linux-block; +Cc: hch, sbauer, axboe [-- Attachment #1: Type: text/plain, Size: 11389 bytes --] lgtm Reviewed-by: Jon Derrick <jonathan.derrick@intel.com> On Tue, 2019-08-13 at 15:43 -0600, Rajashekar, Revanth wrote: > Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com> > --- > block/opal_proto.h | 3 +-- > block/sed-opal.c | 45 +++++++++++++++++++++++++++++++++++++++++---- > 2 files changed, 42 insertions(+), 6 deletions(-) > > diff --git a/block/opal_proto.h b/block/opal_proto.h > index 466ec7be16ef..562b78f40824 100644 > --- a/block/opal_proto.h > +++ b/block/opal_proto.h > @@ -167,7 +167,6 @@ enum opal_token { > OPAL_TABLE_LASTID = 0x0A, > OPAL_TABLE_MIN = 0x0B, > OPAL_TABLE_MAX = 0x0C, > - > /* authority table */ > OPAL_PIN = 0x03, > /* locking tokens */ > @@ -182,7 +181,7 @@ enum opal_token { > OPAL_LIFECYCLE = 0x06, > /* locking info table */ > OPAL_MAXRANGES = 0x04, > - /* mbr control */ > + /* mbr control */ > OPAL_MBRENABLE = 0x01, > OPAL_MBRDONE = 0x02, > /* properties */ > diff --git a/block/sed-opal.c b/block/sed-opal.c > index 7e1a444a25b2..d442f29e84f1 100644 > --- a/block/sed-opal.c > +++ b/block/sed-opal.c > @@ -129,7 +129,6 @@ static const u8 opaluid[][OPAL_UID_LENGTH] = { > { 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x84, 0x01 }, > > /* tables */ > - > [OPAL_TABLE_TABLE] > { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01 }, > [OPAL_LOCKINGRANGE_GLOBAL] = > @@ -152,7 +151,6 @@ static const u8 opaluid[][OPAL_UID_LENGTH] = { > { 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00 }, > > /* C_PIN_TABLE object ID's */ > - > [OPAL_C_PIN_MSID] = > { 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x84, 0x02}, > [OPAL_C_PIN_SID] = > @@ -161,7 +159,6 @@ static const u8 opaluid[][OPAL_UID_LENGTH] = { > { 0x00, 0x00, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x01}, > > /* half UID's (only first 4 bytes used) */ > - > [OPAL_HALF_UID_AUTHORITY_OBJ_REF] = > { 0x00, 0x00, 0x0C, 0x05, 0xff, 0xff, 0xff, 0xff }, > [OPAL_HALF_UID_BOOLEAN_ACE] = > @@ -517,6 +514,7 @@ static int opal_discovery0(struct opal_dev *dev, void *data) > ret = opal_recv_cmd(dev); > if (ret) > return ret; > + > return opal_discovery0_end(dev); > } > > @@ -525,6 +523,7 @@ static int opal_discovery0_step(struct opal_dev *dev) > const struct opal_step discovery0_step = { > opal_discovery0, > }; > + > return execute_step(dev, &discovery0_step, 0); > } > > @@ -551,6 +550,7 @@ static void add_token_u8(int *err, struct opal_dev *cmd, u8 tok) > { > if (!can_add(err, cmd, 1)) > return; > + > cmd->cmd[cmd->pos++] = tok; > } > > @@ -577,6 +577,7 @@ static void add_medium_atom_header(struct opal_dev *cmd, bool bytestring, > header0 |= bytestring ? MEDIUM_ATOM_BYTESTRING : 0; > header0 |= has_sign ? MEDIUM_ATOM_SIGNED : 0; > header0 |= (len >> 8) & MEDIUM_ATOM_LEN_MASK; > + > cmd->cmd[cmd->pos++] = header0; > cmd->cmd[cmd->pos++] = len; > } > @@ -649,6 +650,7 @@ static int build_locking_range(u8 *buffer, size_t length, u8 lr) > > if (lr == 0) > return 0; > + > buffer[5] = LOCKING_RANGE_NON_GLOBAL; > buffer[7] = lr; > > @@ -945,6 +947,7 @@ static size_t response_get_string(const struct parsed_resp *resp, int n, > } > > *store = tok->pos + skip; > + > return tok->len - skip; > } > > @@ -1062,6 +1065,7 @@ static int start_opal_session_cont(struct opal_dev *dev) > > dev->hsn = hsn; > dev->tsn = tsn; > + > return 0; > } > > @@ -1084,6 +1088,7 @@ static int end_session_cont(struct opal_dev *dev) > { > dev->hsn = 0; > dev->tsn = 0; > + > return parse_and_check_status(dev); > } > > @@ -1172,6 +1177,7 @@ static int gen_key(struct opal_dev *dev, void *data) > return err; > > } > + > return finalize_and_send(dev, parse_and_check_status); > } > > @@ -1184,12 +1190,14 @@ static int get_active_key_cont(struct opal_dev *dev) > error = parse_and_check_status(dev); > if (error) > return error; > + > keylen = response_get_string(&dev->parsed, 4, &activekey); > if (!activekey) { > pr_debug("%s: Couldn't extract the Activekey from the response\n", > __func__); > return OPAL_INVAL_PARAM; > } > + > dev->prev_data = kmemdup(activekey, keylen, GFP_KERNEL); > > if (!dev->prev_data) > @@ -1251,6 +1259,7 @@ static int generic_lr_enable_disable(struct opal_dev *dev, > > add_token_u8(&err, dev, OPAL_ENDLIST); > add_token_u8(&err, dev, OPAL_ENDNAME); > + > return err; > } > > @@ -1263,6 +1272,7 @@ static inline int enable_global_lr(struct opal_dev *dev, u8 *uid, > 0, 0); > if (err) > pr_debug("Failed to create enable global lr command\n"); > + > return err; > } > > @@ -1313,7 +1323,6 @@ static int setup_locking_range(struct opal_dev *dev, void *data) > if (err) { > pr_debug("Error building Setup Locking range command.\n"); > return err; > - > } > > return finalize_and_send(dev, parse_and_check_status); > @@ -1393,6 +1402,7 @@ static int start_SIDASP_opal_session(struct opal_dev *dev, void *data) > kfree(key); > dev->prev_data = NULL; > } > + > return ret; > } > > @@ -1518,6 +1528,7 @@ static int erase_locking_range(struct opal_dev *dev, void *data) > pr_debug("Error building Erase Locking Range Command.\n"); > return err; > } > + > return finalize_and_send(dev, parse_and_check_status); > } > > @@ -1636,6 +1647,7 @@ static int write_shadow_mbr(struct opal_dev *dev, void *data) > > off += len; > } > + > return err; > } > > @@ -1816,6 +1828,7 @@ static int lock_unlock_locking_range(struct opal_dev *dev, void *data) > pr_debug("Error building SET command.\n"); > return err; > } > + > return finalize_and_send(dev, parse_and_check_status); > } > > @@ -1857,6 +1870,7 @@ static int lock_unlock_locking_range_sum(struct opal_dev *dev, void *data) > pr_debug("Error building SET command.\n"); > return ret; > } > + > return finalize_and_send(dev, parse_and_check_status); > } > > @@ -1957,6 +1971,7 @@ static int end_opal_session(struct opal_dev *dev, void *data) > > if (err < 0) > return err; > + > return finalize_and_send(dev, end_session_cont); > } > > @@ -1965,6 +1980,7 @@ static int end_opal_session_error(struct opal_dev *dev) > const struct opal_step error_end_session = { > end_opal_session, > }; > + > return execute_step(dev, &error_end_session, 0); > } > > @@ -1984,6 +2000,7 @@ static int check_opal_support(struct opal_dev *dev) > ret = opal_discovery0_step(dev); > dev->supported = !ret; > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2004,6 +2021,7 @@ void free_opal_dev(struct opal_dev *dev) > { > if (!dev) > return; > + > clean_opal_dev(dev); > kfree(dev); > } > @@ -2026,6 +2044,7 @@ struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv) > kfree(dev); > return NULL; > } > + > return dev; > } > EXPORT_SYMBOL(init_opal_dev); > @@ -2045,6 +2064,7 @@ static int opal_secure_erase_locking_range(struct opal_dev *dev, > setup_opal_dev(dev); > ret = execute_steps(dev, erase_steps, ARRAY_SIZE(erase_steps)); > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2062,6 +2082,7 @@ static int opal_erase_locking_range(struct opal_dev *dev, > setup_opal_dev(dev); > ret = execute_steps(dev, erase_steps, ARRAY_SIZE(erase_steps)); > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2089,6 +2110,7 @@ static int opal_enable_disable_shadow_mbr(struct opal_dev *dev, > setup_opal_dev(dev); > ret = execute_steps(dev, mbr_steps, ARRAY_SIZE(mbr_steps)); > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2113,6 +2135,7 @@ static int opal_set_mbr_done(struct opal_dev *dev, > setup_opal_dev(dev); > ret = execute_steps(dev, mbr_steps, ARRAY_SIZE(mbr_steps)); > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2133,6 +2156,7 @@ static int opal_write_shadow_mbr(struct opal_dev *dev, > setup_opal_dev(dev); > ret = execute_steps(dev, mbr_steps, ARRAY_SIZE(mbr_steps)); > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2151,6 +2175,7 @@ static int opal_save(struct opal_dev *dev, struct opal_lock_unlock *lk_unlk) > setup_opal_dev(dev); > add_suspend_info(dev, suspend); > mutex_unlock(&dev->dev_lock); > + > return 0; > } > > @@ -2169,12 +2194,14 @@ static int opal_add_user_to_lr(struct opal_dev *dev, > pr_debug("Locking state was not RO or RW\n"); > return -EINVAL; > } > + > if (lk_unlk->session.who < OPAL_USER1 || > lk_unlk->session.who > OPAL_USER9) { > pr_debug("Authority was not within the range of users: %d\n", > lk_unlk->session.who); > return -EINVAL; > } > + > if (lk_unlk->session.sum) { > pr_debug("%s not supported in sum. Use setup locking range\n", > __func__); > @@ -2185,6 +2212,7 @@ static int opal_add_user_to_lr(struct opal_dev *dev, > setup_opal_dev(dev); > ret = execute_steps(dev, steps, ARRAY_SIZE(steps)); > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2267,6 +2295,7 @@ static int opal_lock_unlock(struct opal_dev *dev, > mutex_lock(&dev->dev_lock); > ret = __opal_lock_unlock(dev, lk_unlk); > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2289,6 +2318,7 @@ static int opal_take_ownership(struct opal_dev *dev, struct opal_key *opal) > setup_opal_dev(dev); > ret = execute_steps(dev, owner_steps, ARRAY_SIZE(owner_steps)); > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2310,6 +2340,7 @@ static int opal_activate_lsp(struct opal_dev *dev, > setup_opal_dev(dev); > ret = execute_steps(dev, active_steps, ARRAY_SIZE(active_steps)); > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2327,6 +2358,7 @@ static int opal_setup_locking_range(struct opal_dev *dev, > setup_opal_dev(dev); > ret = execute_steps(dev, lr_steps, ARRAY_SIZE(lr_steps)); > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2347,6 +2379,7 @@ static int opal_set_new_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw) > setup_opal_dev(dev); > ret = execute_steps(dev, pw_steps, ARRAY_SIZE(pw_steps)); > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2371,6 +2404,7 @@ static int opal_activate_user(struct opal_dev *dev, > setup_opal_dev(dev); > ret = execute_steps(dev, act_steps, ARRAY_SIZE(act_steps)); > mutex_unlock(&dev->dev_lock); > + > return ret; > } > > @@ -2382,6 +2416,7 @@ bool opal_unlock_from_suspend(struct opal_dev *dev) > > if (!dev) > return false; > + > if (!dev->supported) > return false; > > @@ -2399,6 +2434,7 @@ bool opal_unlock_from_suspend(struct opal_dev *dev) > suspend->unlk.session.sum); > was_failure = true; > } > + > if (dev->mbr_enabled) { > ret = __opal_set_mbr_done(dev, &suspend->unlk.session.opal_key); > if (ret) > @@ -2406,6 +2442,7 @@ bool opal_unlock_from_suspend(struct opal_dev *dev) > } > } > mutex_unlock(&dev->dev_lock); > + > return was_failure; > } > EXPORT_SYMBOL(opal_unlock_from_suspend); > -- > 2.17.1 > [-- Attachment #2: smime.p7s --] [-- Type: application/x-pkcs7-signature, Size: 3278 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] block: sed-opal: Add/remove spaces 2019-08-13 21:43 ` [PATCH 1/3] block: sed-opal: Add/remove spaces Revanth Rajashekar 2019-08-14 20:26 ` Derrick, Jonathan @ 2019-08-15 4:01 ` Scott Bauer 1 sibling, 0 replies; 12+ messages in thread From: Scott Bauer @ 2019-08-15 4:01 UTC (permalink / raw) To: Revanth Rajashekar; +Cc: linux-block, Jonathan Derrick On Tue, Aug 13, 2019 at 03:43:38PM -0600, Revanth Rajashekar wrote: > Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com> looks fine Reviewed-by Scott Bauer <sbauer@pldonthack.me> ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/3] block: sed-opal: Eliminating the dead error 2019-08-13 21:43 [PATCH 0/3] block: sed-opal: Code Cleanup Patches Revanth Rajashekar 2019-08-13 21:43 ` [PATCH 1/3] block: sed-opal: Add/remove spaces Revanth Rajashekar @ 2019-08-13 21:43 ` Revanth Rajashekar 2019-08-14 20:33 ` Derrick, Jonathan 2019-08-15 4:03 ` Scott Bauer 2019-08-13 21:43 ` [PATCH 3/3] block: sed-opal: OPAL_METHOD_LENGTH defined twice Revanth Rajashekar 2019-08-13 22:28 ` [PATCH 0/3] block: sed-opal: Code Cleanup Patches Derrick, Jonathan 3 siblings, 2 replies; 12+ messages in thread From: Revanth Rajashekar @ 2019-08-13 21:43 UTC (permalink / raw) To: linux-block; +Cc: Jonathan Derrick, Scott Bauer, Revanth Rajashekar In the function 'response_parse', num_entries will never be 0 as slen is checked for 0. Hence, the condition 'if (num_entries == 0)' can never be true. Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com> --- block/sed-opal.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/block/sed-opal.c b/block/sed-opal.c index d442f29e84f1..4e95a9792162 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -905,10 +905,6 @@ static int response_parse(const u8 *buf, size_t length, num_entries++; } - if (num_entries == 0) { - pr_debug("Couldn't parse response.\n"); - return -EINVAL; - } resp->num = num_entries; return 0; -- 2.17.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] block: sed-opal: Eliminating the dead error 2019-08-13 21:43 ` [PATCH 2/3] block: sed-opal: Eliminating the dead error Revanth Rajashekar @ 2019-08-14 20:33 ` Derrick, Jonathan 2019-08-15 4:03 ` Scott Bauer 1 sibling, 0 replies; 12+ messages in thread From: Derrick, Jonathan @ 2019-08-14 20:33 UTC (permalink / raw) To: Rajashekar, Revanth, linux-block; +Cc: hch, sbauer, axboe [-- Attachment #1: Type: text/plain, Size: 869 bytes --] lgtm Reviewed-by: Jon Derrick <jonathan.derrick@intel.com> On Tue, 2019-08-13 at 15:43 -0600, Rajashekar, Revanth wrote: > In the function 'response_parse', num_entries will never be 0 as > slen is checked for 0. Hence, the condition 'if (num_entries == 0)' > can never be true. > > Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com> > --- > block/sed-opal.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/block/sed-opal.c b/block/sed-opal.c > index d442f29e84f1..4e95a9792162 100644 > --- a/block/sed-opal.c > +++ b/block/sed-opal.c > @@ -905,10 +905,6 @@ static int response_parse(const u8 *buf, size_t length, > num_entries++; > } > > - if (num_entries == 0) { > - pr_debug("Couldn't parse response.\n"); > - return -EINVAL; > - } > resp->num = num_entries; > > return 0; > -- > 2.17.1 > [-- Attachment #2: smime.p7s --] [-- Type: application/x-pkcs7-signature, Size: 3278 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] block: sed-opal: Eliminating the dead error 2019-08-13 21:43 ` [PATCH 2/3] block: sed-opal: Eliminating the dead error Revanth Rajashekar 2019-08-14 20:33 ` Derrick, Jonathan @ 2019-08-15 4:03 ` Scott Bauer 1 sibling, 0 replies; 12+ messages in thread From: Scott Bauer @ 2019-08-15 4:03 UTC (permalink / raw) To: Revanth Rajashekar; +Cc: linux-block, Jonathan Derrick On Tue, Aug 13, 2019 at 03:43:39PM -0600, Revanth Rajashekar wrote: > In the function 'response_parse', num_entries will never be 0 as > slen is checked for 0. Hence, the condition 'if (num_entries == 0)' > can never be true. > > Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com> Reviewed-by: Scott Bauer <sbauer@plzdonthack.me> Can we also change the title to something a little more obvious like: Remove always false if statement The current title is ambigious if you single-line look at commits. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] block: sed-opal: OPAL_METHOD_LENGTH defined twice 2019-08-13 21:43 [PATCH 0/3] block: sed-opal: Code Cleanup Patches Revanth Rajashekar 2019-08-13 21:43 ` [PATCH 1/3] block: sed-opal: Add/remove spaces Revanth Rajashekar 2019-08-13 21:43 ` [PATCH 2/3] block: sed-opal: Eliminating the dead error Revanth Rajashekar @ 2019-08-13 21:43 ` Revanth Rajashekar 2019-08-14 20:34 ` Derrick, Jonathan 2019-08-15 4:07 ` Scott Bauer 2019-08-13 22:28 ` [PATCH 0/3] block: sed-opal: Code Cleanup Patches Derrick, Jonathan 3 siblings, 2 replies; 12+ messages in thread From: Revanth Rajashekar @ 2019-08-13 21:43 UTC (permalink / raw) To: linux-block; +Cc: Jonathan Derrick, Scott Bauer, Revanth Rajashekar Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com> --- block/opal_proto.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/block/opal_proto.h b/block/opal_proto.h index 562b78f40824..5532412d567c 100644 --- a/block/opal_proto.h +++ b/block/opal_proto.h @@ -119,8 +119,6 @@ enum opal_uid { OPAL_UID_HEXFF, }; -#define OPAL_METHOD_LENGTH 8 - /* Enum for indexing the OPALMETHOD array */ enum opal_method { OPAL_PROPERTIES, -- 2.17.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] block: sed-opal: OPAL_METHOD_LENGTH defined twice 2019-08-13 21:43 ` [PATCH 3/3] block: sed-opal: OPAL_METHOD_LENGTH defined twice Revanth Rajashekar @ 2019-08-14 20:34 ` Derrick, Jonathan 2019-08-15 4:07 ` Scott Bauer 1 sibling, 0 replies; 12+ messages in thread From: Derrick, Jonathan @ 2019-08-14 20:34 UTC (permalink / raw) To: Rajashekar, Revanth, linux-block; +Cc: hch, sbauer, axboe [-- Attachment #1: Type: text/plain, Size: 649 bytes --] lgtm Reviewed-by: Jon Derrick <jonathan.derrick@intel.com> On Tue, 2019-08-13 at 15:43 -0600, Revanth Rajashekar wrote: > Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com> > --- > block/opal_proto.h | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/block/opal_proto.h b/block/opal_proto.h > index 562b78f40824..5532412d567c 100644 > --- a/block/opal_proto.h > +++ b/block/opal_proto.h > @@ -119,8 +119,6 @@ enum opal_uid { > OPAL_UID_HEXFF, > }; > > -#define OPAL_METHOD_LENGTH 8 > - > /* Enum for indexing the OPALMETHOD array */ > enum opal_method { > OPAL_PROPERTIES, > -- > 2.17.1 > [-- Attachment #2: smime.p7s --] [-- Type: application/x-pkcs7-signature, Size: 3278 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] block: sed-opal: OPAL_METHOD_LENGTH defined twice 2019-08-13 21:43 ` [PATCH 3/3] block: sed-opal: OPAL_METHOD_LENGTH defined twice Revanth Rajashekar 2019-08-14 20:34 ` Derrick, Jonathan @ 2019-08-15 4:07 ` Scott Bauer 2019-08-15 16:08 ` Rajashekar, Revanth 1 sibling, 1 reply; 12+ messages in thread From: Scott Bauer @ 2019-08-15 4:07 UTC (permalink / raw) To: Revanth Rajashekar; +Cc: linux-block, Jonathan Derrick On Tue, Aug 13, 2019 at 03:43:40PM -0600, Revanth Rajashekar wrote: > Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com> Reviewed-by: Scott Bauer <sbauer@plzdonthack.me> Two things, Can we also change the title of this commit to: "Removed duplicate OPAL_METHOD_LENGTH definition" 2nd, I'm dumb as hell now adays, why doesn't this throw a compiler error for multiple declarations? ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH 3/3] block: sed-opal: OPAL_METHOD_LENGTH defined twice 2019-08-15 4:07 ` Scott Bauer @ 2019-08-15 16:08 ` Rajashekar, Revanth 0 siblings, 0 replies; 12+ messages in thread From: Rajashekar, Revanth @ 2019-08-15 16:08 UTC (permalink / raw) To: Scott Bauer; +Cc: linux-block, Derrick, Jonathan The re-definition error is thrown only when 2 different values are assigned to the same #define variable. But in this case, the same value is defined twice... hence the compiler doesn't throw error. Thank you :) Revanth Rajashekar -----Original Message----- From: Scott Bauer [mailto:sbauer@plzdonthack.me] Sent: Wednesday, August 14, 2019 10:08 PM To: Rajashekar, Revanth <revanth.rajashekar@intel.com> Cc: linux-block@vger.kernel.org; Derrick, Jonathan <jonathan.derrick@intel.com> Subject: Re: [PATCH 3/3] block: sed-opal: OPAL_METHOD_LENGTH defined twice On Tue, Aug 13, 2019 at 03:43:40PM -0600, Revanth Rajashekar wrote: > Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com> Reviewed-by: Scott Bauer <sbauer@plzdonthack.me> Two things, Can we also change the title of this commit to: "Removed duplicate OPAL_METHOD_LENGTH definition" 2nd, I'm dumb as hell now adays, why doesn't this throw a compiler error for multiple declarations? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/3] block: sed-opal: Code Cleanup Patches 2019-08-13 21:43 [PATCH 0/3] block: sed-opal: Code Cleanup Patches Revanth Rajashekar ` (2 preceding siblings ...) 2019-08-13 21:43 ` [PATCH 3/3] block: sed-opal: OPAL_METHOD_LENGTH defined twice Revanth Rajashekar @ 2019-08-13 22:28 ` Derrick, Jonathan 3 siblings, 0 replies; 12+ messages in thread From: Derrick, Jonathan @ 2019-08-13 22:28 UTC (permalink / raw) To: Rajashekar, Revanth, linux-block; +Cc: hch, sbauer, axboe [-- Attachment #1: Type: text/plain, Size: 732 bytes --] +Christoph, Jens On Tue, 2019-08-13 at 15:43 -0600, Rajashekar, Revanth wrote: > This series of patch is a cleanup for sed-opal in kernel 5.4. It > 1. Adds/removes spaces. > 2. Eliminates dead error condition. > 3. Eliminates definition defined twice. > > These cleanup patches are submitted with the intend to submit a new > feature > after this. > > Revanth Rajashekar (3): > block: sed-opal: Add/remove spaces > block: sed-opal: Eliminating the dead error > block: sed-opal: OPAL_METHOD_LENGTH defined twice > > block/opal_proto.h | 5 +---- > block/sed-opal.c | 49 ++++++++++++++++++++++++++++++++++++++---- > ---- > 2 files changed, 42 insertions(+), 12 deletions(-) > > -- > 2.17.1 > [-- Attachment #2: smime.p7s --] [-- Type: application/x-pkcs7-signature, Size: 3278 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2019-08-15 16:08 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-08-13 21:43 [PATCH 0/3] block: sed-opal: Code Cleanup Patches Revanth Rajashekar 2019-08-13 21:43 ` [PATCH 1/3] block: sed-opal: Add/remove spaces Revanth Rajashekar 2019-08-14 20:26 ` Derrick, Jonathan 2019-08-15 4:01 ` Scott Bauer 2019-08-13 21:43 ` [PATCH 2/3] block: sed-opal: Eliminating the dead error Revanth Rajashekar 2019-08-14 20:33 ` Derrick, Jonathan 2019-08-15 4:03 ` Scott Bauer 2019-08-13 21:43 ` [PATCH 3/3] block: sed-opal: OPAL_METHOD_LENGTH defined twice Revanth Rajashekar 2019-08-14 20:34 ` Derrick, Jonathan 2019-08-15 4:07 ` Scott Bauer 2019-08-15 16:08 ` Rajashekar, Revanth 2019-08-13 22:28 ` [PATCH 0/3] block: sed-opal: Code Cleanup Patches Derrick, Jonathan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).