diff mbox series

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

Message ID 1526288948-24977-11-git-send-email-alex.kiernan@gmail.com
State Superseded
Delegated to: Joe Hershberger
Headers show
Series Add fastboot UDP support | expand

Commit Message

Alex Kiernan May 14, 2018, 9:09 a.m. UTC
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@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(-)

Comments

Simon Glass May 14, 2018, 7:52 p.m. UTC | #1
Hi,

On 14 May 2018 at 03:09, Alex Kiernan <alex.kiernan@gmail.com> wrote:
> 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@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(-)

Can you please add this to string.h instead? We are trying to reduce /
remove common.h

Regards,
Simon
Alex Kiernan May 14, 2018, 8:39 p.m. UTC | #2
On Mon, May 14, 2018 at 8:53 PM Simon Glass <sjg@chromium.org> wrote:

> Hi,

> On 14 May 2018 at 03:09, Alex Kiernan <alex.kiernan@gmail.com> wrote:
> > 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@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(-)

> Can you please add this to string.h instead? We are trying to reduce /
> remove common.h


When I was looking through the size changes, I realised that by the time I
was done I'd removed this completely, so I'll just drop it altogether.
diff mbox series

Patch

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)