devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: linuxppc-dev@lists.ozlabs.org
Cc: robh@kernel.org, arnd@arndb.de, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, paulus@samba.org,
	sjitindarsingh@gmail.com
Subject: Re: [V4, 2/3] powerpc/opal: Add #define to get rc from an ASYNC_COMP opal_msg
Date: Tue, 28 Jun 2016 21:58:28 +1000 (AEST)	[thread overview]
Message-ID: <3rf48446rPz9sD5@ozlabs.org> (raw)
In-Reply-To: <1467088857-14477-2-git-send-email-sjitindarsingh@gmail.com>

On Tue, 2016-28-06 at 04:40:56 UTC, Suraj Jitindar Singh wrote:
> An opal_msg of type OPAL_MSG_ASYNC_COMP contains the return code in the
> params[1] struct member. However this isn't intuitive or obvious when
> reading the code and requires that a user look at the skiboot
> documentation or opal-api.h to verify this.
> 
> Add a #define to get the return code from an opal_msg and update call
> sites accordingly.

Thanks for cleaning this up.

Two gripes though :)

>  arch/powerpc/include/asm/opal-api.h            | 4 ++++

opal-api.h is supposed to be a subset of the skiboot version.

So something like this should go in the kernel's opal.h, which has all the
kernel prototypes etc. which aren't part of the OPAL API. I think this routine
should fall under that.

> diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h
> index 9bb8ddf..7433cf0 100644
> --- a/arch/powerpc/include/asm/opal-api.h
> +++ b/arch/powerpc/include/asm/opal-api.h
> @@ -387,6 +387,10 @@ struct opal_msg {
>  	__be64 params[8];
>  };
>  
> +#define GET_OPAL_MSG_ASYNC_COMP_RC(msg)	(msg.msg_type == OPAL_MSG_ASYNC_COMP ? \
> +					be64_to_cpu(msg.params[1]) : \
> +					OPAL_PARAMETER)
> +

You forgot the 7th commandment!

 "Never use a #define when a static inline would work"

:)

A few reasons:
  - it's less shouty.
  - you get type checking.
  - you don't have to wrap lines with \
    etc.

cheers

  reply	other threads:[~2016-06-28 11:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-28  4:40 [PATCH V4 1/3] devicetree/bindings: Add binding for operator panel on FSP machines Suraj Jitindar Singh
     [not found] ` <1467088857-14477-1-git-send-email-sjitindarsingh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-06-28  4:40   ` [PATCH V4 2/3] powerpc/opal: Add #define to get rc from an ASYNC_COMP opal_msg Suraj Jitindar Singh
2016-06-28 11:58     ` Michael Ellerman [this message]
     [not found]       ` <3rf48446rPz9sD5-mnsaURCQ41sdnm+yROfE0A@public.gmane.org>
2016-06-29  0:38         ` [V4, " Suraj Jitindar Singh
2016-06-28  4:40 ` [PATCH V4 3/3] powerpc/drivers: Add driver for operator panel on FSP machines Suraj Jitindar Singh

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=3rf48446rPz9sD5@ozlabs.org \
    --to=mpe@ellerman.id.au \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=robh@kernel.org \
    --cc=sjitindarsingh@gmail.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 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).