From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chaitanya.Kulkarni@wdc.com (Chaitanya Kulkarni) Date: Sun, 12 May 2019 15:22:43 +0000 Subject: [PATCH RFC 2/4] nvme-status: Introduce nvme status module to map errno References: <20190511193713.29516-1-minwoo.im.dev@gmail.com> <20190511193713.29516-3-minwoo.im.dev@gmail.com> <5bcca563-73c9-a588-d656-9b612aedad20@gmail.com> Message-ID: That works. On 5/11/19 3:25 PM, Minwoo Im wrote: >>> + if (sct == NVME_SCT_GENERIC) { >>> + switch (status) { >>> + case NVME_SC_INVALID_OPCODE: >>> + case NVME_SC_INVALID_FIELD: >>> + case NVME_SC_INVALID_NS: >>> + case NVME_SC_SGL_INVALID_LAST: >>> + case NVME_SC_SGL_INVALID_COUNT: >>> + case NVME_SC_SGL_INVALID_DATA: >>> + case NVME_SC_SGL_INVALID_METADATA: >>> + case NVME_SC_SGL_INVALID_TYPE: >>> + case NVME_SC_SGL_INVALID_OFFSET: >>> + case NVME_SC_SGL_INVALID_SUBTYPE: >>> + return EINVAL; >>> + case NVME_SC_CMDID_CONFLICT: >>> + return EADDRINUSE; >>> + case NVME_SC_DATA_XFER_ERROR: >>> + case NVME_SC_INTERNAL: >>> + case NVME_SC_SANITIZE_FAILED: >>> + return EIO; >>> + case NVME_SC_POWER_LOSS: >>> + case NVME_SC_ABORT_REQ: >>> + case NVME_SC_ABORT_QUEUE: >>> + case NVME_SC_FUSED_FAIL: >>> + case NVME_SC_FUSED_MISSING: >>> + return EWOULDBLOCK; >>> + case NVME_SC_CMD_SEQ_ERROR: >>> + return EILSEQ; >>> + case NVME_SC_SANITIZE_IN_PROGRESS: >>> + return EINPROGRESS; >>> + case NVME_SC_NS_WRITE_PROTECTED: >>> + case NVME_SC_NS_NOT_READY: >>> + case NVME_SC_RESERVATION_CONFLICT: >>> + return EACCES; >>> + case NVME_SC_LBA_RANGE: >>> + return EREMOTEIO; >>> + case NVME_SC_CAP_EXCEEDED: >>> + return ENOSPC; >>> + } >> Please move above switch to the small helper inline function >> >> nvme_status_code_generic(). > I would like to have it indicating "errno" concept in the function name. > I'll make them like: > nvme_generic_status_to_errno() > nvme_cmd_specific_status_to_errno() > nvme_fabrics_status_to_errno() >