mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] efi: loader: disk: detect the file system type only once
Date: Mon, 31 Aug 2026 16:55:23 +0200	[thread overview]
Message-ID: <20260831145524.1041308-1-a.fatoum@pengutronix.de> (raw)

From: Ahmad Fatoum <a.fatoum@barebox.org>

efi_fs_exists() calls cdev_detect_type() once per file system driver,
reading the first FILE_TYPE_SAFE_BUFSIZE bytes off the device each time.
Run cdev_detect_type() once and then match the result against the drivers.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 efi/loader/protocols/disk.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/efi/loader/protocols/disk.c b/efi/loader/protocols/disk.c
index 5376c9ec9a14..493be8c5aafe 100644
--- a/efi/loader/protocols/disk.c
+++ b/efi/loader/protocols/disk.c
@@ -160,16 +160,14 @@ efi_fs_from_path(struct efi_device_path *full_path)
 
 static bool efi_fs_exists(struct cdev *cdev)
 {
+	enum filetype filetype;
 	struct driver *drv;
 
+	if (cdev_detect_type(cdev, &filetype))
+		return false;
+
 	bus_for_each_driver(&fs_bus, drv) {
-		struct fs_driver *fdrv;
-		enum filetype filetype;
-
-		fdrv = drv_to_fs_driver(drv);
-
-		if (cdev_detect_type(cdev, &filetype) == 0 &&
-		    filetype == fdrv->type)
+		if (drv_to_fs_driver(drv)->type == filetype)
 			return true;
 	}
 
-- 
2.47.3




                 reply	other threads:[~2026-08-31 14:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260831145524.1041308-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=a.fatoum@barebox.org \
    --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