Convert CONFIG_PCI_CONFIG_HOST_BRIDGE to Kconfig
[platform/kernel/u-boot.git] / common / hwconfig.c
index 4ae042e..43566b8 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * An inteface for configuring a hardware via u-boot environment.
  *
@@ -5,15 +6,16 @@
  * Copyright 2011 Freescale Semiconductor, Inc.
  *
  * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #ifndef HWCONFIG_TEST
 #include <config.h>
 #include <common.h>
+#include <env.h>
 #include <exports.h>
 #include <hwconfig.h>
+#include <log.h>
+#include <asm/global_data.h>
 #include <linux/types.h>
 #include <linux/string.h>
 #else
@@ -81,7 +83,9 @@ static const char *__hwconfig(const char *opt, size_t *arglen,
                                        "and before environment is ready\n");
                        return NULL;
                }
-               env_hwconfig = getenv("hwconfig");
+#if CONFIG_IS_ENABLED(ENV_SUPPORT)
+               env_hwconfig = env_get("hwconfig");
+#endif
        }
 
        if (env_hwconfig) {
@@ -177,7 +181,7 @@ int hwconfig_arg_cmp_f(const char *opt, const char *arg, char *buf)
  *
  * This call is similar to hwconfig_f(), except that it takes additional
  * argument @subopt. In this example:
- *     "dr_usb:mode=peripheral"
+ *     "dr_usb:mode=peripheral"
  * "dr_usb" is an option, "mode" is a sub-option, and "peripheral" is its
  * argument.
  */
@@ -243,7 +247,7 @@ int main()
        const char *ret;
        size_t len;
 
-       setenv("hwconfig", "key1:subkey1=value1,subkey2=value2;key2:value3;;;;"
+       env_set("hwconfig", "key1:subkey1=value1,subkey2=value2;key2:value3;;;;"
                           "key3;:,:=;key4", 1);
 
        ret = hwconfig_arg("key1", &len);
@@ -274,7 +278,7 @@ int main()
        assert(hwconfig_arg("key4", &len) == NULL);
        assert(hwconfig_arg("bogus", &len) == NULL);
 
-       unsetenv("hwconfig");
+       unenv_set("hwconfig");
 
        assert(hwconfig(NULL) == 0);
        assert(hwconfig("") == 0);