From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754310AbcA3JzL (ORCPT ); Sat, 30 Jan 2016 04:55:11 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:11403 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752908AbcA3JzH (ORCPT ); Sat, 30 Jan 2016 04:55:07 -0500 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Sat, 30 Jan 2016 01:55:31 -0800 From: Laxman Dewangan To: CC: , Laxman Dewangan Subject: [PATCH V2] mfd: core: add macro for adding mfd cells Date: Sat, 30 Jan 2016 15:13:53 +0530 Message-ID: <1454147034-17677-1-git-send-email-ldewangan@nvidia.com> X-Mailer: git-send-email 2.1.4 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 Most of MFD drivers add the mfd sub devices cells as follows: static const struct mfd_cell as3722_devs[] = { { .name = "as3722-pinctrl", }, { .name = "as3722-regulator", }, { .name = "as3722-rtc", .num_resources = ARRAY_SIZE(as3722_rtc_resource), .resources = as3722_rtc_resource, }, { .name = "as3722-adc", .num_resources = ARRAY_SIZE(as3722_adc_resource), .resources = as3722_adc_resource, }, }; Add defines for adding mfd cells so that it can be done in single line as follows: static const struct mfd_cell as3722_devs[] = { DEFINE_MFD_CELL_NAME("as3722-pinctrl"), DEFINE_MFD_CELL_NAME("as3722-regulator"), DEFINE_MFD_CELL_NAME_RESOURCE("as3722-rtc", as3722_rtc_resource), DEFINE_MFD_CELL_NAME_RESOURCE("as3722-adc", as3722_adc_resource), }; Signed-off-by: Laxman Dewangan --- I am sending this patch based on review comment recived on max77620 mfd patch to use/add macro whereever possible. Once this is reviewed and agreed, I will post series of mfd patches to use this macro. Changes from V1: - Missing "_" from argument name which was causing the compilation issue. - This is found when using both macro. include/linux/mfd/core.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index bc6f7e0..3fa4ab7 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h @@ -14,6 +14,7 @@ #ifndef MFD_CORE_H #define MFD_CORE_H +#include #include struct irq_domain; @@ -81,6 +82,20 @@ struct mfd_cell { int num_parent_supplies; }; +/* Defne mfd cells with name and resource */ +#define DEFINE_MFD_CELL_NAME_RESOURCE(_name, _res) \ + { \ + .name = (_name), \ + .num_resources = ARRAY_SIZE((_res)), \ + .resources = (_res), \ + } + +/* Defne mfd cells with name */ +#define DEFINE_MFD_CELL_NAME(_name) \ + { \ + .name = (_name), \ + } + /* * Convenience functions for clients using shared cells. Refcounting * happens automatically, with the cell's enable/disable callbacks -- 2.1.4