#include #include #include #include #include #include #include /*----------------------------------------------------------------------------*\ \*----------------------------------------------------------------------------*/ #if IS_ENABLED(CONFIG_OF_AVM_DT_ENV) #include #include #include /* * Retrieves the AVM Environment Variables from the Device Tree */ char *__must_check prom_getenv_device_tree(char *envname) { /* Check if we have a device tree */ if (of_have_populated_dt()) { struct device_node *node; char *string = 0; /* Go to the chosen node where the environment is stored */ node = of_find_node_by_path("/chosen"); if (!node) { pr_err("Chosen node not found\n"); return 0; } /* check if the is a property with the name specified by * envname */ if (of_property_read_string(node, envname, (const char **) &string) == 0) { pr_debug("Found env %s\n", string); return string; } pr_err("Could not find Env '%s' in the device tree\n", envname); return 0; } pr_err("Device Tree not populated\n"); return NULL; } #else char eva_urlader_env[SZ_16K]; #endif /* PROM environment functions */ char *prom_getenv(char *env_name) { /* * Return a pointer to the given environment variable. prom_envp * points to a null terminated array of pointers to variables. */ #if IS_ENABLED(CONFIG_OF_AVM_DT_ENV) pr_debug("Retrieving %s from device tree\n", env_name); return prom_getenv_device_tree(env_name); #else char **var = (char **)eva_urlader_env; int i = strlen(env_name); while (*var) { if (strncmp(env_name, *var, i) == 0) { return *(var+1); } var+=2; } return NULL; #endif } EXPORT_SYMBOL(prom_getenv);