All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Mohit Kapoor <mohit.kap@samsung.com>
Cc: fam@euphon.net, kwolf@redhat.com, p.kalghatgi@samsung.com,
	qemu-block@nongnu.org, k.jensen@samsung.com,
	d.palani@samsung.com, qemu-devel@nongnu.org,
	linux-nvme@lists.infrared.org, mreitz@redhat.com,
	u.kishore@samsung.com, stefanha@redhat.com, its@irrelevant.dk,
	javier.gonz@samsung.com, prakash.v@samsung.com,
	jg123.choi@samsung.com
Subject: Re: [RFC PATCH nvme-cli 2/2] nvme-cli/plugins/mi:add support
Date: Fri, 9 Jul 2021 09:04:30 -0700	[thread overview]
Message-ID: <20210709160430.GB291156@dhcp-10-100-145-180.wdc.com> (raw)
In-Reply-To: <20210709145352.GA14300@test-zns>

> +int hal_init()
> +{
> +    int retval = -1;
> +    switch (GetSidebandInterface()) {
> +    case qemu_nvme_mi:
> +        retval = qemu_mi_init();
> +        break;
> +    default:
> +        break;
> +    }
> +    return retval;
> +}
> +
> +int hal_open()
> +{
> +    int retval = -1;
> +    switch (GetSidebandInterface()) {
> +    case qemu_nvme_mi:
> +        retval = qemu_mi_open();
> +        break;
> +    default:
> +        break;
> +    }
> +    return retval;
> +}
> +
> +int hal_close()
> +{
> +    int retval = -1;
> +    switch (GetSidebandInterface()) {
> +    case qemu_nvme_mi:
> +        retval = qemu_mi_close();
> +        break;
> +    default:
> +        break;
> +    }
> +    return retval;
> +}
> +
> +int hal_i2c_write(uint8_t *data_out, uint16_t num_bytes)
> +{
> +    int retval = -1;
> +    switch (GetSidebandInterface()) {
> +    case qemu_nvme_mi:
> +        retval = qemu_mi_write(data_out, num_bytes);
> +        break;
> +    default:
> +        break;
> +    }
> +    return retval;
> +}
> +
> +int hal_i2c_read(uint8_t *data_in, uint16_t num_bytes)
> +{
> +    uint32_t retval = -1;
> +    switch (GetSidebandInterface()) {
> +    case qemu_nvme_mi:
> +        retval = qemu_mi_read(data_in, num_bytes);
> +        break;
> +    default:
> +        break;
> +    }
> +    return retval;
> +}

I'm really not a fan of having non-standard interfaces. If you were
going to do that, though, you should create a struct of function
pointers so that you don't need these repetitive "switch (...)"
statements.

But if we're going to have OOB MI support in toolign, they should all
use the same standard defined interface.


  reply	other threads:[~2021-07-09 16:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210709145458epcas5p35826843853e7a8986098c4ff8fba857a@epcas5p3.samsung.com>
2021-07-09 14:53 ` [RFC PATCH nvme-cli 2/2] nvme-cli/plugins/mi:add support Mohit Kapoor
2021-07-09 16:04   ` Keith Busch [this message]
2021-07-19 15:31     ` Mohit Kapoor
2021-07-19 15:31       ` Mohit Kapoor

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=20210709160430.GB291156@dhcp-10-100-145-180.wdc.com \
    --to=kbusch@kernel.org \
    --cc=d.palani@samsung.com \
    --cc=fam@euphon.net \
    --cc=its@irrelevant.dk \
    --cc=javier.gonz@samsung.com \
    --cc=jg123.choi@samsung.com \
    --cc=k.jensen@samsung.com \
    --cc=kwolf@redhat.com \
    --cc=linux-nvme@lists.infrared.org \
    --cc=mohit.kap@samsung.com \
    --cc=mreitz@redhat.com \
    --cc=p.kalghatgi@samsung.com \
    --cc=prakash.v@samsung.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=u.kishore@samsung.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.