nvmet: use helper to remove the duplicate code
authorChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Mon, 10 May 2021 19:15:37 +0000 (12:15 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 11 May 2021 16:30:45 +0000 (18:30 +0200)
Use the helper nvmet_report_invalid_opcode() to report invalid opcode
so we can remove the duplicate code.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/admin-cmd.c

index e7a367c..dcd49a7 100644 (file)
@@ -975,10 +975,7 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
        case nvme_admin_keep_alive:
                req->execute = nvmet_execute_keep_alive;
                return 0;
+       default:
+               return nvmet_report_invalid_opcode(req);
        }
-
-       pr_debug("unhandled cmd %d on qid %d\n", cmd->common.opcode,
-              req->sq->qid);
-       req->error_loc = offsetof(struct nvme_common_command, opcode);
-       return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
 }