diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-05-08 09:14:13 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-05-19 08:36:37 +0200 |
commit | b42bcee8f4bfb36565483e8e681d8132c4c382c4 (patch) | |
tree | 3ecdced1ce01863049af3813079fdff81205e5f5 /drivers/mfd | |
parent | b90e1f70c862e9204ae963523a342e3e6bafc6ee (diff) | |
download | barebox-b42bcee8f4bfb36565483e8e681d8132c4c382c4.tar.gz barebox-b42bcee8f4bfb36565483e8e681d8132c4c382c4.tar.xz |
mfd: mc13xxx: move to coredevice_initcall
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@pengutronix.de>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/mc13xxx.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/drivers/mfd/mc13xxx.c b/drivers/mfd/mc13xxx.c index eabd5c4724..8584df237b 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); |