From patchwork Tue Jan 17 22:09:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Nelson X-Patchwork-Id: 136530 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 6BBD2B6EF1 for ; Wed, 18 Jan 2012 09:17:10 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9BAC7282DE; Tue, 17 Jan 2012 23:17:00 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 xJA+FiwokIh0; Tue, 17 Jan 2012 23:17:00 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 60357282DA; Tue, 17 Jan 2012 23:16:47 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7A307282C8 for ; Tue, 17 Jan 2012 23:16:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 En1sgKv3nORn for ; Tue, 17 Jan 2012 23:16:40 +0100 (CET) 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 mail.integraonline.com (relay2.integra.net [204.130.255.181]) by theia.denx.de (Postfix) with SMTP id 95C05282CB for ; Tue, 17 Jan 2012 23:16:39 +0100 (CET) Received: (qmail 7509 invoked from network); 17 Jan 2012 22:09:57 -0000 Received: from unknown (HELO ericsony.example.org) (70.96.116.236) by relay2.integra.net with SMTP; 17 Jan 2012 22:09:57 -0000 From: Eric Nelson To: u-boot@lists.denx.de Date: Tue, 17 Jan 2012 15:09:48 -0700 Message-Id: <1326838190-13746-5-git-send-email-eric.nelson@boundarydevices.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1326838190-13746-1-git-send-email-eric.nelson@boundarydevices.com> References: <1326838190-13746-1-git-send-email-eric.nelson@boundarydevices.com> Cc: dirk.behme@de.bosch.com, jason.hui@linaro.org Subject: [U-Boot] [PATCH 4/6] sf command: allow default chip select through CONFIG_SPI_FLASH_CS X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Eric Nelson --- common/cmd_sf.c | 34 +++++++++++++++++++++++----------- 1 files changed, 23 insertions(+), 11 deletions(-) diff --git a/common/cmd_sf.c b/common/cmd_sf.c index 7225656..97fce16 100644 --- a/common/cmd_sf.c +++ b/common/cmd_sf.c @@ -70,20 +70,28 @@ static int do_spi_flash_probe(int argc, char * const argv[]) char *endp; struct spi_flash *new; - if (argc < 2) - return -1; - - cs = simple_strtoul(argv[1], &endp, 0); - if (*argv[1] == 0 || (*endp != 0 && *endp != ':')) +#ifndef CONFIG_SPI_FLASH_CS + if (argc < 2) { + printf("%s: missing arguments\n", __func__); return -1; - if (*endp == ':') { - if (endp[1] == 0) - return -1; + } +#else + cs = CONFIG_SPI_FLASH_CS ; +#endif - bus = cs; - cs = simple_strtoul(endp + 1, &endp, 0); - if (*endp != 0) + if (argc >= 2) { + cs = simple_strtoul(argv[1], &endp, 0); + if (*argv[1] == 0 || (*endp != 0 && *endp != ':')) return -1; + if (*endp == ':') { + if (endp[1] == 0) + return -1; + + bus = cs; + cs = simple_strtoul(endp + 1, &endp, 0); + if (*endp != 0) + return -1; + } } if (argc >= 3) { @@ -299,7 +307,11 @@ usage: U_BOOT_CMD( sf, 5, 1, do_spi_flash, "SPI flash sub-system", +#ifndef CONFIG_SPI_FLASH_CS "probe [bus:]cs [hz] [mode] - init flash device on given SPI bus\n" +#else + "probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus\n" +#endif " and chip select\n" "sf read addr offset len - read `len' bytes starting at\n" " `offset' to memory at `addr'\n"