All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH v1 2/5] dfu: Extract fastboot_okay/fail to fb_common.c
Date: Wed, 25 Apr 2018 09:32:20 +0200	[thread overview]
Message-ID: <20180425093220.2112810a@jawa> (raw)
In-Reply-To: <1524562627-5794-3-git-send-email-alex.kiernan@gmail.com>

Hi Alex,

> Added common/fb_common.c, where fastboot_okay/fail are implemented
> so we can call them from a non-USB implementation.
> 
> Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
> ---
> 
>  common/Makefile                 |  4 ++++
>  common/fb_common.c              | 26 ++++++++++++++++++++++++++
>  drivers/usb/gadget/f_fastboot.c | 13 -------------
>  3 files changed, 30 insertions(+), 13 deletions(-)
>  create mode 100644 common/fb_common.c
> 
> diff --git a/common/Makefile b/common/Makefile
> index 7011dad..8177341 100644
> --- a/common/Makefile
> +++ b/common/Makefile
> @@ -124,6 +124,10 @@ endif
>  endif
>  endif
>  
> +ifneq ($(or
> $(CONFIG_USB_FUNCTION_FASTBOOT),$(CONFIG_UDP_FUNCTION_FASTBOOT)),)
> +obj-y += fb_common.o +endif
> +
>  ifdef CONFIG_CMD_EEPROM_LAYOUT
>  obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o
>  endif
> diff --git a/common/fb_common.c b/common/fb_common.c
> new file mode 100644
> index 0000000..53cffe3
> --- /dev/null
> +++ b/common/fb_common.c
> @@ -0,0 +1,26 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * (C) Copyright 2008 - 2009
> + * Windriver, <www.windriver.com>
> + * Tom Rix <Tom.Rix@windriver.com>
> + *
> + * Copyright 2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> + *
> + * Copyright 2014 Linaro, Ltd.
> + * Rob Herring <robh@kernel.org>
> + */
> +
> +#include <common.h>
> +#include <fastboot.h>
> +
> +void fastboot_fail(const char *reason, char *response)
> +{
> +	strncpy(response, "FAIL\0", 5);
> +	strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
				  ^^^^^^^ This looks a bit
				  "hand-crafted". I suppose that it is
				  to prevent not adding "reason" when
				  response is large ?
> +}
> +
> +void fastboot_okay(const char *reason, char *response)
> +{
> +	strncpy(response, "OKAY\0", 5);
> +	strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
> +}
> diff --git a/drivers/usb/gadget/f_fastboot.c
> b/drivers/usb/gadget/f_fastboot.c index 6ae1d97..fda4505 100644
> --- a/drivers/usb/gadget/f_fastboot.c
> +++ b/drivers/usb/gadget/f_fastboot.c
> @@ -150,19 +150,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); 
> -
> -void fastboot_fail(const char *reason, char *response)
> -{
> -	strncpy(response, "FAIL\0", 5);
> -	strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
> -}
> -
> -void fastboot_okay(const char *reason, char *response)
> -{
> -	strncpy(response, "OKAY\0", 5);
> -	strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
> -}
> -
>  static void fastboot_complete(struct usb_ep *ep, struct usb_request
> *req) {
>  	int status = req->status;




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180425/5a77ee0b/attachment.sig>

  reply	other threads:[~2018-04-25  7:32 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-24  9:37 [U-Boot] [RFC PATCH v1 0/5] Add fastboot UDP support Alex Kiernan
2018-04-24  9:37 ` [U-Boot] [RFC PATCH v1 1/5] dfu: Refactor fastboot_okay/fail to take response Alex Kiernan
2018-04-25  7:27   ` Lukasz Majewski
2018-04-25  8:10     ` Alex Kiernan
2018-04-24  9:37 ` [U-Boot] [RFC PATCH v1 2/5] dfu: Extract fastboot_okay/fail to fb_common.c Alex Kiernan
2018-04-25  7:32   ` Lukasz Majewski [this message]
2018-04-25  8:15     ` Alex Kiernan
2018-04-24  9:37 ` [U-Boot] [RFC PATCH v1 3/5] net: dfu: Merge AOSP UDP fastboot Alex Kiernan
2018-04-24  9:37 ` [U-Boot] [RFC PATCH v1 4/5] dfu: Resolve Kconfig dependency loops Alex Kiernan
2018-04-25  7:53   ` Lukasz Majewski
2018-04-25  8:55     ` Alex Deymo
2018-04-24  9:37 ` [U-Boot] [RFC PATCH v1 5/5] net: dfu: Support building without MMC Alex Kiernan
2018-04-24 10:24 ` [U-Boot] [RFC PATCH v1 0/5] Add fastboot UDP support Alex Deymo
2018-04-24 11:58   ` Alex Kiernan
2018-04-24 17:10     ` Jocelyn Bohr
2018-04-25  7:53       ` Alex Kiernan
2018-04-25 12:50         ` Alex Kiernan
2018-04-25 15:19           ` Lukasz Majewski
2018-04-26  3:27       ` Kever Yang
2018-04-27  8:04         ` Lukasz Majewski
2018-04-27 12:20           ` Alex Kiernan
2018-04-30  8:37             ` Alex Kiernan
2018-05-01  6:16               ` Jocelyn Bohr
2018-04-25  7:40     ` Lukasz Majewski
2018-04-25  7:52 ` Lukasz Majewski
2018-04-25  7:57   ` Lukasz Majewski
2018-04-25  8:43   ` Alex Kiernan
2018-04-25  8:46     ` Alex Deymo
2018-04-27 19:10 ` Sam Protsenko
2018-04-27 19:23   ` Alex Kiernan
2018-04-30  8:56   ` Alex Deymo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180425093220.2112810a@jawa \
    --to=lukma@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.