From patchwork Fri Feb 19 08:50:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 62271 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1038454lbl; Fri, 19 Feb 2016 00:50:27 -0800 (PST) X-Received: by 10.98.79.156 with SMTP id f28mr16491922pfj.55.1455871827705; Fri, 19 Feb 2016 00:50:27 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l28si15316210pfb.54.2016.02.19.00.50.26; Fri, 19 Feb 2016 00:50:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1427320AbcBSIuZ (ORCPT + 30 others); Fri, 19 Feb 2016 03:50:25 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:33773 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754311AbcBSIuX (ORCPT ); Fri, 19 Feb 2016 03:50:23 -0500 Received: by mail-wm0-f45.google.com with SMTP id g62so59141539wme.0 for ; Fri, 19 Feb 2016 00:50:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=IJ4EjkRsDkLQD7KRpkIXBUFpF964vsnJ4a9SizUlvwU=; b=LkT5SUKIcA76oh5dIYb2P4AICzMHwL3zTtJyv3LS7r1OlsvsPfLnDSi5PfEww8kfwU lVshoKdCJKXgAGHBZfaoJF3Hb4cSym+w5qeXCP+ZBSo2IbuS4Z+XfIav7mVcFCfJhSCO gcIfZiuBPQGAkN+qW5KFE3QDA2Rg2kE197taE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=IJ4EjkRsDkLQD7KRpkIXBUFpF964vsnJ4a9SizUlvwU=; b=DD+gdgtSpd2hUzLC51l/RAsVLjJaMX4V2KBSE7MEPRh9EQaiaE4Kk4QingZDlX9cIA jmezZvtNxYF60cI8df1u8AYPvIgzndcdilNTuATwG1L6WFqSVTZ7V7qKtlnw0YF8omIo qli2hd4ZMRfboBTVmvT065ZWphC43M0lziTBZ58kcuZRlWBdDY7FgjnqRJ+CCuAKGEFG HB2NWNZNJ9zdkdfTDQq5/r3EtYPDjWS6oNH5dypSxw11xnlYwfUVNPAb5/9mBLY0D9R8 wvlv4Le9Q4zjzX91WQxFmxOodMcrJNFRYF8We9+nXfWfECP7FCXqILJ45lvI0z1KIqkf G+vw== X-Gm-Message-State: AG10YOTz/oAIz79ZGeBB/Qwd/RjR+YlVBMbgOZSTQ5lNT2UF96LWIKINBlTGz2PqB3GGy3Hy X-Received: by 10.194.216.2 with SMTP id om2mr11808960wjc.164.1455871822757; Fri, 19 Feb 2016 00:50:22 -0800 (PST) Received: from x1 (host81-154-142-212.range81-154.btcentralplus.com. [81.154.142.212]) by smtp.gmail.com with ESMTPSA id i1sm10119588wjs.45.2016.02.19.00.50.21 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Feb 2016 00:50:21 -0800 (PST) Date: Fri, 19 Feb 2016 08:50:19 +0000 From: Lee Jones To: Rhyland Klein Cc: linux-kernel@vger.kernel.org, Laxman Dewangan Subject: Re: [PATCH] mfd: Fix MACRO for commonly declared MFD cell attributes Message-ID: <20160219085019.GA3410@x1> References: <1455821558-28493-1-git-send-email-rklein@nvidia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1455821558-28493-1-git-send-email-rklein@nvidia.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 Feb 2016, Rhyland Klein wrote: > MFD_ARRAY_SIZE() would not accurately return 0 if the passed > parameter was NULL. Fix this so that num_resources will > accurately be 0 in the case that _res is NULL. > > cc: Lee Jones > cc: Laxman Dewangan > Signed-off-by: Rhyland Klein > --- > include/linux/mfd/core.h | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h > index 1a5a87f3cd38..62136ccff1df 100644 > --- a/include/linux/mfd/core.h > +++ b/include/linux/mfd/core.h > @@ -18,11 +18,11 @@ > > #define MFD_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) > > -#define MFD_CELL_ALL(_name, _res, _pdata, _id, _compat, _match) \ > +#define MFD_CELL_ALL(_name, _nres, _res, _pdata, _id, _compat, _match) \ > { \ > .name = (_name), \ > .resources = (_res), \ > - .num_resources = MFD_ARRAY_SIZE((_res)), \ > + .num_resources = (_nres), \ > .platform_data = (_pdata), \ > .pdata_size = MFD_ARRAY_SIZE((_pdata)), \ > .of_compatible = (_compat), \ > @@ -31,16 +31,19 @@ > } > > #define OF_MFD_CELL(_name, _res, _pdata, _id, _compat) \ > - MFD_CELL_ALL(_name, _res, _pdata, _id, _compat, NULL) \ > + MFD_CELL_ALL(_name, MFD_ARRAY_SIZE((_res)), _res, \ > + _pdata, _id, _compat, NULL) \ I'm confused. Why would it be any different just by changing the call site of MFD_ARRAY_SIZE? And what about .platform_data? How about this change instead? -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index 1a5a87f..8440f42 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h @@ -16,7 +16,7 @@ #include -#define MFD_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#define MFD_ARRAY_SIZE(arr) (arr ? (sizeof(arr) / sizeof((arr)[0])) : 0) #define MFD_CELL_ALL(_name, _res, _pdata, _id, _compat, _match) \ { \