From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1947345AbcBRS4B (ORCPT ); Thu, 18 Feb 2016 13:56:01 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:19103 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946936AbcBRS4A (ORCPT ); Thu, 18 Feb 2016 13:56:00 -0500 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Thu, 18 Feb 2016 10:55:02 -0800 From: Rhyland Klein To: Lee Jones CC: , Rhyland Klein , Laxman Dewangan Subject: [PATCH] mfd: Fix MACRO for commonly declared MFD cell attributes Date: Thu, 18 Feb 2016 13:52:38 -0500 Message-ID: <1455821558-28493-1-git-send-email-rklein@nvidia.com> X-Mailer: git-send-email 1.9.1 X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) \ #define ACPI_MFD_CELL(_name, _res, _pdata, _id, _match) \ - MFD_CELL_ALL(_name, _res, _pdata, _id, NULL, _match) \ + MFD_CELL_ALL(_name, MFD_ARRAY_SIZE((_res)), _res, \ + _pdata, _id, NULL, _match) \ #define MFD_CELL_BASIC(_name, _res, _pdata, _id) \ - MFD_CELL_ALL(_name, _res, _pdata, _id, NULL, NULL) \ + MFD_CELL_ALL(_name, MFD_ARRAY_SIZE((_res)), _res, \ + _pdata, _id, NULL, NULL) \ #define MFD_CELL_NAME(_name) \ - MFD_CELL_ALL(_name, NULL, NULL, 0, NULL, NULL) \ + MFD_CELL_ALL(_name, 0, NULL, NULL, 0, NULL, NULL) \ struct irq_domain; struct property_set; -- 1.9.1