Clean up add_children a bit before adding more children to twl4030-core.c Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxx> --- drivers/i2c/chips/twl4030-core.c | 58 ++++++++++++++++++++----------------- include/linux/i2c/twl4030.h | 6 ++++ 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/drivers/i2c/chips/twl4030-core.c b/drivers/i2c/chips/twl4030-core.c index 47f65f8..bbffc40 100644 --- a/drivers/i2c/chips/twl4030-core.c +++ b/drivers/i2c/chips/twl4030-core.c @@ -639,34 +639,38 @@ static int add_children(struct twl4030_platform_data *pdata) struct twl4030_client *twl = NULL; int status = 0; -#ifdef CONFIG_RTC_DRV_TWL4030 - pdev = platform_device_alloc("twl4030_rtc", -1); - if (pdev) { - twl = &twl4030_modules[TWL4030_SLAVENUM_NUM3]; - pdev->dev.parent = &twl->client->dev; - device_init_wakeup(&pdev->dev, 1); - - /* - * FIXME add the relevant IRQ resource, and make the - * rtc driver use it instead of hard-wiring ... - * - * REVISIT platform_data here currently only supports - * setting up the "msecure" line ... which actually - * violates the "princple of least privilege", since - * it's effectively always in "high trust" mode. - * - * For now, expect equivalent treatment at board init: - * setting msecure high. Eventually, Linux might - * become more aware of those HW security concerns. - */ - - status = platform_device_add(pdev); - if (status < 0) - platform_device_put(pdev); - } else - status = -ENOMEM; -#endif + if (twl_has_rtc()) { + pdev = platform_device_alloc("twl4030_rtc", -1); + if (pdev) { + twl = &twl4030_modules[TWL4030_SLAVENUM_NUM3]; + pdev->dev.parent = &twl->client->dev; + device_init_wakeup(&pdev->dev, 1); + + /* + * FIXME add the relevant IRQ resource, and make the + * rtc driver use it instead of hard-wiring ... + * + * REVISIT platform_data here currently only supports + * setting up the "msecure" line ... which actually + * violates the "princple of least privilege", since + * it's effectively always in "high trust" mode. + * + * For now, expect equivalent treatment at board init: + * setting msecure high. Eventually, Linux might + * become more aware of those HW security concerns. + */ + + 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; } diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h index 2434ad0..ff1dff4 100644 --- a/include/linux/i2c/twl4030.h +++ b/include/linux/i2c/twl4030.h @@ -145,4 +145,10 @@ int twl4030_free_gpio(int gpio); static inline int twl4030charger_usb_en(int enable) { return 0; } #endif +#if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE) +#define twl_has_rtc() (1) +#else +#define twl_has_rtc() (0) +#endif + #endif /* End of __TWL4030_H */ -- 1.6.0.2.307.gc427 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html