aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvme/host/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/nvme/host/core.c')
-rw-r--r--drivers/nvme/host/core.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 7ff2e820bbf4..2feacc70bf61 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -81,10 +81,12 @@ EXPORT_SYMBOL_GPL(nvme_cancel_request);
81bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, 81bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
82 enum nvme_ctrl_state new_state) 82 enum nvme_ctrl_state new_state)
83{ 83{
84 enum nvme_ctrl_state old_state = ctrl->state; 84 enum nvme_ctrl_state old_state;
85 bool changed = false; 85 bool changed = false;
86 86
87 spin_lock_irq(&ctrl->lock); 87 spin_lock_irq(&ctrl->lock);
88
89 old_state = ctrl->state;
88 switch (new_state) { 90 switch (new_state) {
89 case NVME_CTRL_LIVE: 91 case NVME_CTRL_LIVE:
90 switch (old_state) { 92 switch (old_state) {
@@ -140,11 +142,12 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
140 default: 142 default:
141 break; 143 break;
142 } 144 }
143 spin_unlock_irq(&ctrl->lock);
144 145
145 if (changed) 146 if (changed)
146 ctrl->state = new_state; 147 ctrl->state = new_state;
147 148
149 spin_unlock_irq(&ctrl->lock);
150
148 return changed; 151 return changed;
149} 152}
150EXPORT_SYMBOL_GPL(nvme_change_ctrl_state); 153EXPORT_SYMBOL_GPL(nvme_change_ctrl_state);
@@ -608,7 +611,7 @@ int nvme_get_features(struct nvme_ctrl *dev, unsigned fid, unsigned nsid,
608 611
609 ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0, 612 ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0,
610 NVME_QID_ANY, 0, 0); 613 NVME_QID_ANY, 0, 0);
611 if (ret >= 0) 614 if (ret >= 0 && result)
612 *result = le32_to_cpu(cqe.result); 615 *result = le32_to_cpu(cqe.result);
613 return ret; 616 return ret;
614} 617}
@@ -628,7 +631,7 @@ int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dword11,
628 631
629 ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0, 632 ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0,
630 NVME_QID_ANY, 0, 0); 633 NVME_QID_ANY, 0, 0);
631 if (ret >= 0) 634 if (ret >= 0 && result)
632 *result = le32_to_cpu(cqe.result); 635 *result = le32_to_cpu(cqe.result);
633 return ret; 636 return ret;
634} 637}