[PATCH] usb: gadget: ums: add support for optional partition flag

Ahmad Fatoum a.fatoum at pengutronix.de
Sun Apr 14 22:34:30 PDT 2024


File lists for fastboot support a 'o' flag to silently skip files that
don't exist at bind time. Add support for the same for USB mass storage
gadgets as well.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/usb/gadget/function/f_mass_storage.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index 2c934c621a18..e099123cea2b 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -2474,14 +2474,17 @@ static int fsg_common_init(struct fsg_common *common,
 		struct stat st;
 		int fd;
 
-		if (fentry->flags) {
-			pr_err("flags not supported\n");
-			rc = -ENOSYS;
-			goto close;
-		}
+		if (fentry->flags & ~FILE_LIST_FLAG_OPTIONAL)
+			pr_warn("some flags will be ignored\n");
 
 		fd = open(fentry->filename, flags);
 		if (fd < 0) {
+			if (fentry->flags & FILE_LIST_FLAG_OPTIONAL) {
+				pr_info("skipping unavailable optional partition %s\n",
+					fentry->filename);
+				continue;
+			}
+
 			pr_err("open('%s') failed: %pe\n",
 			       fentry->filename, ERR_PTR(fd));
 			rc = fd;
-- 
2.39.2




More information about the barebox mailing list