[U-Boot] [PATCH v3 10/13] fastboot: Extract common definitions from USB fastboot

Alex Kiernan alex.kiernan at gmail.com
Mon May 14 09:09:05 UTC 2018


Move strcmp_l1() to include/common.h so we can can call it from elsewhere.
Move FASTBOOT_VERSION to include/fastboot.h so when we merge the UDP code
we only have one definition.

Signed-off-by: Alex Kiernan <alex.kiernan at gmail.com>
---

Changes in v3:
- new

Changes in v2: None

 drivers/usb/gadget/f_fastboot.c | 10 ----------
 include/common.h                | 13 +++++++++++++
 include/fastboot.h              |  2 ++
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 697eee5..ad76351 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -27,8 +27,6 @@
 #include <fb_nand.h>
 #endif
 
-#define FASTBOOT_VERSION		"0.4"
-
 #define FASTBOOT_INTERFACE_CLASS	0xff
 #define FASTBOOT_INTERFACE_SUB_CLASS	0x42
 #define FASTBOOT_INTERFACE_PROTOCOL	0x03
@@ -147,7 +145,6 @@ static struct usb_gadget_strings *fastboot_strings[] = {
 };
 
 static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
-static int strcmp_l1(const char *s1, const char *s2);
 
 static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
 {
@@ -370,13 +367,6 @@ static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
 	fastboot_tx_write_str("OKAY");
 }
 
-static int strcmp_l1(const char *s1, const char *s2)
-{
-	if (!s1 || !s2)
-		return -1;
-	return strncmp(s1, s2, strlen(s1));
-}
-
 static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
 {
 	char *cmd = req->buf;
diff --git a/include/common.h b/include/common.h
index 60c7913..5ba111d 100644
--- a/include/common.h
+++ b/include/common.h
@@ -524,6 +524,19 @@ static inline struct in_addr env_get_ip(char *var)
 
 int	pcmcia_init (void);
 
+/**
+ * Compare strings over the length of s1
+ *
+ * @param s1		Pointer to string which limits the comparison
+ * @param s2		Second string
+ */
+static inline int strcmp_l1(const char *s1, const char *s2)
+{
+	if (!s1 || !s2)
+		return -1;
+	return strncmp(s1, s2, strlen(s1));
+}
+
 #ifdef CONFIG_LED_STATUS
 # include <status_led.h>
 #endif
diff --git a/include/fastboot.h b/include/fastboot.h
index f2ef51c..593e6a7 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -12,6 +12,8 @@
 #ifndef _FASTBOOT_H_
 #define _FASTBOOT_H_
 
+#define FASTBOOT_VERSION	"0.4"
+
 /* The 64 defined bytes plus \0 */
 #define FASTBOOT_RESPONSE_LEN	(64 + 1)
 
-- 
2.7.4



More information about the U-Boot mailing list