Signed-off-by: Peter 'p2' De Schrijver <[EMAIL PROTECTED]>
---
 drivers/i2c/chips/twl4030-core.c |   41 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/chips/twl4030-core.c b/drivers/i2c/chips/twl4030-core.c
index 9debab4..42d9e4f 100644
--- a/drivers/i2c/chips/twl4030-core.c
+++ b/drivers/i2c/chips/twl4030-core.c
@@ -70,6 +70,12 @@
 #define twl_has_madc() false
 #endif
 
+#ifdef CONFIG_TWL4030_POWER
+#define twl_has_power()        true
+#else
+#define twl_has_power()        false
+#endif
+
 #if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE)
 #define twl_has_rtc()  true
 #else
@@ -838,6 +844,41 @@ static int add_children(struct twl4030_platform_data 
*pdata)
                }
        }
 
+       if (twl_has_power() && pdata->power) {
+               twl = &twl4030_modules[TWL4030_SLAVENUM_NUM3];
+
+               pdev = platform_device_alloc("twl4030_power", -1);
+               if (!pdev) {
+                       pr_debug("%s: can't alloc power dev\n", DRIVER_NAME);
+                       status = -ENOMEM;
+                       goto err;
+               }
+
+               if (status == 0) {
+                       pdev->dev.parent = &twl->client->dev;
+                       status = platform_device_add_data(pdev, pdata->power,
+                                       sizeof(*pdata->power));
+                       if (status < 0) {
+                               platform_device_put(pdev);
+                               dev_dbg(&twl->client->dev,
+                                       "can't add power data, %d\n",
+                                       status);
+                               goto err;
+                       }
+               }
+
+               if (status == 0)
+                       status = platform_device_add(pdev);
+
+               if (status < 0) {
+                       platform_device_put(pdev);
+                       dev_dbg(&twl->client->dev,
+                                       "can't create power dev, %d\n",
+                                       status);
+                       goto err;
+               }
+       }
+
        if (twl_has_rtc()) {
                twl = &twl4030_modules[TWL4030_SLAVENUM_NUM3];
 
-- 
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to