Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9A1BC4338F for ; Mon, 2 Aug 2021 16:28:28 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E43660EB2 for ; Mon, 2 Aug 2021 16:28:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0E43660EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A606982903; Mon, 2 Aug 2021 18:28:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="rDtzZIpS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 289F482D3C; Mon, 2 Aug 2021 18:28:24 +0200 (CEST) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0F94581FC6 for ; Mon, 2 Aug 2021 18:28:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=p.yadav@ti.com Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 172GS7ha090839; Mon, 2 Aug 2021 11:28:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1627921687; bh=0iLg76W90GqLLt5oNZkcraxYbnbQkkjGVNutNogtAUk=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=rDtzZIpSwQkpcRpe3F9AiUQTu/lWbtvCdFyLhc+bL13ASHbc0wXyo5r1oHYd9IaZw yUT3jc2a2MYHv/BkOIAIgwlNIfHUHar7YrHhaRVoIHpPv1qZ12yK8VKN0Zy8gwgEKb gMJ1V0uiJPNmG5YUBPAkrw1nbhd9m0Zr5GSJpnfs= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 172GS7Gx064984 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 2 Aug 2021 11:28:07 -0500 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 2 Aug 2021 11:28:07 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Mon, 2 Aug 2021 11:28:07 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 172GS6JG128998; Mon, 2 Aug 2021 11:28:06 -0500 Date: Mon, 2 Aug 2021 21:58:05 +0530 From: Pratyush Yadav To: Simon Glass CC: U-Boot Mailing List , Heinrich Schuchardt , Jagan Teki , Mike Frysinger Subject: Re: [PATCH v3 2/4] sf: Tidy up code to avoid #ifdef Message-ID: <20210802162803.mnbxo5yprnv7pkhz@ti.com> References: <20210801211245.2208037-1-sjg@chromium.org> <20210801211245.2208037-3-sjg@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210801211245.2208037-3-sjg@chromium.org> User-Agent: NeoMutt/20171215 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 01/08/21 03:12PM, Simon Glass wrote: > Update this code to use IS_ENABLED() instead. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > cmd/sf.c | 32 ++++++++++++++------------------ > 1 file changed, 14 insertions(+), 18 deletions(-) > > diff --git a/cmd/sf.c b/cmd/sf.c > index 46346fb9d43..d4f5ecee38c 100644 > --- a/cmd/sf.c > +++ b/cmd/sf.c > @@ -384,7 +384,6 @@ static int do_spi_protect(int argc, char *const argv[]) > return ret == 0 ? 0 : 1; > } > > -#ifdef CONFIG_CMD_SF_TEST > enum { > STAGE_ERASE, > STAGE_CHECK, > @@ -394,7 +393,7 @@ enum { > STAGE_COUNT, > }; > > -static char *stage_name[STAGE_COUNT] = { > +static const char *stage_name[STAGE_COUNT] = { Unrelated change. Dunno if it is worth its own separate patch though. Up to you. > "erase", > "check", > "write", > @@ -548,7 +547,6 @@ static int do_spi_flash_test(int argc, char *const argv[]) > > return 0; > } > -#endif /* CONFIG_CMD_SF_TEST */ > > static int do_spi_flash(struct cmd_tbl *cmdtp, int flag, int argc, > char *const argv[]) > @@ -582,10 +580,8 @@ static int do_spi_flash(struct cmd_tbl *cmdtp, int flag, int argc, > ret = do_spi_flash_erase(argc, argv); > else if (strcmp(cmd, "protect") == 0) > ret = do_spi_protect(argc, argv); > -#ifdef CONFIG_CMD_SF_TEST > - else if (!strcmp(cmd, "test")) > + else if (IS_ENABLED(CONFIG_CMD_SF_TEST) && !strcmp(cmd, "test")) Ok. > ret = do_spi_flash_test(argc, argv); > -#endif > else > ret = -1; > > @@ -597,16 +593,8 @@ usage: > return CMD_RET_USAGE; > } > > -#ifdef CONFIG_CMD_SF_TEST > -#define SF_TEST_HELP "\nsf test offset len " \ > - "- run a very basic destructive test" > -#else > -#define SF_TEST_HELP > -#endif > - > -U_BOOT_CMD( > - sf, 5, 1, do_spi_flash, > - "SPI flash sub-system", > +#ifdef CONFIG_SYS_LONGHELP > +static const char long_help[] = > "probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus\n" > " and chip select\n" > "sf read addr offset|partition len - read `len' bytes starting at\n" > @@ -622,6 +610,14 @@ U_BOOT_CMD( > " at `addr' to flash at `offset'\n" > " or to start of mtd `partition'\n" > "sf protect lock/unlock sector len - protect/unprotect 'len' bytes starting\n" > - " at address 'sector'\n" > - SF_TEST_HELP > + " at address 'sector'" > +#ifdef CONFIG_CMD_SF_TEST > + "\nsf test offset len - run a very basic destructive test" > +#endif Dunno if this is better or worse than before. Should be fine either way I guess Other than the comment above, Reviewed-by: Pratyush Yadav > +#endif /* CONFIG_SYS_LONGHELP */ > + ; > + > +U_BOOT_CMD( > + sf, 5, 1, do_spi_flash, > + "SPI flash sub-system", long_help > ); > -- > 2.32.0.554.ge1b32706d8-goog > -- Regards, Pratyush Yadav Texas Instruments Inc.