]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/i2c/chips/twl4030-core.c
i2c: move twl4030-madc to new registration style
[linux-2.6-omap-h63xx.git] / drivers / i2c / chips / twl4030-core.c
index c9460f754f9dad43fc58b4e814d59c41a9723e03..79d4d828f85e8b8f95c4767c100c69350519a53d 100644 (file)
 #define twl_has_gpio() false
 #endif
 
+#if defined(CONFIG_TWL4030_MADC) || defined(CONFIG_TWL4030_MADC_MODULE)
+#define twl_has_madc() true
+#else
+#define twl_has_madc() false
+#endif
+
 /* Primary Interrupt Handler on TWL4030 Registers */
 
 /* Register Definitions */
@@ -772,6 +778,27 @@ static int add_children(struct twl4030_platform_data *pdata)
                }
        }
 
+       if (twl_has_madc() && pdata->madc) {
+               pdev = platform_device_alloc("twl4030_madc", -1);
+               if (pdev) {
+                       twl = &twl4030_modules[TWL4030_SLAVENUM_NUM2];
+                       pdev->dev.parent = &twl->client->dev;
+                       device_init_wakeup(&pdev->dev, 1);
+                       status = platform_device_add_data(pdev, pdata->madc,
+                                       sizeof(*pdata->madc));
+                       if (status < 0) {
+                               platform_device_put(pdev);
+                               goto err;
+                       }
+                       status = platform_device_add(pdev);
+                       if (status < 0)
+                               platform_device_put(pdev);
+               } else {
+                       status = -ENOMEM;
+                       goto err;
+               }
+       }
+
 err:
        pr_err("failed to add twl4030's children\n");
        return status;