[PATCH 3/3] dm: mmc: fix driver rebinding in the case of dtb reloading
Caleb Connolly
caleb.connolly at linaro.org
Fri Jun 28 01:57:46 CEST 2024
Hi Mikhail,
On 27/06/2024 13:35, Mikhail Kshevetskiy wrote:
> Rebinding of the mmc driver causes reregistration of block device.
> Thus second mmc device appears and the first becomes broken.
>
> Fix an issue by using already registered block device instead of
> registering a new one.
>
> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy at iopsys.eu>
> ---
> drivers/mmc/mmc-uclass.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
> index 24170c59ecc..403d20dad53 100644
> --- a/drivers/mmc/mmc-uclass.c
> +++ b/drivers/mmc/mmc-uclass.c
> @@ -420,11 +420,17 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
> /* Use the fixed index with aliases node's index */
> debug("%s: alias devnum=%d\n", __func__, dev_seq(dev));
>
> - ret = blk_create_devicef(dev, "mmc_blk", "blk", UCLASS_MMC,
> - dev_seq(dev), DEFAULT_BLKSZ, 0, &bdev);
> - if (ret) {
> - debug("Cannot create block device\n");
> - return ret;
> +#if CONFIG_IS_ENABLED(MULTI_DTB_FIT_RESCAN)
> + device_find_first_child_by_uclass(dev, UCLASS_BLK, &bdev);
> + if (!bdev)
What about boards with multiple block devices (e.g. ufs + sdcard or mmc
+ sdcard)?
> +#endif
> + {
> + ret = blk_create_devicef(dev, "mmc_blk", "blk", UCLASS_MMC,
> + dev_seq(dev), DEFAULT_BLKSZ, 0, &bdev);
> + if (ret) {
> + debug("Cannot create block device\n");
> + return ret;
> + }
> }
> bdesc = dev_get_uclass_plat(bdev);
> mmc->cfg = cfg;
--
// Caleb (they/them)
More information about the U-Boot
mailing list