From patchwork Sun Jul 28 14:03:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1138010 X-Patchwork-Delegate: trini@ti.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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="SX6LBSuH"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45xQ8b3t07z9s4Y for ; Mon, 29 Jul 2019 00:25:35 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 36087C21E35; Sun, 28 Jul 2019 14:14:19 +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=T_DKIM_INVALID 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 AF065C21DB3; Sun, 28 Jul 2019 14:08:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 78AE9C21E16; Sun, 28 Jul 2019 14:06:42 +0000 (UTC) Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by lists.denx.de (Postfix) with ESMTPS id 26B32C21DED for ; Sun, 28 Jul 2019 14:06:40 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id j5so110363450ioj.8 for ; Sun, 28 Jul 2019 07:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eTzJjpXah/A+mnMuOFlNu9SEyL3ITpTRKowlmWkH5sY=; b=SX6LBSuHKGlzQZCCx5sque3sz2Bd+/nGfIMXGTBgK/LqOs0b++flZ0+B9ASNwlJBIu yD+6KLCQXehr9mlnL9xHpGWFHGxsudlfCBv05HWhEn5h4WgAeQ1Ex15WFnjU50NPqSjs ALgTXxKP38POAGRzFP8amBXUEBPN9jIPlkFVA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eTzJjpXah/A+mnMuOFlNu9SEyL3ITpTRKowlmWkH5sY=; b=sWDfL12DEMc8CwWVzQW07eKcUe+be4/hut1cCzobfuJsNOVJI4QK1Cc2/baA/TdMH8 S4p5lCIhkmXKnLOfJCyxnv8EKI6iGCPRfFcKIDNWUQyg+VAHcWLW+ggmBrEXU/hZ5eS8 Ilg4z+sw/k1Ii0DjdK8kA0Yr6EvSqj9v3waCOShH3r/ypxwcF18Io3DZu+i8hy21dYkM H9tp5R4ytBXNF0Bnxxcu9JInezB+g15pvEteL2Qm2v+fSxGDOJR11B2Ac2+h0g4UbhC8 Ny0cgEVkabG8LyfvqnNErvRciy1t9ZNxzuF6NBxA/j3IVZ+SRgDOX0dfUZcQ3YLg98DY LiZg== X-Gm-Message-State: APjAAAWeGwg5aXbUTCTOh3IleNGCZOsCZF1eltrWR/Xs0s5fo9wf7/+/ 9TfALLlrFiay5C+uL6WG7/Iyljvf7Ns= X-Google-Smtp-Source: APXvYqxmtBmjKDIjm9Hy1XJf7m/+NM2KhI7dYUd8Ehro8Lip6SoDC/SwboOZ36BDBiyffzMcz78pdg== X-Received: by 2002:a02:3f0a:: with SMTP id d10mr33896150jaa.23.1564322799041; Sun, 28 Jul 2019 07:06:39 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id t5sm46782450iol.55.2019.07.28.07.06.38 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 28 Jul 2019 07:06:38 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Sun, 28 Jul 2019 08:03:39 -0600 Message-Id: <20190728140357.137295-23-sjg@chromium.org> X-Mailer: git-send-email 2.22.0.709.g102302147b-goog In-Reply-To: <20190728140357.137295-1-sjg@chromium.org> References: <20190728140357.137295-1-sjg@chromium.org> MIME-Version: 1.0 Cc: Joe Hershberger , Tom Rini Subject: [U-Boot] [PATCH 22/39] env: Move env import/export functions to env.h 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Move these functions to the new header file. Signed-off-by: Simon Glass Acked-by: Joe Hershberger --- include/env.h | 38 ++++++++++++++++++++++++++++++++++++++ include/environment.h | 12 ------------ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/include/env.h b/include/env.h index 2ba345fc4a..d6718fdf99 100644 --- a/include/env.h +++ b/include/env.h @@ -12,6 +12,8 @@ #include #include +struct environment_s; + /** * env_get_id() - Gets a sequence number for the environment * @@ -230,4 +232,40 @@ int env_save(void); */ int env_erase(void); +/** + * env_import() - Import from a binary representation into hash table + * + * This imports the environment from a buffer. THe format for each variable is + * var=value\0 with a double \0 at the end of the buffer. + * + * @buf: Buffer containing the environment (struct environemnt_s *) + * @check: non-zero to check the CRC at the start of the environment, 0 to + * ignore it + * @return 0 if imported successfully, -ENOMSG if the CRC was bad, -EIO if + * something else went wrong + */ +int env_import(const char *buf, int check); + +/** + * env_export() - Export the environment to a buffer + * + * Export from hash table into binary representation + * + * @env_out: Buffer to contain the environment (must be large enough!) + * @return 0 if OK, 1 on error + */ +int env_export(struct environment_s *env_out); + +/** + * env_import_redund() - Select and import one of two redundant environments + * + * @buf1: First environment (struct environemnt_s *) + * @buf1_read_fail: 0 if buf1 is valid, non-zero if invalid + * @buf2: Second environment (struct environemnt_s *) + * @buf2_read_fail: 0 if buf2 is valid, non-zero if invalid + * @return 0 if OK, -EIO if no environment is valid, -ENOMSG if the CRC was bad + */ +int env_import_redund(const char *buf1, int buf1_read_fail, + const char *buf2, int buf2_read_fail); + #endif diff --git a/include/environment.h b/include/environment.h index b921b8f28e..c740d5a216 100644 --- a/include/environment.h +++ b/include/environment.h @@ -274,18 +274,6 @@ char *env_get_default(const char *name); /* [re]set to the default environment */ void set_default_env(const char *s, int flags); -/* Import from binary representation into hash table */ -int env_import(const char *buf, int check); - -/* Export from hash table into binary representation */ -int env_export(env_t *env_out); - -#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT -/* Select and import one of two redundant environments */ -int env_import_redund(const char *buf1, int buf1_status, - const char *buf2, int buf2_status); -#endif - /** * env_get_char() - Get a character from the early environment *