diff options
author | Keith Busch <kbusch@kernel.org> | 2024-01-24 09:27:27 -0800 |
---|---|---|
committer | Keith Busch <kbusch@kernel.org> | 2024-01-29 07:02:50 -0800 |
commit | 6d3c7fb17b4c047ccd0b42cf1308da693ab45acb (patch) | |
tree | e219029aeb82327159efc5a90f0de9a30a35993b /drivers/nvme/host/sysfs.c | |
parent | 47c5dd66c1840524572dcdd956f4af2bdb6fbdff (diff) | |
download | linux-stable-6d3c7fb17b4c047ccd0b42cf1308da693ab45acb.tar.gz linux-stable-6d3c7fb17b4c047ccd0b42cf1308da693ab45acb.tar.bz2 linux-stable-6d3c7fb17b4c047ccd0b42cf1308da693ab45acb.zip |
nvme: use ctrl state accessor
The ctrl->state value is updated in another thread using WRITE_ONCE, so
ensure all the readers use the appropriate accessor.
Reviewed-by: Sagi Grimberg <sagi@grmberg.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Diffstat (limited to 'drivers/nvme/host/sysfs.c')
-rw-r--r-- | drivers/nvme/host/sysfs.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c index 754e91111042..6b2f06f190de 100644 --- a/drivers/nvme/host/sysfs.c +++ b/drivers/nvme/host/sysfs.c @@ -311,6 +311,7 @@ static ssize_t nvme_sysfs_show_state(struct device *dev, char *buf) { struct nvme_ctrl *ctrl = dev_get_drvdata(dev); + unsigned state = (unsigned)nvme_ctrl_state(ctrl); static const char *const state_name[] = { [NVME_CTRL_NEW] = "new", [NVME_CTRL_LIVE] = "live", @@ -321,9 +322,8 @@ static ssize_t nvme_sysfs_show_state(struct device *dev, [NVME_CTRL_DEAD] = "dead", }; - if ((unsigned)ctrl->state < ARRAY_SIZE(state_name) && - state_name[ctrl->state]) - return sysfs_emit(buf, "%s\n", state_name[ctrl->state]); + if (state < ARRAY_SIZE(state_name) && state_name[state]) + return sysfs_emit(buf, "%s\n", state_name[state]); return sysfs_emit(buf, "unknown state\n"); } |