From patchwork Sat Aug 27 22:15:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 663332 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3sMC1v03Kgz9sRB for ; Sun, 28 Aug 2016 08:16:49 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5FCEA4B93F; Sun, 28 Aug 2016 00:16:45 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R4PaQDATuhFL; Sun, 28 Aug 2016 00:16:45 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C7AF24B698; Sun, 28 Aug 2016 00:16:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7ABB44B698 for ; Sun, 28 Aug 2016 00:16:41 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JNVm6LRPOQHV for ; Sun, 28 Aug 2016 00:16:41 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from p3plsmtpa09-09.prod.phx3.secureserver.net (p3plsmtpa09-09.prod.phx3.secureserver.net [173.201.193.238]) by theia.denx.de (Postfix) with ESMTPS id 99ED44B660 for ; Sun, 28 Aug 2016 00:16:36 +0200 (CEST) Received: from VM-host64-64-A1.ric.broadcom.com ([216.31.219.19]) by :SMTPAUTH: with SMTP id dltMbgJfKCq6xdltSb1lJF; Sat, 27 Aug 2016 15:16:04 -0700 X-Sender: smtpout@raedomain.com From: Steve Rae To: u-boot@lists.denx.de, Tom Rini , Masahiro Yamada , Simon Glass Date: Sat, 27 Aug 2016 15:15:43 -0700 Message-Id: <1472336143-8532-1-git-send-email-steve.rae@raedomain.com> X-Mailer: git-send-email 1.8.5 X-CMAE-Envelope: MS4wfKTje1UfMJVybcctdbnLe5DmwQh/Sc9/FM5n2ifbTky6AJTrTbBybPynQO4uEyZzrorVHKeYvZ8dvVVArIA2YnxDGy6RXM/4sGIReeszHMoVSc8lCFrS 7vAZ0sY0rJ4rcvwpCIBzwAAQjU7SuUN3pZnodluy2y5IgTx4Y4GYq5W3h6JX/t8bBnCXT3q5kA4W4pglB9JPq9U3WMLArhgkLqjpe/5EcitXJo7HROHQCvL8 TON2DpzcMFo6ImqvM2GXzLQO9XEScNbzZxD1cL99CIobaRfjN21OLUNNTLFSrcmyy0Qi65WTk/OopQtByr/1/7YGeC+bY2dG2P2VLQFjL/E= Cc: Steve Rae Subject: [U-Boot] [PATCH] Kconfig: update FASTBOOT_FLASH_MMC_DEV X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" handle FASTBOOT_FLASH_MMC_DEV default properly Signed-off-by: Steve Rae --- I was hoping that the FASTBOOT_FLASH_MMC_DEV Kconfig option could be an integer (eg. 0, 1, or 2 etc.) or undefined (to signify that it is not being used). However, it seems that (Kconfig experts please!) this is not correct within Kconfig. Therefore, I have implemented "-1" to signify that it is not used. Is this the "best practice" for handling this scenario? cmd/fastboot/Kconfig | 4 +++- common/Makefile | 4 +++- drivers/usb/gadget/f_fastboot.c | 12 ++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmd/fastboot/Kconfig b/cmd/fastboot/Kconfig index a93d1c0..fdd5475 100644 --- a/cmd/fastboot/Kconfig +++ b/cmd/fastboot/Kconfig @@ -50,10 +50,12 @@ config FASTBOOT_FLASH config FASTBOOT_FLASH_MMC_DEV int "Define FASTBOOT MMC FLASH default device" + default -1 help The fastboot "flash" command requires additional information regarding the non-volatile storage device. Define this to - the eMMC device that fastboot should use to store the image. + the eMMC device that fastboot should use to store the image, + or define '-1' to disable storing to an eMMC device. endif # USB_FUNCTION_FASTBOOT diff --git a/common/Makefile b/common/Makefile index 21619b3..56e95b3 100644 --- a/common/Makefile +++ b/common/Makefile @@ -142,12 +142,14 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o obj-y += memsize.o obj-y += stdio.o -# This option is not just y/n - it can have a numeric value ifdef CONFIG_FASTBOOT_FLASH obj-y += image-sparse.o +# This option is not just y/n - it is a numeric value ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +ifneq ($(CONFIG_FASTBOOT_FLASH_MMC_DEV), -1) obj-y += fb_mmc.o endif +endif ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV obj-y += fb_nand.o endif diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 2160b1c..5df6b8b 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -21,7 +21,8 @@ #include #include #include -#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#if defined(CONFIG_FASTBOOT_FLASH_MMC_DEV) && \ + (CONFIG_FASTBOOT_FLASH_MMC_DEV != -1) #include #endif #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV @@ -594,7 +595,8 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) fb_response_str = response; fastboot_fail("no flash device defined"); -#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#if defined(CONFIG_FASTBOOT_FLASH_MMC_DEV) && \ + (CONFIG_FASTBOOT_FLASH_MMC_DEV != -1) fb_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR, download_bytes); #endif @@ -610,7 +612,8 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) static void cb_oem(struct usb_ep *ep, struct usb_request *req) { char *cmd = req->buf; -#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#if defined(CONFIG_FASTBOOT_FLASH_MMC_DEV) && \ + (CONFIG_FASTBOOT_FLASH_MMC_DEV != -1) if (strncmp("format", cmd + 4, 6) == 0) { char cmdbuf[32]; sprintf(cmdbuf, "gpt write mmc %x $partitions", @@ -646,7 +649,8 @@ static void cb_erase(struct usb_ep *ep, struct usb_request *req) fb_response_str = response; fastboot_fail("no flash device defined"); -#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#if defined(CONFIG_FASTBOOT_FLASH_MMC_DEV) && \ + (CONFIG_FASTBOOT_FLASH_MMC_DEV != -1) fb_mmc_erase(cmd); #endif #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV