mfd: sh_mobile_sdhi MMC_CAP_MMC_HIGHSPEED support
[safe/jmp/linux-2.6] / drivers / mfd / wm8400-core.c
index 6a0cedb..ecfc8bb 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/bug.h>
 #include <linux/i2c.h>
 #include <linux/kernel.h>
+#include <linux/mfd/core.h>
 #include <linux/mfd/wm8400-private.h>
 #include <linux/mfd/wm8400-audio.h>
 
@@ -239,6 +240,16 @@ void wm8400_reset_codec_reg_cache(struct wm8400 *wm8400)
 }
 EXPORT_SYMBOL_GPL(wm8400_reset_codec_reg_cache);
 
+static int wm8400_register_codec(struct wm8400 *wm8400)
+{
+       struct mfd_cell cell = {
+               .name = "wm8400-codec",
+               .driver_data = wm8400,
+       };
+
+       return mfd_add_devices(wm8400->dev, -1, &cell, 1, NULL, 0);
+}
+
 /*
  * wm8400_init - Generic initialisation
  *
@@ -254,7 +265,7 @@ static int wm8400_init(struct wm8400 *wm8400,
 
        mutex_init(&wm8400->io_lock);
 
-       wm8400->dev->driver_data = wm8400;
+       dev_set_drvdata(wm8400->dev, wm8400);
 
        /* Check that this is actually a WM8400 */
        ret = wm8400->read_dev(wm8400->io_data, WM8400_RESET_ID, 1, &reg);
@@ -296,24 +307,32 @@ static int wm8400_init(struct wm8400 *wm8400,
        reg = (reg & WM8400_CHIP_REV_MASK) >> WM8400_CHIP_REV_SHIFT;
        dev_info(wm8400->dev, "WM8400 revision %x\n", reg);
 
+       ret = wm8400_register_codec(wm8400);
+       if (ret != 0) {
+               dev_err(wm8400->dev, "Failed to register codec\n");
+               goto err_children;
+       }
+
        if (pdata && pdata->platform_init) {
                ret = pdata->platform_init(wm8400->dev);
-               if (ret != 0)
+               if (ret != 0) {
                        dev_err(wm8400->dev, "Platform init failed: %d\n",
                                ret);
+                       goto err_children;
+               }
        } else
                dev_warn(wm8400->dev, "No platform initialisation supplied\n");
 
+       return 0;
+
+err_children:
+       mfd_remove_devices(wm8400->dev);
        return ret;
 }
 
 static void wm8400_release(struct wm8400 *wm8400)
 {
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(wm8400->regulators); i++)
-               if (wm8400->regulators[i].name)
-                       platform_device_unregister(&wm8400->regulators[i]);
+       mfd_remove_devices(wm8400->dev);
 }
 
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
@@ -441,7 +460,7 @@ static int __init wm8400_module_init(void)
 
        return ret;
 }
-module_init(wm8400_module_init);
+subsys_initcall(wm8400_module_init);
 
 static void __exit wm8400_module_exit(void)
 {