]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mmc: exynos_dw_mmc: Extend dm_dwmci_ops without code duplication
authorSam Protsenko <semen.protsenko@linaro.org>
Sun, 26 Oct 2025 01:06:53 +0000 (20:06 -0500)
committerPeng Fan <peng.fan@nxp.com>
Fri, 7 Nov 2025 01:28:28 +0000 (09:28 +0800)
Instead of extending dm_dwmci_ops by copy-pasting the structure code
first, copy the actual structure data with memcpy() and then set the
.execute_tuning field. Now if struct dm_dwmci_ops gets modified in
future, these changes will be automatically reflected in struct
exynos_dwmmc_ops, which prevents possible issues in future. It also
avoids code duplication.

No functional change, but it can prevent possible isssues in future.

Fixes: eda4bd29929c ("mmc: exynos_dw_mmc: add support for MMC HS200 and HS400 modes")
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Anand Moon <linux.amoon@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
drivers/mmc/exynos_dw_mmc.c

index b230e9dbbf88c9d84101a7b00cf160acd07d7822..190c6349380d16f2e8cf09b2c9d2f90ab35caad0 100644 (file)
@@ -367,6 +367,8 @@ static int exynos_dwmmc_execute_tuning(struct udevice *dev, u32 opcode)
 }
 #endif
 
+struct dm_mmc_ops exynos_dwmmc_ops;
+
 static int exynos_dwmmc_probe(struct udevice *dev)
 {
        struct exynos_mmc_plat *plat = dev_get_plat(dev);
@@ -376,6 +378,12 @@ static int exynos_dwmmc_probe(struct udevice *dev)
        unsigned long freq;
        int err;
 
+       /* Extend generic 'dm_dwmci_ops' with .execute_tuning implementation */
+       memcpy(&exynos_dwmmc_ops, &dm_dwmci_ops, sizeof(struct dm_mmc_ops));
+#if CONFIG_IS_ENABLED(MMC_SUPPORTS_TUNING)
+       exynos_dwmmc_ops.execute_tuning = exynos_dwmmc_execute_tuning;
+#endif
+
 #ifndef CONFIG_CPU_V7A
        err = clk_get_by_index(dev, 1, &priv->clk); /* ciu */
        if (err)
@@ -480,14 +488,6 @@ static const struct udevice_id exynos_dwmmc_ids[] = {
        { }
 };
 
-struct dm_mmc_ops exynos_dwmmc_ops = {
-       .send_cmd       = dwmci_send_cmd,
-       .set_ios        = dwmci_set_ios,
-#if CONFIG_IS_ENABLED(MMC_SUPPORTS_TUNING)
-       .execute_tuning = exynos_dwmmc_execute_tuning,
-#endif
-};
-
 U_BOOT_DRIVER(exynos_dwmmc_drv) = {
        .name           = "exynos_dwmmc",
        .id             = UCLASS_MMC,