mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laxman Dewangan <ldewangan@nvidia.com>
To: <lee.jones@linaro.org>
Cc: <linux-kernel@vger.kernel.org>, Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH] mfd: core: add macro for adding mfd cells
Date: Sat, 30 Jan 2016 12:07:05 +0530	[thread overview]
Message-ID: <1454135825-3660-1-git-send-email-ldewangan@nvidia.com> (raw)

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 <ldewangan@nvidia.com>
---
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.

 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..508e586 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 <linux/kernel.h>
 #include <linux/platform_device.h>
 
 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

                 reply	other threads:[~2016-01-30  6:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454135825-3660-1-git-send-email-ldewangan@nvidia.com \
    --to=ldewangan@nvidia.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®