[PATCH] mmc: Simplify poll CD logic in case cyclic framework is enabled

Simplify 90cc07fd786d ("mmc: Poll CD in case cyclic framework is enabled") according to suggestions by Rasmus. The struct cyclic_info is zero-size in case CONFIG_CYCLIC is not enabled and does not add any size to struct mmc, so it can unconditionally be part of that structure. This allows clean up of all the other conditionals in mmc.c which can now be unconditionally present, as they also add no extra space.
Suggested-by: Rasmus Villemoes ravi@prevas.dk Signed-off-by: Marek Vasut marek.vasut+renesas@mailbox.org --- Cc: Heinrich Schuchardt xypron.glpk@gmx.de Cc: Jaehoon Chung jh80.chung@samsung.com Cc: Jonas Karlman jonas@kwiboo.se Cc: Kever Yang kever.yang@rock-chips.com Cc: Peng Fan peng.fan@nxp.com Cc: Quentin Schulz quentin.schulz@cherry.de Cc: Ronald Wahl ronald.wahl@legrand.com Cc: Simon Glass sjg@chromium.org Cc: Tim Harvey tharvey@gateworks.com Cc: Tom Rini trini@konsulko.com Cc: Venkatesh Yadav Abbarapu venkatesh.abbarapu@amd.com Cc: u-boot@lists.denx.de --- drivers/mmc/mmc.c | 10 ++++------ include/mmc.h | 6 +++++- 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 799586891af..821abc7dd66 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -3042,7 +3042,7 @@ static int mmc_complete_init(struct mmc *mmc)
static void __maybe_unused mmc_cyclic_cd_poll(struct cyclic_info *c) { - struct mmc *m = CONFIG_IS_ENABLED(CYCLIC, (container_of(c, struct mmc, cyclic)), (NULL)); + struct mmc *m = container_of(c, struct mmc, cyclic);
if (!m->has_init) return; @@ -3078,10 +3078,8 @@ int mmc_init(struct mmc *mmc)
if (CONFIG_IS_ENABLED(CYCLIC, (!mmc->cyclic.func), (NULL))) { /* Register cyclic function for card detect polling */ - CONFIG_IS_ENABLED(CYCLIC, (cyclic_register(&mmc->cyclic, - mmc_cyclic_cd_poll, - 100 * 1000, - mmc->cfg->name))); + cyclic_register(&mmc->cyclic, mmc_cyclic_cd_poll, 100 * 1000, + mmc->cfg->name); }
return err; @@ -3092,7 +3090,7 @@ int mmc_deinit(struct mmc *mmc) u32 caps_filtered;
if (CONFIG_IS_ENABLED(CYCLIC, (mmc->cyclic.func), (NULL))) - CONFIG_IS_ENABLED(CYCLIC, (cyclic_unregister(&mmc->cyclic))); + cyclic_unregister(&mmc->cyclic);
if (!CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) && !CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) && diff --git a/include/mmc.h b/include/mmc.h index e4b960b7294..c6ed25db728 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -759,7 +759,11 @@ struct mmc {
enum bus_mode user_speed_mode; /* input speed mode from user */
- CONFIG_IS_ENABLED(CYCLIC, (struct cyclic_info cyclic)); + /* + * If CONFIG_CYCLIC is not set, struct cyclic_info is + * zero-size structure and does not add any space here. + */ + struct cyclic_info cyclic; };
#if CONFIG_IS_ENABLED(DM_MMC)

On 1/18/25 4:08 AM, Marek Vasut wrote:
Simplify 90cc07fd786d ("mmc: Poll CD in case cyclic framework is enabled") according to suggestions by Rasmus. The struct cyclic_info is zero-size in case CONFIG_CYCLIC is not enabled and does not add any size to struct mmc, so it can unconditionally be part of that structure. This allows clean up of all the other conditionals in mmc.c which can now be unconditionally present, as they also add no extra space.
Please ignore v1 and review v2, I forgot to drop the __maybe_unused , fixed in V2 .
participants (2)
-
Marek Vasut
-
Marek Vasut