summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorJohannes Zink <j.zink@pengutronix.de>2022-09-22 15:24:10 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-09-26 10:21:53 +0200
commit76c57235435cd309130667f8fa400728ce4bb4e0 (patch)
tree169ecee99cdaf84d9708d4e3cac1581f30c2de43 /common
parentec76c020b9b22f0d7a28ae7a40fe74e867fed26c (diff)
downloadbarebox-76c57235435cd309130667f8fa400728ce4bb4e0.tar.gz
barebox-76c57235435cd309130667f8fa400728ce4bb4e0.tar.xz
USB: gadget: fastboot: introduce optional flag for fastboot partitions
On some boards, some partitions exposed to fastboot may become unavailable under certain circumstances, e.g. if an SD-Card exposed to fastboot is removed. Previously, this lead to an error and the fastboot gadget did not initialize the remaining partitions exposed via fastboot, e.g. an eMMC which usually is permanently soldered on the board. This patch allows to append an optional flag 'o' to the description of a fastboot partition. If this partition is unavailable at the initialization of the fastboot gadget, said partition is skipped, while the remaining available partitions are still exposed. Signed-off-by: Johannes Zink <j.zink@pengutronix.de> Link: https://lore.barebox.org/20220922132410.2653284-1-j.zink@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/fastboot.c8
-rw-r--r--common/file-list.c7
2 files changed, 14 insertions, 1 deletions
diff --git a/common/fastboot.c b/common/fastboot.c
index 72e6ba3c40..ae7f132444 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -95,6 +95,14 @@ static int fastboot_add_partition_variables(struct fastboot *fb,
}
if (ret) {
+ if (fentry->flags & FILE_LIST_FLAG_OPTIONAL) {
+ pr_info("skipping unavailable optional partition %s for fastboot gadget\n",
+ fentry->filename);
+ ret = 0;
+ type = "unavailable";
+ goto out;
+ }
+
if (fentry->flags & FILE_LIST_FLAG_CREATE) {
ret = 0;
type = "file";
diff --git a/common/file-list.c b/common/file-list.c
index 11db7c6e44..1dc7cd8266 100644
--- a/common/file-list.c
+++ b/common/file-list.c
@@ -88,6 +88,9 @@ static int file_list_parse_one(struct file_list *files, const char *partstr, con
case 'u':
flags |= FILE_LIST_FLAG_UBI;
break;
+ case 'o':
+ flags |= FILE_LIST_FLAG_OPTIONAL;
+ break;
default:
pr_err("Unknown flag '%c'\n", *partstr);
return -EINVAL;
@@ -113,7 +116,7 @@ static int file_list_parse_one(struct file_list *files, const char *partstr, con
static const char *flags_to_str(int flags)
{
- static char str[sizeof "srcu"];
+ static char str[sizeof "srcuo"];
char *s = str;;
if (flags & FILE_LIST_FLAG_SAFE)
@@ -124,6 +127,8 @@ static const char *flags_to_str(int flags)
*s++ = 'c';
if (flags & FILE_LIST_FLAG_UBI)
*s++ = 'u';
+ if (flags & FILE_LIST_FLAG_OPTIONAL)
+ *s++ = 'o';
*s = '\0';