qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Corey Minyard <cminyard@mvista.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] ipmi: add SET_SENSOR_READING command
Date: Fri, 22 Nov 2019 08:28:00 -0600	[thread overview]
Message-ID: <20191122142800.GT3556@minyard.net> (raw)
In-Reply-To: <20191118092429.16149-1-clg@kaod.org>

On Mon, Nov 18, 2019 at 10:24:29AM +0100, Cédric Le Goater wrote:
> SET_SENSOR_READING is a complex IPMI command (see IPMI spec 35.17)
> which enables the host software to set the reading value and the event
> status of sensors supporting it.
> 
> Below is a proposal for all the operations (reading, assert, deassert,
> event data) with the following limitations :
> 
>  - No event are generated for threshold-based sensors.
>  - The case in which the BMC needs to generate its own events is not
>    supported.

Ok, I've included this in my tree.  I made one small change mentioned
below.  Beyond that, I think you could make this function shorter, but I
think that would actually make it harder to understand.  Breaking it
into multiple functions doesn't make sense to me, either.

If you are including this in the ppc tree:

Acked-by: Corey Minyard <cminyard@mvista.com>

with the change below and I can remove it from mine.

> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> Reviewed-by: Corey Minyard <cminyard@mvista.com>
> ---
> +
> +    switch (do_gen_event) {
> +    case SENSOR_GEN_EVENT_DATA: {
> +        unsigned int bit = evd1 & 0xf;
> +        uint16_t mask = (1 << bit);
> +
> +        if (sens->assert_states & mask & sens->assert_enable) {
> +            gen_event(ibs, cmd[2], 0, evd1, evd2, evd3);
> +        }
> +
> +        if (sens->deassert_states & mask & sens->deassert_enable) {
> +            gen_event(ibs, cmd[2], 1, evd1, evd2, evd3);
> +        }
> +    }
> +        break;

I moved this break statement above the brace before it to keep the
indention consistent.  It just screwed with my brain too much :).

I looked and there is nothing in the coding style about this, and I
found this done in three different ways:

  case x: {  /* in vl.c */
      ....
      break;
  }
  case y: /* in thunk.c */
      {
           ....
      }
      break;
  case z: /* In vl.c */
  {
      ....
      break;
  }

Oddly enough, I didn't find anything about this in the Linux coding
style document, either (I was curious).  One could argue, I suppose,
that according to the "Block structure" section in the qemu style and
the similar section in the Linux style that the first is correct,
but then case statements violate the "Every indented statement is
braced" statement in the qemu style.  This has always bugged me in
C, sorry for the diatribe on this.

-corey

> +    case SENSOR_GEN_EVENT_BMC:


  reply	other threads:[~2019-11-22 14:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-18  9:24 [PATCH] ipmi: add SET_SENSOR_READING command Cédric Le Goater
2019-11-22 14:28 ` Corey Minyard [this message]
2019-11-22 15:51   ` Cédric Le Goater

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=20191122142800.GT3556@minyard.net \
    --to=cminyard@mvista.com \
    --cc=clg@kaod.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).