diff options
author | Alex Kiernan <alex.kiernan@gmail.com> | 2018-05-29 15:30:40 +0000 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2018-05-30 11:59:21 +0200 |
commit | c4ded03ef608be37db105200010d2f3f88195bd6 (patch) | |
tree | da52aed38bf366e0809899f537429b461b39fb8b /drivers/usb | |
parent | 312a10f16bf3e8b68066fa359d4dd6a887b5fd55 (diff) |
fastboot: Refactor fastboot_okay/fail to take response
Add the response string as a parameter to fastboot_okay/fail, instead
of modifying a global, to match the contract expected by the AOSP
U-Boot code.
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 3acadae8b1..bb60612647 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -150,18 +150,16 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req); static int strcmp_l1(const char *s1, const char *s2); -static char *fb_response_str; - -void fastboot_fail(const char *reason) +void fastboot_fail(const char *reason, char *response) { - strncpy(fb_response_str, "FAIL\0", 5); - strncat(fb_response_str, reason, FASTBOOT_RESPONSE_LEN - 4 - 1); + strncpy(response, "FAIL\0", 5); + strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1); } -void fastboot_okay(const char *reason) +void fastboot_okay(const char *reason, char *response) { - strncpy(fb_response_str, "OKAY\0", 5); - strncat(fb_response_str, reason, FASTBOOT_RESPONSE_LEN - 4 - 1); + 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) @@ -597,18 +595,14 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) return; } - /* initialize the response buffer */ - fb_response_str = response; - - fastboot_fail("no flash device defined"); + fastboot_fail("no flash device defined", response); #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV fb_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR, - download_bytes); + download_bytes, response); #endif #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV - fb_nand_flash_write(cmd, - (void *)CONFIG_FASTBOOT_BUF_ADDR, - download_bytes); + fb_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR, + download_bytes, response); #endif fastboot_tx_write_str(response); } @@ -649,15 +643,12 @@ static void cb_erase(struct usb_ep *ep, struct usb_request *req) return; } - /* initialize the response buffer */ - fb_response_str = response; - - fastboot_fail("no flash device defined"); + fastboot_fail("no flash device defined", response); #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV - fb_mmc_erase(cmd); + fb_mmc_erase(cmd, response); #endif #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV - fb_nand_erase(cmd); + fb_nand_erase(cmd, response); #endif fastboot_tx_write_str(response); } |