[PATCH 14/14] mfd: Add WM8350 subdevice registration helper

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mark Brown
Date: Friday, October 10, 2008 - 7:58 am

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>
---
 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 9a1a0b2..cd1f76e 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

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/13] WM8350 support, Mark Brown, (Mon Oct 6, 5:32 am)
[PATCH 12/13] mfd: Add WM8350 interrupt support, Mark Brown, (Mon Oct 6, 5:38 am)
Re: [PATCH 0/13] WM8350 support, Liam Girdwood, (Fri Oct 10, 7:24 am)
Re: [PATCH 0/13] WM8350 support, Samuel Ortiz, (Fri Oct 10, 7:31 am)
Re: [PATCH 0/13] WM8350 support, Mark Brown, (Fri Oct 10, 7:38 am)
Re: [PATCH 0/13] WM8350 support, Liam Girdwood, (Fri Oct 10, 7:38 am)
Re: [PATCH 0/13] WM8350 support, Liam Girdwood, (Fri Oct 10, 7:45 am)
Re: [PATCH 0/13] WM8350 support, Samuel Ortiz, (Fri Oct 10, 7:48 am)
[PATCH 12/14] mfd: Add WM8350 interrupt support, Mark Brown, (Fri Oct 10, 7:58 am)
[PATCH 14/14] mfd: Add WM8350 subdevice registration helper, Mark Brown, (Fri Oct 10, 7:58 am)
Re: [PATCH 0/13] WM8350 support, Samuel Ortiz, (Sat Oct 11, 7:23 am)