static const char *__hwconfig(const char *opt, size_t *arglen) { const char *env_hwconfig = NULL; char buf[HWCONFIG_PRE_RELOC_BUF_SIZE]; if (gd->flags & GD_FLG_ENV_READY) { env_hwconfig = getenv("hwconfig"); } else { /* * Use our own on stack based buffer before relocation to allow * accessing longer hwconfig strings that might be in the * environment before we've relocated. This is pretty fragile * on both the use of stack and if the buffer is big enough. * However we will get a warning from getenv_f for the later. */ if ((getenv_f("hwconfig", buf, sizeof(buf))) > 0) env_hwconfig = buf; } if (env_hwconfig) return hwconfig_parse(env_hwconfig, strlen(env_hwconfig), opt, ";", ':', arglen); if (board_hwconfig) return hwconfig_parse(board_hwconfig, strlen(board_hwconfig), opt, ";", ':', arglen); if (cpu_hwconfig) return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig), opt, ";", ':', arglen); return NULL; }
static const char *__hwconfig(const char *opt, size_t *arglen, const char *env_hwconfig) { const char *ret; /* if we are passed a buffer use it, otherwise try the environment */ if (!env_hwconfig) { if (!(gd->flags & GD_FLG_ENV_READY)) { printf("WARNING: Calling __hwconfig without a buffer " "and before environment is ready\n"); return NULL; } env_hwconfig = env_get("hwconfig"); } if (env_hwconfig) { ret = hwconfig_parse(env_hwconfig, strlen(env_hwconfig), opt, ";", ':', arglen); if (ret) return ret; } ret = hwconfig_parse(board_hwconfig, strlen(board_hwconfig), opt, ";", ':', arglen); if (ret) return ret; return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig), opt, ";", ':', arglen); }
static const char *__hwconfig(const char *opt, size_t *arglen) { const char *env_hwconfig = getenv("hwconfig"); if (env_hwconfig) return hwconfig_parse(env_hwconfig, strlen(env_hwconfig), opt, ';', ':', arglen); if (board_hwconfig) return hwconfig_parse(board_hwconfig, strlen(board_hwconfig), opt, ';', ':', arglen); if (cpu_hwconfig) return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig), opt, ';', ':', arglen); return NULL; }
/* * hwconfig_sub - query if a particular hwconfig sub-option is specified * @opt: a string representing an option * @subopt: a string representing a sub-option * * This call is similar to hwconfig(), except that it takes additional * argument @subopt. In this example: * "dr_usb:mode=peripheral" * "dr_usb" is an option, "mode" is a sub-option, and "peripheral" is its * argument. */ int hwconfig_sub(const char *opt, const char *subopt) { size_t arglen; const char *arg; arg = __hwconfig(opt, &arglen); if (!arg) return 0; return !!hwconfig_parse(arg, arglen, subopt, ",;", '=', NULL); }
/* * hwconfig_subarg - get hwconfig sub-option's argument * @opt: a string representing an option * @subopt: a string representing a sub-option * @subarglen: a pointer to an allocated size_t variable * * This call is similar to hwconfig_arg(), except that it takes an additional * argument @subopt, and so works with sub-options. */ const char *hwconfig_subarg(const char *opt, const char *subopt, size_t *subarglen) { size_t arglen; const char *arg; arg = __hwconfig(opt, &arglen); if (!arg) return NULL; return hwconfig_parse(arg, arglen, subopt, ",;", '=', subarglen); }