From patchwork Wed Oct 25 12:25:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 830243 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yMTsW65P2z9t38 for ; Wed, 25 Oct 2017 23:26:55 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9F6CBC21DC5; Wed, 25 Oct 2017 12:26:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 98128C21D92; Wed, 25 Oct 2017 12:26:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1CECEC21DE4; Wed, 25 Oct 2017 12:26:12 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id B6D23C21DC4 for ; Wed, 25 Oct 2017 12:26:08 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 16EE02084E; Wed, 25 Oct 2017 14:26:07 +0200 (CEST) Received: from localhost (unknown [185.94.189.189]) by mail.free-electrons.com (Postfix) with ESMTPSA id 6143F206D8; Wed, 25 Oct 2017 14:26:06 +0200 (CEST) From: Maxime Ripard To: Tom Rini Date: Wed, 25 Oct 2017 14:25:58 +0200 Message-Id: <20171025122601.28224-2-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171025122601.28224-1-maxime.ripard@free-electrons.com> References: <20171025122601.28224-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC 1/4] env: Rework mmc environment ifdef X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" We want the MMC environment code to be compilable so that it can be used by other environment methods, even if it's not the primary one. Rework slightly the ifdef to do that. Signed-off-by: Maxime Ripard --- env/mmc.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/env/mmc.c b/env/mmc.c index 3f3092d97560..ffbd1f7c0e59 100644 --- a/env/mmc.c +++ b/env/mmc.c @@ -143,7 +143,10 @@ static inline int write_env(struct mmc *mmc, unsigned long size, return (n == blk_cnt) ? 0 : -1; } -static int env_mmc_save(void) +#ifdef CONFIG_ENV_IS_IN_MMC +static +#endif +int env_mmc_save(void) { ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1); int dev = mmc_get_env_dev(); @@ -206,10 +209,13 @@ static inline int read_env(struct mmc *mmc, unsigned long size, return (n == blk_cnt) ? 0 : -1; } -#ifdef CONFIG_ENV_OFFSET_REDUND -static int env_mmc_load(void) +#ifdef CONFIG_ENV_IS_IN_MMC +static +#endif +int env_mmc_load(void) { #if !defined(ENV_IS_EMBEDDED) +#ifdef CONFIG_ENV_OFFSET_REDUND struct mmc *mmc; u32 offset1, offset2; int read1_fail = 0, read2_fail = 0; @@ -265,13 +271,7 @@ err: if (ret) set_default_env(errmsg); -#endif - return ret; -} #else /* ! CONFIG_ENV_OFFSET_REDUND */ -static int env_mmc_load(void) -{ -#if !defined(ENV_IS_EMBEDDED) ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE); struct mmc *mmc; u32 offset; @@ -306,11 +306,12 @@ fini: err: if (ret) set_default_env(errmsg); -#endif +#endif /* CONFIG_ENV_OFFSET_REDUND */ +#endif /* ENV_IS_EMBEDDED */ return ret; } -#endif /* CONFIG_ENV_OFFSET_REDUND */ +#ifdef CONFIG_ENV_IS_IN_MMC U_BOOT_ENV_LOCATION(mmc) = { .location = ENVL_MMC, ENV_NAME("MMC") @@ -319,3 +320,4 @@ U_BOOT_ENV_LOCATION(mmc) = { .save = env_save_ptr(env_mmc_save), #endif }; +#endif /* CONFIG_ENV_IS_IN_MMC */