From 4495a7a7319df596ef328360209e72988dcc9956 Mon Sep 17 00:00:00 2001 From: "faqiang.zhu" Date: Thu, 6 Dec 2018 20:06:56 +0800 Subject: MA-13715 Alway return UNLOCK state for uboot boot from USB Now "is_boot_from_usb()" can work for imx6, imx7 and imx8, use this function to judge whether boot from USB, and then return FASTBOOT_UNLOCK. This can save some time for imx8 to flash images if the board is locked. Change-Id: Iaa63f326f33400f2fdf13bf2e175cd9ac7d60317 Signed-off-by: faqiang.zhu --- drivers/usb/gadget/f_fastboot.c | 29 +++++++++++++---------------- drivers/usb/gadget/fastboot_lock_unlock.c | 3 +++ 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 2898d71af4..f853527345 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -3862,24 +3862,21 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) /* Always enable image flash for Android Things. */ #if defined(CONFIG_FASTBOOT_LOCK) && !defined(CONFIG_AVB_ATX) - /* for imx8 boot from USB, lock status can be ignored for uuu.*/ - if (!(is_imx8() || is_imx8m()) || !(is_boot_from_usb())) { - int status; - status = fastboot_get_lock_stat(); + int status; + status = fastboot_get_lock_stat(); - if (status == FASTBOOT_LOCK) { - pr_err("device is LOCKed!\n"); - strcpy(response, "FAIL device is locked."); - fastboot_tx_write_str(response); - return; + if (status == FASTBOOT_LOCK) { + pr_err("device is LOCKed!\n"); + strcpy(response, "FAIL device is locked."); + fastboot_tx_write_str(response); + return; - } else if (status == FASTBOOT_LOCK_ERROR) { - pr_err("write lock status into device!\n"); - fastboot_set_lock_stat(FASTBOOT_LOCK); - strcpy(response, "FAILdevice is locked."); - fastboot_tx_write_str(response); - return; - } + } else if (status == FASTBOOT_LOCK_ERROR) { + pr_err("write lock status into device!\n"); + fastboot_set_lock_stat(FASTBOOT_LOCK); + strcpy(response, "FAILdevice is locked."); + fastboot_tx_write_str(response); + return; } #endif fastboot_fail("no flash device defined"); diff --git a/drivers/usb/gadget/fastboot_lock_unlock.c b/drivers/usb/gadget/fastboot_lock_unlock.c index 2a377f9ebd..06d21e73b8 100644 --- a/drivers/usb/gadget/fastboot_lock_unlock.c +++ b/drivers/usb/gadget/fastboot_lock_unlock.c @@ -385,6 +385,9 @@ FbLockState fastboot_get_lock_stat(void) { unsigned char *bdata; int mmc_id; FbLockState ret; + /* uboot used by uuu will boot from USB, always return UNLOCK state */ + if (is_boot_from_usb()) + return g_lockstat; bdata = (unsigned char *)memalign(ARCH_DMA_MINALIGN, SECTOR_SIZE); if (bdata == NULL) -- cgit v1.2.3