[PATCH master 1/6] usb: gadget: implement and use system_partitions_get_null

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



system_partitions_get() clones the system partitions file list and
returns the copy. usb multi gadget code expects disabled gadgets to
have a NULL file list, not an empty one, so fastboot and DFU handle
this case. Add a new system_partitions_get_null helper that can be
used instead. This will be used for USB mass storage gadget as well
in a follow-up commit.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 common/fastboot.c           | 4 +---
 common/usbgadget.c          | 4 +---
 include/system-partitions.h | 8 ++++++++
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/common/fastboot.c b/common/fastboot.c
index 04a8573b4adb..f8ed40c86e00 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -920,9 +920,7 @@ struct file_list *get_fastboot_partitions(void)
 {
 	if (fastboot_partitions && *fastboot_partitions)
 		return file_list_parse_null(fastboot_partitions);
-	if (!system_partitions_empty())
-		return system_partitions_get();
-	return NULL;
+	return system_partitions_get_null();
 }
 
 static int fastboot_globalvars_init(void)
diff --git a/common/usbgadget.c b/common/usbgadget.c
index e8c9f7d236d3..92e486199556 100644
--- a/common/usbgadget.c
+++ b/common/usbgadget.c
@@ -27,9 +27,7 @@ static inline struct file_list *get_dfu_function(void)
 {
 	if (dfu_function && *dfu_function)
 		return file_list_parse_null(dfu_function);
-	if (!system_partitions_empty())
-		return system_partitions_get();
-	return NULL;
+	return system_partitions_get_null();
 }
 
 int usbgadget_register(const struct usbgadget_funcs *funcs)
diff --git a/include/system-partitions.h b/include/system-partitions.h
index 86de3612ccd8..e6d1a0f88bf3 100644
--- a/include/system-partitions.h
+++ b/include/system-partitions.h
@@ -2,6 +2,7 @@
 #ifndef SYSTEM_PARTITIONS_H_
 #define SYSTEM_PARTITIONS_H_
 
+#include <linux/types.h>
 #include <file-list.h>
 
 #ifdef CONFIG_SYSTEM_PARTITIONS
@@ -37,4 +38,11 @@ static inline bool system_partitions_empty(void)
 
 #endif
 
+static inline struct file_list *system_partitions_get_null(void)
+{
+	if (system_partitions_empty())
+		return NULL;
+	return system_partitions_get();
+}
+
 #endif
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux