Skip to content

Commit b6cec06

Browse files
ChaitanayaKulkarniChristoph Hellwig
authored andcommitted
nvme-loop: remove extra variable in create ctrl
We can call the nvme_change_ctrl_state() directly and have WARN_ON_ONCE(1) call instead of having to use an extra variable which matches the name of the function. Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 64d452b commit b6cec06

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

drivers/nvme/target/loop.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ static void nvme_loop_reset_ctrl_work(struct work_struct *work)
444444
{
445445
struct nvme_loop_ctrl *ctrl =
446446
container_of(work, struct nvme_loop_ctrl, ctrl.reset_work);
447-
bool changed;
448447
int ret;
449448

450449
nvme_stop_ctrl(&ctrl->ctrl);
@@ -471,8 +470,8 @@ static void nvme_loop_reset_ctrl_work(struct work_struct *work)
471470
blk_mq_update_nr_hw_queues(&ctrl->tag_set,
472471
ctrl->ctrl.queue_count - 1);
473472

474-
changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE);
475-
WARN_ON_ONCE(!changed);
473+
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE))
474+
WARN_ON_ONCE(1);
476475

477476
nvme_start_ctrl(&ctrl->ctrl);
478477

@@ -567,7 +566,6 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev,
567566
struct nvmf_ctrl_options *opts)
568567
{
569568
struct nvme_loop_ctrl *ctrl;
570-
bool changed;
571569
int ret;
572570

573571
ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
@@ -583,8 +581,8 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev,
583581
if (ret)
584582
goto out_put_ctrl;
585583

586-
changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING);
587-
WARN_ON_ONCE(!changed);
584+
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING))
585+
WARN_ON_ONCE(1);
588586

589587
ret = -ENOMEM;
590588

@@ -620,8 +618,8 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev,
620618
dev_info(ctrl->ctrl.device,
621619
"new ctrl: \"%s\"\n", ctrl->ctrl.opts->subsysnqn);
622620

623-
changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE);
624-
WARN_ON_ONCE(!changed);
621+
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE))
622+
WARN_ON_ONCE(1);
625623

626624
mutex_lock(&nvme_loop_ctrl_mutex);
627625
list_add_tail(&ctrl->list, &nvme_loop_ctrl_list);

0 commit comments

Comments
 (0)