From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424782AbdD1IQf (ORCPT ); Fri, 28 Apr 2017 04:16:35 -0400 Received: from mail-io0-f177.google.com ([209.85.223.177]:34785 "EHLO mail-io0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756145AbdD1IQY (ORCPT ); Fri, 28 Apr 2017 04:16:24 -0400 MIME-Version: 1.0 In-Reply-To: <1493281194-5200-3-git-send-email-jacopo+renesas@jmondi.org> References: <1493281194-5200-1-git-send-email-jacopo+renesas@jmondi.org> <1493281194-5200-3-git-send-email-jacopo+renesas@jmondi.org> From: Linus Walleij Date: Fri, 28 Apr 2017 10:16:22 +0200 Message-ID: Subject: Re: [PATCH v5 02/10] pinctrl: generic: Add macros to unpack properties To: Jacopo Mondi Cc: Geert Uytterhoeven , Laurent Pinchart , Chris Brandt , Rob Herring , Mark Rutland , Russell King , Linux-Renesas , "linux-gpio@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 27, 2017 at 10:19 AM, Jacopo Mondi wrote: > Add PIN_CONF_UNPACK_PARAM and PIN_CONF_UNPACK_ARGS macros useful to > unpack generic properties and their arguments > > Signed-off-by: Jacopo Mondi (...) /* * Helpful configuration macro to be used in tables etc. Then this should say "macros" rather than "macro". > -#define PIN_CONF_PACKED(p, a) ((a << 8) | ((unsigned long) p & 0xffUL)) > +#define PIN_CONF_PACKED(p, a) (((a) << 8) | ((unsigned long) (p) & 0xffUL)) Also adding some extra parantheses I see. > +#define PIN_CONF_UNPACK_PARAM(c) ((c) & 0xffUL) > +#define PIN_CONF_UNPACK_ARGS(c) ((c) >> 8) But why. I have these two static inlines just below your new macros: static inline enum pin_config_param pinconf_to_config_param(unsigned long config) { return (enum pin_config_param) (config & 0xffUL); } static inline u32 pinconf_to_config_argument(unsigned long config) { return (u32) ((config >> 8) & 0xffffffUL); } Why can't you use this in your code instead of macros? We generally prefer static inlines over macros because they are easier to read. Yours, Linus Walleij