aboutsummaryrefslogtreecommitdiff
path: root/drivers/mmc/mmc_legacy.c
diff options
context:
space:
mode:
authorEzequiel Garcia2019-05-25 19:25:22 -0300
committerTom Rini2019-07-13 11:11:26 -0400
commitd66fb5b1f6662a8aa5f78994696994c2594dbb22 (patch)
tree8aca15fa6816e8b283ecf04caf4af04b0b8d5387 /drivers/mmc/mmc_legacy.c
parentbf7c01d92b8458524190f585b20748f470bc9418 (diff)
mmc: Register only the first MMC device on MMC_TINY
When MMC_TINY is enabled, support for only one MMC device is provided. Boards that register more than one device, will just write over mmc_static keeping only the last one registered. This commit prevents this, keeping only the first MMC device created. A debug warning message is added, if nothing else, as a hint/documentation for developers. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Diffstat (limited to 'drivers/mmc/mmc_legacy.c')
-rw-r--r--drivers/mmc/mmc_legacy.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/mmc/mmc_legacy.c b/drivers/mmc/mmc_legacy.c
index 66a7cda440c..b0f5cf58a2b 100644
--- a/drivers/mmc/mmc_legacy.c
+++ b/drivers/mmc/mmc_legacy.c
@@ -150,6 +150,15 @@ struct mmc *mmc_create(const struct mmc_config *cfg, void *priv)
{
struct mmc *mmc = &mmc_static;
+ /* First MMC device registered, fail to register a new one.
+ * Given users are not expecting this to fail, instead
+ * of failing let's just return the only MMC device
+ */
+ if (mmc->cfg) {
+ debug("Warning: MMC_TINY doesn't support multiple MMC devices\n");
+ return mmc;
+ }
+
mmc->cfg = cfg;
mmc->priv = priv;