From: Simon Glass Date: Sun, 16 Feb 2025 12:55:59 +0000 (-0700) Subject: mmc: Avoid uniniting twice X-Git-Tag: v2025.07-rc1~81^2~1 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d99f8d2d749c0e1b352766281f5f5d71fa845f76;p=pandora-u-boot.git mmc: Avoid uniniting twice Each MMC device has a child which ihs a block device. At present we call mmc_deinit() when the block device is removed. But the MMC struct (i.e. struct mmc) is attached to the MMC's device, not its child. So at present, when an MMC device is removed, mmc_deinit() is called twice, once for the MMC device and once for its block device. This results in a double call to cyclic_unregister(). Fix this by adding a 'remove' method to the uclass and calling mmc_deinit() from there. Also drop the call to device_probe() within the block-device's probe() method. The device is already in the process of being probed, so this call does nothing. Signed-off-by: Simon Glass Fixes: c822c1a50bd ("mmc: call device_probe() after scanning") Signed-off-by: Peng Fan --- diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index c8db4f811c2..9af84da1599 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -498,22 +498,12 @@ static int mmc_blk_probe(struct udevice *dev) return ret; } - ret = device_probe(dev); - if (ret) { - debug("Probing %s failed (err=%d)\n", dev->name, ret); - - mmc_deinit(mmc); - - return ret; - } - return 0; } -static int mmc_blk_remove(struct udevice *dev) +static int mmc_remove(struct udevice *dev) { - struct udevice *mmc_dev = dev_get_parent(dev); - struct mmc_uclass_priv *upriv = dev_get_uclass_priv(mmc_dev); + struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct mmc *mmc = upriv->mmc; return mmc_deinit(mmc); @@ -533,7 +523,6 @@ U_BOOT_DRIVER(mmc_blk) = { .id = UCLASS_BLK, .ops = &mmc_blk_ops, .probe = mmc_blk_probe, - .remove = mmc_blk_remove, .flags = DM_FLAG_OS_PREPARE, }; #endif /* CONFIG_BLK */ @@ -543,4 +532,5 @@ UCLASS_DRIVER(mmc) = { .name = "mmc", .flags = DM_UC_FLAG_SEQ_ALIAS, .per_device_auto = sizeof(struct mmc_uclass_priv), + .pre_remove = mmc_remove, };