From 9e4f4fe5ec1a7d6df5eceae0da33c24b753e34d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 25 Jul 2023 16:17:25 +0200 Subject: [PATCH] mmc: core: propagate removable attribute to driver core MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Userspace can use this to distinguish hotpluggable mmc devices such as sdcards from non-hotpluggable ones such as eMMC. One example is the lsblk tool from util-linux. Note that dev_set_removable() is not related to GENHD_FL_REMOVABLE which is not applicable as per the comment in drivers/mmc/core/block.c Link: https://github.com/util-linux/util-linux/issues/2379 Signed-off-by: Thomas Weißschuh Reviewed-by: Avri Altman Link: https://lore.kernel.org/r/20230725-mmc-removable-v1-1-b2e0c4f18e6d@weissschuh.net Signed-off-by: Ulf Hansson --- drivers/mmc/core/bus.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 2c3074a605fc4..0af96548e7da2 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -310,6 +310,9 @@ int mmc_add_card(struct mmc_card *card) dev_set_name(&card->dev, "%s:%04x", mmc_hostname(card->host), card->rca); + dev_set_removable(&card->dev, + mmc_card_is_removable(card->host) ? + DEVICE_REMOVABLE : DEVICE_FIXED); switch (card->type) { case MMC_TYPE_MMC: -- 2.30.2