qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Maxim Levitsky <mlevitsk@redhat.com>
To: Klaus Jensen <its@irrelevant.dk>, qemu-block@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Beata Michalska" <beata.michalska@linaro.org>,
	"Klaus Jensen" <k.jensen@samsung.com>,
	qemu-devel@nongnu.org, "Max Reitz" <mreitz@redhat.com>,
	"Keith Busch" <kbusch@kernel.org>,
	"Javier Gonzalez" <javier.gonz@samsung.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH v2 12/16] nvme: add namespace helpers
Date: Tue, 21 Apr 2020 18:41:10 +0300	[thread overview]
Message-ID: <ee8ad286b9d4a7079210914291098eab2016e8b0.camel@redhat.com> (raw)
In-Reply-To: <20200415130159.611361-13-its@irrelevant.dk>

On Wed, 2020-04-15 at 15:01 +0200, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> Introduce some small helpers to make the next patches easier on the eye.
> 
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>  hw/block/nvme.c |  3 +--
>  hw/block/nvme.h | 16 ++++++++++++++++
>  2 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index 80da0825d295..d5244102252c 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -1469,8 +1469,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
>          id_ns->dps = 0;
>          id_ns->lbaf[0].ds = BDRV_SECTOR_BITS;
>          id_ns->ncap  = id_ns->nuse = id_ns->nsze =
> -            cpu_to_le64(n->ns_size >>
> -                id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas)].ds);
> +            cpu_to_le64(nvme_ns_nlbas(n, ns));
>      }
>  }
>  
> diff --git a/hw/block/nvme.h b/hw/block/nvme.h
> index 7eecfd3a50f6..dd932a9e7ebc 100644
> --- a/hw/block/nvme.h
> +++ b/hw/block/nvme.h
> @@ -67,6 +67,17 @@ typedef struct NvmeNamespace {
>      NvmeIdNs        id_ns;
>  } NvmeNamespace;
>  
> +static inline NvmeLBAF *nvme_ns_lbaf(NvmeNamespace *ns)
> +{
> +    NvmeIdNs *id_ns = &ns->id_ns;
> +    return &id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(id_ns->flbas)];
> +}
> +
> +static inline uint8_t nvme_ns_lbads(NvmeNamespace *ns)
> +{
> +    return nvme_ns_lbaf(ns)->ds;
> +}
> +
>  #define TYPE_NVME "nvme"
>  #define NVME(obj) \
>          OBJECT_CHECK(NvmeCtrl, (obj), TYPE_NVME)
> @@ -101,4 +112,9 @@ typedef struct NvmeCtrl {
>      NvmeIdCtrl      id_ctrl;
>  } NvmeCtrl;
>  
> +static inline uint64_t nvme_ns_nlbas(NvmeCtrl *n, NvmeNamespace *ns)
> +{
> +    return n->ns_size >> nvme_ns_lbads(ns);
> +}
> +
>  #endif /* HW_NVME_H */

Nitpick: On second thought, these function names do sound quite cryptic, so maybe
at least for nvme_ns_nlbas pick something more readable? maybe nvme_ns_number_of_lbas
or something.
Or add a comment - comment always fixes these kind of issues.

But that doesn't matter much IMHO, so
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>

Best regards,
	Maxim Levitsky



  parent reply	other threads:[~2020-04-21 15:42 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 13:01 [PATCH v2 00/16] nvme: refactoring and cleanups Klaus Jensen
2020-04-15 13:01 ` [PATCH v2 01/16] nvme: fix pci doorbell size calculation Klaus Jensen
2020-04-15 13:13   ` Philippe Mathieu-Daudé
2020-04-21  9:39     ` Maxim Levitsky
2020-04-15 13:01 ` [PATCH v2 02/16] nvme: rename trace events to pci_nvme Klaus Jensen
2020-04-15 13:04   ` Philippe Mathieu-Daudé
2020-04-21  9:43   ` Maxim Levitsky
2020-04-15 13:01 ` [PATCH v2 03/16] nvme: remove superfluous breaks Klaus Jensen
2020-04-15 13:01 ` [PATCH v2 04/16] nvme: move device parameters to separate struct Klaus Jensen
2020-04-15 13:01 ` [PATCH v2 05/16] nvme: use constants in identify Klaus Jensen
2020-04-15 13:01 ` [PATCH v2 06/16] nvme: refactor nvme_addr_read Klaus Jensen
2020-04-21 10:35   ` Maxim Levitsky
2020-04-15 13:01 ` [PATCH v2 07/16] nvme: add max_ioqpairs device parameter Klaus Jensen
2020-04-15 13:01 ` [PATCH v2 08/16] nvme: remove redundant cmbloc/cmbsz members Klaus Jensen
2020-04-21 12:05   ` Maxim Levitsky
2020-04-15 13:01 ` [PATCH v2 09/16] nvme: factor out property/constraint checks Klaus Jensen
2020-04-15 13:08   ` Philippe Mathieu-Daudé
2020-04-21 14:53   ` Maxim Levitsky
2020-04-15 13:01 ` [PATCH v2 10/16] nvme: factor out device state setup Klaus Jensen
2020-04-21 14:55   ` Maxim Levitsky
2020-04-15 13:01 ` [PATCH v2 11/16] nvme: factor out block backend setup Klaus Jensen
2020-04-15 13:08   ` Philippe Mathieu-Daudé
2020-04-21 15:04   ` Maxim Levitsky
2020-04-15 13:01 ` [PATCH v2 12/16] nvme: add namespace helpers Klaus Jensen
2020-04-15 13:09   ` Philippe Mathieu-Daudé
2020-04-21 15:41   ` Maxim Levitsky [this message]
2020-04-15 13:01 ` [PATCH v2 13/16] nvme: factor out namespace setup Klaus Jensen
2020-04-15 13:16   ` Philippe Mathieu-Daudé
2020-04-15 13:20     ` Klaus Birkelund Jensen
2020-04-15 13:26       ` Philippe Mathieu-Daudé
2020-04-16  6:03         ` Klaus Birkelund Jensen
2020-04-24 10:13           ` Philippe Mathieu-Daudé
2020-04-21 15:57   ` Maxim Levitsky
2020-04-15 13:01 ` [PATCH v2 14/16] nvme: factor out pci setup Klaus Jensen
2020-04-15 13:14   ` Philippe Mathieu-Daudé
2020-04-21 15:59   ` Maxim Levitsky
2020-04-15 13:01 ` [PATCH v2 15/16] nvme: factor out cmb setup Klaus Jensen
2020-04-21 16:10   ` Maxim Levitsky
2020-04-15 13:01 ` [PATCH v2 16/16] nvme: factor out controller identify setup Klaus Jensen
2020-04-15 13:06   ` Philippe Mathieu-Daudé
2020-04-21 16:17   ` Maxim Levitsky
2020-04-15 14:29 ` [PATCH v2 00/16] nvme: refactoring and cleanups no-reply
2020-04-20  5:14 ` Klaus Birkelund Jensen
2020-04-20 17:38 ` Keith Busch
2020-04-21  6:38   ` Klaus Birkelund Jensen
2020-04-21 15:47     ` Kevin Wolf
2020-04-21 16:24 ` Maxim Levitsky
2020-04-22  6:19   ` Klaus Birkelund Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee8ad286b9d4a7079210914291098eab2016e8b0.camel@redhat.com \
    --to=mlevitsk@redhat.com \
    --cc=beata.michalska@linaro.org \
    --cc=its@irrelevant.dk \
    --cc=javier.gonz@samsung.com \
    --cc=k.jensen@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).