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: 117110 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp786136qgn; Wed, 25 Oct 2017 05:27:04 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SbarBN48vqzI2tdGuA7bwc/rvFy4gdkrCZ4fUL8gkD/KlQmitl8tegx+w8AwpYeQKJSpVR X-Received: by 10.80.222.76 with SMTP id a12mr24139863edl.214.1508934424775; Wed, 25 Oct 2017 05:27:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508934424; cv=none; d=google.com; s=arc-20160816; b=UibBL/yHPshAIXwpRjAYu6NBoVL9AdJVIYlGQtjQ9Ar/cQHeR7ZGxvAr6JWxqj5/5M KcEoyxbjpNrxhMVpUO/4Fu0b3nT8PMRhTHpmAWJnBI9k5Z/4CYbuwi6Me1FG9DZ/bfu7 3iRTzr+6Wd/ZCG0FpAbQj5jvovaHb0trGZgS+ed5fSXGNW/oLc1zZaq5TXc6TjD9R/JG ZMPVHpsefHA7GJjvRJH+I5mmz27vABOhXtc1zAODM+Tsy9F6qyoWLiWdiod8icwGImBC 6uFa/5wxSIhw9Ng0FbLKXZuTY7KtCAeM72lYTKS8NT/alaw/DH9GiIIBKfulcKmovHf0 kHxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=3uqeVYV9lEzvPHlVc8AqlHLNXZaisvyf9IrPloiGX/A=; b=RlYC463eHrYcFp5oYs0VEH0E8WSB79w1Hd0fRCNwNBNq99wS6oY7EcmkFLPozv9TUe xWpH9NyAHz2ppHQnHqAQHJJ4D/sQ1bXxLbdEiqUG2U32SK90k4O0ZwEY/1Tg4FKv5RQB etBJIdZijaSLiMyNBf+f8iM5tZKimhRAJTHIqWfZ+fAwLbNXQfXSLjOcPPw1bgxfHuOs y3HY2qzzCVYnC0KA+gT2K6P9cBPf3WCX5wdXnyG26e0+IwsviseuMXV85Ls+jo2j4Chw lbAGP0ufxPX7+V+NP95xxXTAcIVSQmU2geukU9iPntqtCkDLEJ1pXcfyZBdfCGXV9A7n wirg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id p61si1733085edd.543.2017.10.25.05.27.04; Wed, 25 Oct 2017 05:27:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 53767C21DB9; Wed, 25 Oct 2017 12:26:25 +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 */