diff mbox series

[v7,05/48] nvme: use constants in identify

Message ID 20200415055140.466900-6-its@irrelevant.dk
State New
Headers show
Series nvme: support NVMe v1.3d, SGLs and multiple namespaces | expand

Commit Message

Klaus Jensen April 15, 2020, 5:50 a.m. UTC
From: Klaus Jensen <k.jensen@samsung.com>

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 hw/block/nvme.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Philippe Mathieu-Daudé April 15, 2020, 7:01 a.m. UTC | #1
On 4/15/20 7:50 AM, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>   hw/block/nvme.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index 088668f28bae..622103c42d0a 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -679,7 +679,7 @@ static uint16_t nvme_identify_ns(NvmeCtrl *n, NvmeIdentify *c)
>   
>   static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeIdentify *c)
>   {
> -    static const int data_len = 4 * KiB;
> +    static const int data_len = NVME_IDENTIFY_DATA_SIZE;
>       uint32_t min_nsid = le32_to_cpu(c->nsid);
>       uint64_t prp1 = le64_to_cpu(c->prp1);
>       uint64_t prp2 = le64_to_cpu(c->prp2);
> @@ -709,11 +709,11 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeCmd *cmd)
>       NvmeIdentify *c = (NvmeIdentify *)cmd;
>   
>       switch (le32_to_cpu(c->cns)) {
> -    case 0x00:
> +    case NVME_ID_CNS_NS:
>           return nvme_identify_ns(n, c);
> -    case 0x01:
> +    case NVME_ID_CNS_CTRL:
>           return nvme_identify_ctrl(n, c);
> -    case 0x02:
> +    case NVME_ID_CNS_NS_ACTIVE_LIST:
>           return nvme_identify_nslist(n, c);
>       default:

Ah, NVME_ID_CNS_NS_DESCR_LIST is currently invalid.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>           trace_nvme_dev_err_invalid_identify_cns(le32_to_cpu(c->cns));
>
diff mbox series

Patch

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 088668f28bae..622103c42d0a 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -679,7 +679,7 @@  static uint16_t nvme_identify_ns(NvmeCtrl *n, NvmeIdentify *c)
 
 static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeIdentify *c)
 {
-    static const int data_len = 4 * KiB;
+    static const int data_len = NVME_IDENTIFY_DATA_SIZE;
     uint32_t min_nsid = le32_to_cpu(c->nsid);
     uint64_t prp1 = le64_to_cpu(c->prp1);
     uint64_t prp2 = le64_to_cpu(c->prp2);
@@ -709,11 +709,11 @@  static uint16_t nvme_identify(NvmeCtrl *n, NvmeCmd *cmd)
     NvmeIdentify *c = (NvmeIdentify *)cmd;
 
     switch (le32_to_cpu(c->cns)) {
-    case 0x00:
+    case NVME_ID_CNS_NS:
         return nvme_identify_ns(n, c);
-    case 0x01:
+    case NVME_ID_CNS_CTRL:
         return nvme_identify_ctrl(n, c);
-    case 0x02:
+    case NVME_ID_CNS_NS_ACTIVE_LIST:
         return nvme_identify_nslist(n, c);
     default:
         trace_nvme_dev_err_invalid_identify_cns(le32_to_cpu(c->cns));