[PATCH 07/12] usbgadget: fastboot: Use function to find file_list entry by name

Sascha Hauer s.hauer at pengutronix.de
Wed Sep 27 05:09:05 PDT 2017


We have file_list_entry_by_name() now, so use it rather than open
coding it.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/usb/gadget/f_fastboot.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 598637619d..0f2c02ee47 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -679,18 +679,15 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd
 
 	fastboot_tx_print(f_fb, "INFOCopying file to %s...", cmd);
 
-	file_list_for_each_entry(f_fb->files, fentry) {
-		if (!strcmp(cmd, fentry->name)) {
-			filename = fentry->filename;
-			break;
-		}
-	}
+	fentry = file_list_entry_by_name(f_fb->files, cmd);
 
-	if (!filename) {
+	if (!fentry) {
 		fastboot_tx_print(f_fb, "FAILNo such partition: %s", cmd);
 		return;
 	}
 
+	filename = fentry->filename;
+
 	if (filetype == filetype_ubi) {
 		int fd;
 		struct mtd_info_user meminfo;
-- 
2.11.0




More information about the barebox mailing list