]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/env_callback.c
buildman: Permit branch names with an embedded '/'
[karo-tx-uboot.git] / common / env_callback.c
index 78ca3674f09a85d5834bae0e2bb4d3a1427b07d3..d03fa03a436219a6d7a52f67eeb494a07393199a 100644 (file)
@@ -2,23 +2,7 @@
  * (C) Copyright 2012
  * Joe Hershberger, National Instruments, joe.hershberger@ni.com
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -31,7 +15,7 @@ DECLARE_GLOBAL_DATA_PTR;
 /*
  * Look up a callback function pointer by name
  */
-struct env_clbk_tbl *find_env_callback(const char *name)
+static struct env_clbk_tbl *find_env_callback(const char *name)
 {
        struct env_clbk_tbl *clbkp;
        int i;
@@ -51,6 +35,9 @@ struct env_clbk_tbl *find_env_callback(const char *name)
        return NULL;
 }
 
+static int first_call = 1;
+static const char *callback_list;
+
 /*
  * Look for a possible callback for a newly added variable
  * This is called specifically when the variable did not exist in the hash
@@ -59,11 +46,15 @@ struct env_clbk_tbl *find_env_callback(const char *name)
 void env_callback_init(ENTRY *var_entry)
 {
        const char *var_name = var_entry->key;
-       const char *callback_list = getenv(ENV_CALLBACK_VAR);
        char callback_name[256] = "";
        struct env_clbk_tbl *clbkp;
        int ret = 1;
 
+       if (first_call) {
+               callback_list = getenv(ENV_CALLBACK_VAR);
+               first_call = 0;
+       }
+
        /* look in the ".callbacks" var for a reference to this variable */
        if (callback_list != NULL)
                ret = env_attr_lookup(callback_list, var_name, callback_name);