[PATCH 3/5] mfd: mc13xxx: move to coredevice_initcall
Sascha Hauer
s.hauer at pengutronix.de
Thu May 8 00:31:37 PDT 2014
The PMIC is often a dependency for other devices, so make sure
it's initialized early. While at it, merge the spi/i2c registration
into a single initcall and use IS_ENABLED instead of ifdefs.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/mfd/mc13xxx.c | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/drivers/mfd/mc13xxx.c b/drivers/mfd/mc13xxx.c
index 9842c56..9e86fc3 100644
--- a/drivers/mfd/mc13xxx.c
+++ b/drivers/mfd/mc13xxx.c
@@ -397,7 +397,6 @@ static __maybe_unused struct of_device_id mc13xxx_dt_ids[] = {
{ }
};
-#ifdef CONFIG_I2C
static struct driver_d mc13xxx_i2c_driver = {
.name = "mc13xxx-i2c",
.probe = mc13xxx_probe,
@@ -405,19 +404,30 @@ static struct driver_d mc13xxx_i2c_driver = {
.of_compatible = DRV_OF_COMPAT(mc13xxx_dt_ids),
};
-static int __init mc13xxx_i2c_init(void)
-{
- return i2c_driver_register(&mc13xxx_i2c_driver);
-}
-device_initcall(mc13xxx_i2c_init);
-#endif
-
-#ifdef CONFIG_SPI
static struct driver_d mc13xxx_spi_driver = {
.name = "mc13xxx-spi",
.probe = mc13xxx_probe,
.id_table = mc13xxx_ids,
.of_compatible = DRV_OF_COMPAT(mc13xxx_dt_ids),
};
-device_spi_driver(mc13xxx_spi_driver);
-#endif
+
+static int __init mc13xxx_init(void)
+{
+ int err_spi = 0, err_i2c = 0;
+
+ if (IS_ENABLED(CONFIG_I2C))
+ err_spi = i2c_driver_register(&mc13xxx_i2c_driver);
+
+ if (IS_ENABLED(CONFIG_SPI))
+ err_i2c = spi_driver_register(&mc13xxx_spi_driver);
+
+ if (err_spi)
+ return err_spi;
+
+ if (err_i2c)
+ return err_i2c;
+
+ return 0;
+
+}
+coredevice_initcall(mc13xxx_init);
--
2.0.0.rc0
More information about the barebox
mailing list