[PATCH v2 2/3] drivers: mmc: uclass: Set removable flag based on device tree property

Casey Connolly casey.connolly at linaro.org
Tue May 5 15:45:49 CEST 2026



On 21/04/2026 15:00, Balaji Selvanathan wrote:
> The block device removable flag should reflect whether the MMC
> device is physically removable (SD card) or soldered (eMMC). This
> information is specified in the device tree via the "non-removable"
> property and stored in the MMC_CAP_NONREMOVABLE capability flag.
> 
> Update the removable flag in the block device descriptor during
> controller probe to properly reflect the device's removable status.
> This allows the block layer and upper layers (particularly EFI boot
> manager) to distinguish between eMMC and SD cards for appropriate
> handling.
> 
> The default removable=1 is set in mmc_bind(), and this change
> overrides it only for non-removable devices after mmc_of_parse()
> has set the MMC_CAP_NONREMOVABLE capability from the device tree.
> 
> Reviewed-by: Varadarajan Narayanan <varadarajan.narayanan at oss.qualcomm.com>
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan at oss.qualcomm.com>
> ---
> Changes in v2:
> - Moved removable flag update from generic mmc-uclass.c to platform-
>   specific msm_sdhci.c driver
> ---
>  drivers/mmc/msm_sdhci.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c
> index 66f3cf2de4f..13fd4ae8a7d 100644
> --- a/drivers/mmc/msm_sdhci.c
> +++ b/drivers/mmc/msm_sdhci.c
> @@ -189,6 +189,7 @@ static int msm_sdc_probe(struct udevice *dev)
>  	struct sdhci_host *host = &prv->host;
>  	u32 core_version, core_minor, core_major;
>  	struct reset_ctl bcr_rst;
> +	struct blk_desc *bdesc;
>  	u32 caps;
>  	int ret;
>  
> @@ -252,6 +253,12 @@ static int msm_sdc_probe(struct udevice *dev)
>  	if (ret)
>  		return ret;
>  
> +	if (plat->cfg.host_caps & MMC_CAP_NONREMOVABLE) {
> +		bdesc = mmc_get_blk_desc(&plat->mmc);
> +		if (bdesc)
> +			bdesc->removable = 0;

Would bdesc ever be null here? Or an ERR_PTR()? Please handle the error
case properly and bail out.

> +	}
> +
>  	host->mmc = &plat->mmc;
>  	host->mmc->dev = dev;
>  	host->ops = &msm_sdhci_ops;
> 

-- 
// Casey (she/her)



More information about the U-Boot mailing list