env: Drop common init() functions
[platform/kernel/u-boot.git] / env / remote.c
1 /*
2  * (C) Copyright 2011-2012 Freescale Semiconductor, Inc.
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 /* #define DEBUG */
8
9 #include <common.h>
10 #include <command.h>
11 #include <environment.h>
12 #include <linux/stddef.h>
13
14 char *env_name_spec = "Remote";
15
16 #ifdef ENV_IS_EMBEDDED
17 env_t *env_ptr = &environment;
18 #else /* ! ENV_IS_EMBEDDED */
19 env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
20 #endif /* ENV_IS_EMBEDDED */
21
22 DECLARE_GLOBAL_DATA_PTR;
23
24 #if !defined(CONFIG_ENV_OFFSET)
25 #define CONFIG_ENV_OFFSET 0
26 #endif
27
28 static int env_remote_init(void)
29 {
30         if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
31                 gd->env_addr = (ulong)&(env_ptr->data);
32                 gd->env_valid = ENV_VALID;
33                 return 0;
34         }
35
36         return -ENOENT;
37 }
38
39 #ifdef CONFIG_CMD_SAVEENV
40 static int env_remote_save(void)
41 {
42 #ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
43         printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n");
44         return 1;
45 #else
46         return 0;
47 #endif
48 }
49 #endif /* CONFIG_CMD_SAVEENV */
50
51 static void env_remote_load(void)
52 {
53 #ifndef ENV_IS_EMBEDDED
54         env_import((char *)env_ptr, 1);
55 #endif
56 }
57
58 U_BOOT_ENV_LOCATION(remote) = {
59         .location       = ENVL_REMOTE,
60         .load           = env_remote_load,
61         .save           = env_save_ptr(env_remote_save),
62         .init           = env_remote_init,
63 };