From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] fixup! environment: prefer non-removable over removable devices for autoprobe
Date: Mon, 8 Dec 2025 11:32:29 +0100 [thread overview]
Message-ID: <20251208103229.4130820-1-a.fatoum@pengutronix.de> (raw)
Instead of ad-hoc determination in an inline function in the header, let
every user decide for itself, it the device is removable or not.
This changes the implementation slightly: SD-Cards with the
non-removable device tree property are now reported as such to the block
layer, whereas before, they were always removable.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/environment.c | 2 +-
drivers/mci/mci-core.c | 4 ++++
drivers/usb/storage/usb.c | 1 +
include/block.h | 12 +-----------
4 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/common/environment.c b/common/environment.c
index d7f5f51cfc6d..0e551c90352e 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -105,7 +105,7 @@ static struct cdev *default_environment_path_search(void)
continue;
/* Prefer eMMC over SD if neither is the boot medium */
- if (blockdevice_is_removable(blk))
+ if (blk->removable)
score += 1;
else
score += 2;
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 206147cb93e2..82864d710417 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2795,6 +2795,10 @@ static int mci_register_partition(struct mci_part *part)
part->blk.type = IS_SD(mci) ? BLK_TYPE_SD : BLK_TYPE_MMC;
part->blk.rootwait = true;
+ part->blk.removable = IS_SD(mci);
+ if (host->non_removable)
+ part->blk.removable = false;
+
if (part->area_type == MMC_BLK_DATA_AREA_RPMB)
return 0;
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index e106174f37d8..b3116dc6e6c2 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -422,6 +422,7 @@ static int usb_stor_add_blkdev(struct us_data *us, unsigned char lun)
pblk_dev->blk.cdev.name = basprintf("disk%d", result);
pblk_dev->blk.blockbits = SECTOR_SHIFT;
pblk_dev->blk.type = BLK_TYPE_USB;
+ pblk_dev->blk.removable = true;
pblk_dev->blk.rootwait = true;
result = blockdevice_register(&pblk_dev->blk);
diff --git a/include/block.h b/include/block.h
index 6810684ff49b..9f388ae67133 100644
--- a/include/block.h
+++ b/include/block.h
@@ -46,6 +46,7 @@ struct block_device {
u8 blockbits;
u8 type; /* holds enum blk_type */
u8 rootwait:1;
+ u8 removable:1;
blkcnt_t num_blocks;
int rdbufsize;
int blkmask;
@@ -82,17 +83,6 @@ static inline int block_flush(struct block_device *blk)
return cdev_flush(&blk->cdev);
}
-static inline bool blockdevice_is_removable(struct block_device *blk)
-{
- switch (blk->type) {
- case BLK_TYPE_USB:
- case BLK_TYPE_SD:
- return true;
- default:
- return false;
- }
-}
-
#ifdef CONFIG_BLOCK
unsigned file_list_add_blockdevs(struct file_list *files);
char *cdev_get_linux_rootarg(const struct cdev *partcdev);
--
2.47.3
next reply other threads:[~2025-12-08 10:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 10:32 Ahmad Fatoum [this message]
2025-12-08 12:11 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251208103229.4130820-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox