mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mfd: Add WM8350 subdevice registration helper
@ 2008-10-10 10:19 Mark Brown
  0 siblings, 0 replies; only message in thread
From: Mark Brown @ 2008-10-10 10:19 UTC (permalink / raw)
  To: Liam Girdwood, Samuel Ortiz; +Cc: linux-kernel, Mark Brown

Most of the subdevices for the WM8350 code are registered in the same
fashion so factor out the code to do the initial registration.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
This patch applies on top of the previously posted WM8350 patch series
so needs to be merged via the regulator tree too.

 drivers/mfd/wm8350-core.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index c7ae776..d925eb8 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -1130,6 +1130,32 @@ out:
 }
 EXPORT_SYMBOL_GPL(wm8350_create_cache);
 
+/*
+ * Register a client device.  This is non-fatal since there is no need to
+ * fail the entire device init due to a single platform device failing.
+ */
+static void wm8350_client_dev_register(struct wm8350 *wm8350,
+				       const char *name,
+				       struct platform_device **pdev)
+{
+	int ret;
+
+	*pdev = platform_device_alloc(name, -1);
+	if (pdev == NULL) {
+		dev_err(wm8350->dev, "Failed to allocate %s\n", name);
+		return;
+	}
+
+	(*pdev)->dev.parent = wm8350->dev;
+	platform_set_drvdata(*pdev, wm8350);
+	ret = platform_device_add(*pdev);
+	if (ret != 0) {
+		dev_err(wm8350->dev, "Failed to register %s: %d\n", name, ret);
+		platform_device_put(*pdev);
+		*pdev = NULL;
+	}
+}
+
 int wm8350_device_init(struct wm8350 *wm8350, int irq,
 		       struct wm8350_platform_data *pdata)
 {
-- 
1.5.6.5


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-10-10 10:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-10 10:19 [PATCH] mfd: Add WM8350 subdevice registration helper Mark Brown

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®