[PATCH 1/5] mfd mc13xxx: Separate I2C and SPI probe

Sascha Hauer s.hauer at pengutronix.de
Tue Sep 11 09:31:49 EDT 2012


Upcoming patches will put I2C/SPI on their own busses with
spi_register_driver / i2c_register_driver which will only
be available if the subsystem is enabled. We could provide
static inlines, but it wouldn't make much sense to compile
a spi/i2c driver if the corresponding subsystem is disabled.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mfd/mc13xxx.c |   28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/mfd/mc13xxx.c b/drivers/mfd/mc13xxx.c
index 704446d..58394a7 100644
--- a/drivers/mfd/mc13xxx.c
+++ b/drivers/mfd/mc13xxx.c
@@ -336,31 +336,39 @@ static int mc_probe(struct device_d *dev, enum mc13xxx_mode mode)
 	return 0;
 }
 
+#ifdef CONFIG_I2C
 static int mc_i2c_probe(struct device_d *dev)
 {
 	return mc_probe(dev, MC13XXX_MODE_I2C);
 }
 
-static int mc_spi_probe(struct device_d *dev)
-{
-	return mc_probe(dev, MC13XXX_MODE_SPI);
-}
-
 static struct driver_d mc_i2c_driver = {
 	.name  = "mc13xxx-i2c",
 	.probe = mc_i2c_probe,
 };
 
+static int mc_i2c_init(void)
+{
+	return register_driver(&mc_i2c_driver);
+}
+device_initcall(mc_i2c_init);
+#endif
+
+#ifdef CONFIG_SPI
+static int mc_spi_probe(struct device_d *dev)
+{
+	return mc_probe(dev, MC13XXX_MODE_SPI);
+}
+
 static struct driver_d mc_spi_driver = {
 	.name  = "mc13xxx-spi",
 	.probe = mc_spi_probe,
 };
 
-static int mc_init(void)
+static int mc_spi_init(void)
 {
-        register_driver(&mc_i2c_driver);
-        register_driver(&mc_spi_driver);
-        return 0;
+	return register_driver(&mc_spi_driver);
 }
 
-device_initcall(mc_init);
+device_initcall(mc_spi_init);
+#endif
-- 
1.7.10.4




More information about the barebox mailing list