All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "Williams, Dan J" <dan.j.williams@intel.com>
Cc: "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>
Subject: Re: [ndctl PATCH] ndctl: add an API to check support for smart injection
Date: Wed, 11 Jul 2018 21:51:43 +0000	[thread overview]
Message-ID: <1531345901.7574.50.camel@intel.com> (raw)
In-Reply-To: <CAPcyv4hbe2rxPELdB2AmcfwcrzWSmdXDtW-tpn+dHKH7nmptHQ@mail.gmail.com>


On Wed, 2018-07-11 at 14:38 -0700, Dan Williams wrote:
> On Wed, Jul 11, 2018 at 2:17 PM, Vishal Verma <vishal.l.verma@intel.com> wrote:
> > Add an API to check whether smart injection is supported, and add an
> > intel-dsm implementation for it. Use this check in the ndctl
> > inject-smart command.
> > 
> > Reported-by: Leszek Lugin <leszek.lugin@intel.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> 
> [..]
> > +static int intel_dimm_smart_inject_supported(struct ndctl_dimm *dimm)
> > +{
> > +       struct ndctl_ctx *ctx = ndctl_dimm_get_ctx(dimm);
> > +
> > +       if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_CALL)) {
> > +               dbg(ctx, "unsupported cmd: %d\n", ND_CMD_CALL);
> > +               return -EOPNOTSUPP;
> > +       }
> > +
> > +       if (test_dimm_dsm(dimm, ND_INTEL_SMART_INJECT_MTEMP) ==
> > +                       DIMM_DSM_UNSUPPORTED ||
> > +                       test_dimm_dsm(dimm, ND_INTEL_SMART_INJECT_SPARE) ==
> > +                       DIMM_DSM_UNSUPPORTED ||
> > +                       test_dimm_dsm(dimm, ND_INTEL_SMART_INJECT_FATAL) ==
> > +                       DIMM_DSM_UNSUPPORTED ||
> > +                       test_dimm_dsm(dimm, ND_INTEL_SMART_INJECT_SHUTDOWN) ==
> > +                       DIMM_DSM_UNSUPPORTED) {
> > +               dbg(ctx, "smart injection functions unsupported\n");
> > +               return -EIO;
> 
> Just a nit on readability. I find it jarring to split the arguments to
> "== "on 2 different lines, especially after Neil Brown made a similar
> observation on my code. The natural read cadence is to grok the "=="
> statement and then move to the next operator on the following line.
> Also, we've thankfully defined DIMM_DSM_UNSUPPORTED as zero, so it
> would be more readable to drop == and do the following with the ||
> operators:
> 
>         if (!test_dimm_dsm(dimm, ND_INTEL_SMART_INJECT_MTEMP)
>                         || !test_dimm_dsm(dimm, ND_INTEL_SMART_INJECT_SPARE)
>                         || !test_dimm_dsm(dimm, ND_INTEL_SMART_INJECT_FATAL)
>                         || !test_dimm_dsm(dimm,
> ND_INTEL_SMART_INJECT_SHUTDOWN)) {

Yes that looks much better. I'll send a v2.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  reply	other threads:[~2018-07-11 21:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-11 21:17 [ndctl PATCH] ndctl: add an API to check support for smart injection Vishal Verma
2018-07-11 21:38 ` Dan Williams
2018-07-11 21:51   ` Verma, Vishal L [this message]
2018-07-11 22:10     ` Verma, Vishal L

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=1531345901.7574.50.camel@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.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 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.