From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752582AbcF2AjJ (ORCPT ); Tue, 28 Jun 2016 20:39:09 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34077 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752440AbcF2AjG (ORCPT ); Tue, 28 Jun 2016 20:39:06 -0400 Date: Wed, 29 Jun 2016 10:38:52 +1000 From: Suraj Jitindar Singh To: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, robh@kernel.org, arnd@arndb.de, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, paulus@samba.org Subject: Re: [V4, 2/3] powerpc/opal: Add #define to get rc from an ASYNC_COMP opal_msg Message-ID: <20160629103852.17ffdd59@dyn253.ozlabs.ibm.com> In-Reply-To: <3rf48446rPz9sD5@ozlabs.org> References: <1467088857-14477-2-git-send-email-sjitindarsingh@gmail.com> <3rf48446rPz9sD5@ozlabs.org> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.29; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Jun 2016 21:58:28 +1000 (AEST) Michael Ellerman wrote: > 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. Will move this > > > 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 Thanks, will change this