From patchwork Thu Mar 26 23:01:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1262419 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=Li1hSybp; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48pL9G5DlXz9sSL for ; Fri, 27 Mar 2020 10:02:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3ECC48183F; Fri, 27 Mar 2020 00:02:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk 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=prevas.dk header.i=@prevas.dk header.b="Li1hSybp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C7D498185A; Fri, 27 Mar 2020 00:02:17 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20709.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::709]) (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 9D96B8183F for ; Fri, 27 Mar 2020 00:02:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i6LaqVkmlsutC8xfN0V7Q3AHfRbSnj4XSbA/kBXelSF7dJdD60lqSnIy6ZpwhmKsI4DLAiNga+AahRY3ZQFgOelvFRAkwcOo21ZqaX5YPnS9BM3zUcviOHEE428xh0wUgDv9ERnWZ5CHf98CBn8eSSqaOw9+0mfl/0hDgFWlDH+lAtNwkRrcXvhj5X8mTqWJZfMeXxuvFK69ZJqSpPcyuH8A+xq2MLheuDYOgSRI5fAsA8RWyywzRHz2crF9cJACJNKdV28BxMgj3z6uC29H3xMxmTEJVUjLbioBToh4kp5X7Xg1yM3xV4UMRmLbPwlxJO/o2jnW0K/EQ017Ei/Lug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GaSIRNi63LBx2TWadgvC8osMc9IykHhPxfc1J/ZDSnU=; b=hkcsB8BeLOvpkFlu23ozyqMqmWnD5w3IvVRarPvoqUoh7bkrjGNvgH1UXTQf3IBdwkFiaswm6ARDnxO2MiLsD5GuNruJai22Uk0TFk+OZPHg8WECkwJyJtdNDKL4XG2r6an4T8lIx7rTEpXyCi2aAf+qfhn8BwfQ+KfZ8DTiXE6YZPKLcytvlyv+Wum8ajgxiPfsBrIbFmT8x8sczBSVAwJaOXPxN6xtmEw6TtTgwG1q6s2hBstMqYnlv5F0ntzaIqWPGhqdy5CACmYQJH81YJS/KG9HAS+guRVKKbUicOx7x0YFc2vXHLE61C5f0ZP9CImxE4WEiHhqt0hpmhbaxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GaSIRNi63LBx2TWadgvC8osMc9IykHhPxfc1J/ZDSnU=; b=Li1hSybp0poXtqp0VKvHmY+mtgwJfNPZDPozVL4kJFlNm//rhcIc7/ydnC26+uPyNzyNrit9wGbnxuYfwDso7HbIhz08eBoETv0qMdbP6sRu12xOfao5CqjIe/wAIFIFLvP25h7izSz3OMaUHbI5hpX08QDpnPiYkPI3kndd/X8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rasmus.villemoes@prevas.dk; Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB3167.EURPRD10.PROD.OUTLOOK.COM (52.133.244.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18; Thu, 26 Mar 2020 23:02:10 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::e58f:1097:b71d:32c7]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::e58f:1097:b71d:32c7%5]) with mapi id 15.20.2835.023; Thu, 26 Mar 2020 23:02:10 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Wolfgang Denk , Joe Hershberger , Tom Rini , Rasmus Villemoes Subject: [PATCH v2 1/2] env: add SAVEENV as an alias of the CMD_SAVEENV symbol Date: Fri, 27 Mar 2020 00:01:59 +0100 Message-Id: <20200326230200.12617-2-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200326230200.12617-1-rasmus.villemoes@prevas.dk> References: <20200219094726.26798-1-rasmus.villemoes@prevas.dk> <20200326230200.12617-1-rasmus.villemoes@prevas.dk> X-ClientProxiedBy: AM6P192CA0031.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:83::44) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.116.45) by AM6P192CA0031.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:83::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.18 via Frontend Transport; Thu, 26 Mar 2020 23:02:09 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.116.45] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 20e47cb5-ec06-4f38-c4a8-08d7d1d9b680 X-MS-TrafficTypeDiagnostic: VI1PR10MB3167: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-Forefront-PRVS: 0354B4BED2 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(10019020)(376002)(396003)(136003)(346002)(39840400004)(366004)(316002)(66946007)(54906003)(66476007)(66556008)(6486002)(5660300002)(44832011)(1076003)(6506007)(6666004)(36756003)(478600001)(8976002)(2616005)(4326008)(956004)(52116002)(6512007)(8936002)(16526019)(6916009)(186003)(8676002)(107886003)(81156014)(81166006)(86362001)(2906002)(26005); DIR:OUT; SFP:1102; Received-SPF: None (protection.outlook.com: prevas.dk does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gZdIYfy1Cbt4G2mGfGDQEeVDkFeGAm+WBsy3oGalXXLRpZcLfh/Njc7T4P4lxtj2YIP0cMfBma42Ix+vB/4VV5ZSDdYcaWZzccpaC+bZkJ6ZHIjhdcKISEYvAgEJYQWn1avikavTPdNc06nr1HffikmxOe3plfWUdt+kjv+YxXII8kUrOMWFGtM3cqUqlEZj5IvDWe6YV7PQvHB7hit+13hpE0YMIjHuIwIEULTz99Dg42vSm5PrHJH4njGOHvKvEjItkdfIQHL+giyNEIglPvCnL5JHe7TQY3GzDKS6yQ+12JxGKleB9mU8DQIKeAfGIOu73lw7B9CFfx3dwQWgGbzIwqQddEd5qZRW6DZehCVvF0WwRBcsHtP9sHrsC16+lFMz4/XC8MRkI2yl87XmobCJFARLqTEaN8iLs8kuILjIudP+TiSMMLhLn2VBi1XB X-MS-Exchange-AntiSpam-MessageData: hfmqd1+Mm391X3S4iOLSpumxqGZvpYNhq93IKxpOyIPBmdE5eQnKrBUXG+wrZ287psYHI0JCiimLAszH3kOpTDTPzjODXZJ3tsDHGOM0Pfgjq+S4oFmQFqBFliIpPGi2DT/A815SpgB9EGpSAVZRXQ== X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 20e47cb5-ec06-4f38-c4a8-08d7d1d9b680 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2020 23:02:10.0892 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Dyi9Ima5g3Stidy3+qO7WhOjP6O3NWVUXFci2hPJsRx6QEaID37Y6GLOBJlbBK9Zf0yk8a+17VO9NhpdArDxPSSIfxAph+dX/2qieUOL77w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB3167 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Currently, quite a few storage drivers currently do not honour SPL_SAVEENV. That is, whether or not one enables CONFIG_SPL_SAVEENV, the backend drivers do not provide the .save method. Witness env/fat.c:#ifdef CONFIG_SPL_BUILD ... env/fat.c-#else env/fat.c-# define LOADENV env/fat.c:# if defined(CONFIG_CMD_SAVEENV) env/fat.c:# define CMD_SAVEENV env/fat.c-# endif env/fat.c-#endif env/fat.c- env/fat.c:#ifdef CMD_SAVEENV env/fat.c-static int env_fat_save(void) env/flash.c:#ifndef CONFIG_SPL_BUILD env/flash.c:# if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_FLASH) env/flash.c:# define CMD_SAVEENV ... env/flash.c:#ifdef CMD_SAVEENV env/flash.c-static int env_flash_save(void) env/mmc.c:#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_SPL_BUILD) env/mmc.c-static inline int write_env(struct mmc *mmc, unsigned long size, env/nand.c:#if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_NAND) && \ env/nand.c: !defined(CONFIG_SPL_BUILD) env/nand.c:#define CMD_SAVEENV ... env/nand.c:#ifdef CMD_SAVEENV env/nand.c-/* env/nand.c- * The legacy NAND code saved the environment in the first NAND device i.e., env/nand.c- * nand_dev_desc + 0. This is also the behaviour using the new NAND code. env/nand.c- */ env/nand.c-static int writeenv(size_t offset, u_char *buf) env/sf.c:#ifndef CONFIG_SPL_BUILD env/sf.c:#define CMD_SAVEENV env/sf.c-#define INITENV env/sf.c-#endif ... env/sf.c:#ifdef CMD_SAVEENV env/sf.c-static int env_sf_save(void) In all these cases, the mere presence of CONFIG_SPL_BUILD means the save method does not get built. Now, it is currently a bit awkward to write a proper test for whether saving the environment is enabled in the current context; something like #if (!defined(CONFIG_SPL_BUILD) && defined(CONFIG_CMD_SAVEENV)) || \ (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_SAVEENV)) But we already have a rather elegant mechanism that implicitly does the CONFIG_SPL_BUILD tests, namely CONFIG_IS_ENABLED(). Using that requires that the controlling config symbols follow a strict pattern: FOO for U-Boot proper, SPL_FOO for SPL. This patch introduces CONFIG_SAVEENV as an alias for CONFIG_CMD_SAVEENV. That way, the above can simply be written #if CONFIG_IS_ENABLED(SAVEENV) and moreover, CONFIG_IS_ENABLED(SAVEENV) can also be used in C code, avoiding ifdeffery and providing more compile testing. Signed-off-by: Rasmus Villemoes --- v2: Expand commit message, explain why one needs a new config symbol in order to use CONFIG_IS_ENABLED, and demonstrate how many of the storage drivers don't compile their .save method when CONFIG_SPL_BUILD. The patch itself is the same. env/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/env/Kconfig b/env/Kconfig index 0d6f559b39..969308fe6c 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -3,6 +3,9 @@ menu "Environment" config ENV_SUPPORT def_bool y +config SAVEENV + def_bool y if CMD_SAVEENV + config ENV_IS_NOWHERE bool "Environment is not stored" default y if !ENV_IS_IN_EEPROM && !ENV_IS_IN_EXT4 && \