From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/5] mfd: mc13xxx: move to coredevice_initcall
Date: Thu, 8 May 2014 09:31:37 +0200 [thread overview]
Message-ID: <1399534299-27051-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1399534299-27051-1-git-send-email-s.hauer@pengutronix.de>
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>
---
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
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-05-08 7:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-08 7:31 [PATCH] fix i.MX51 babbage ethernet Sascha Hauer
2014-05-08 7:31 ` [PATCH 1/5] mfd: mc13xxx: Allow to set callback for mc13xxx Sascha Hauer
2014-05-18 23:14 ` Marc Reilly
2014-05-19 6:40 ` Sascha Hauer
2014-05-08 7:31 ` [PATCH 2/5] spi: i.MX: Move to coredevice_initcall Sascha Hauer
2014-05-11 18:49 ` Alexander Shiyan
2014-05-12 10:38 ` Sascha Hauer
2014-05-14 17:57 ` Alexander Shiyan
2014-05-19 8:47 ` Sascha Hauer
2014-05-08 7:31 ` Sascha Hauer [this message]
2014-05-08 7:31 ` [PATCH 4/5] ARM: i.MX51 babbage: use mc13xxx_register_callback to initialize PMIC Sascha Hauer
2014-05-08 7:31 ` [PATCH 5/5] ARM: dts: i.MX51 babbage: overwrite upstream FEC iomux settings Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399534299-27051-4-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox