
Handle the error code returned by cyclic_register() and propagate it, except in case the return code is EALREADY. The cyclic_register() in mmc.c can be called multiple times with the same parameters, and that is not an error, so depend on the cyclic_register() to skip such a repeated registration and consider EALREADY as non-error here.
Signed-off-by: Marek Vasut marek.vasut+renesas@mailbox.org --- Cc: Aaron Williams awilliams@marvell.com Cc: Anatolij Gustschin agust@denx.de Cc: Angelo Dureghello angelo@kernel-space.org Cc: Christian Marangi ansuelsmth@gmail.com Cc: Devarsh Thakkar devarsht@ti.com Cc: Heinrich Schuchardt xypron.glpk@gmx.de Cc: Jaehoon Chung jh80.chung@samsung.com Cc: Michael Polyntsov michael.polyntsov@iopsys.eu Cc: Michael Trimarchi michael@amarulasolutions.com Cc: Nikhil M Jain n-jain1@ti.com Cc: Peng Fan peng.fan@nxp.com Cc: Peter Robinson pbrobinson@gmail.com Cc: Rasmus Villemoes rasmus.villemoes@prevas.dk Cc: Ronald Wahl ronald.wahl@legrand.com Cc: Simon Glass sjg@chromium.org Cc: Stefan Roese sr@denx.de Cc: Tim Harvey tharvey@gateworks.com Cc: Tom Rini trini@konsulko.com Cc: u-boot@lists.denx.de --- drivers/mmc/mmc.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 4ea97974383..9c58d052261 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -3078,11 +3078,17 @@ int mmc_init(struct mmc *mmc) return err; }
- if (CONFIG_IS_ENABLED(CYCLIC, (!mmc->cyclic.func), (NULL))) { - /* Register cyclic function for card detect polling */ - cyclic_register(&mmc->cyclic, mmc_cyclic_cd_poll, 100 * 1000, - mmc->cfg->name); - } + /* Register cyclic function for card detect polling */ + err = cyclic_register(&mmc->cyclic, mmc_cyclic_cd_poll, 100 * 1000, + mmc->cfg->name); + /* + * This cyclic_register() here might be called multiple times, this + * is not a problem in this specific case, because the mmc subsystem + * always registers the same function with the same polling delay, + * so the EALREADY error can be ignored here. + */ + if (err && err == -EALREADY) + err = 0;
return err; } @@ -3091,8 +3097,7 @@ int mmc_deinit(struct mmc *mmc) { u32 caps_filtered;
- if (CONFIG_IS_ENABLED(CYCLIC, (mmc->cyclic.func), (NULL))) - cyclic_unregister(&mmc->cyclic); + cyclic_unregister(&mmc->cyclic);
if (!CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) && !CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) &&