[PATCH 02/14] nvme-core: don't use switch for only one case use

Chaitanya Kulkarni chaitanya.kulkarni at wdc.com
Tue Feb 16 19:10:20 EST 2021


There is no point in using switch case statement for only one case that
takes about 5 lines.

Remove switch case which only checks for the NVME_CTRL_LIVE state and
use simple if statement that only takes one line.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 drivers/nvme/host/core.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 70042e111efe..2f6b89f6309d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3254,12 +3254,8 @@ static int nvme_dev_open(struct inode *inode, struct file *file)
 	struct nvme_ctrl *ctrl =
 		container_of(inode->i_cdev, struct nvme_ctrl, cdev);
 
-	switch (ctrl->state) {
-	case NVME_CTRL_LIVE:
-		break;
-	default:
+	if (ctrl->state != NVME_CTRL_LIVE)
 		return -EWOULDBLOCK;
-	}
 
 	nvme_get_ctrl(ctrl);
 	if (!try_module_get(ctrl->ops->module)) {
-- 
2.22.1




More information about the Linux-nvme mailing list