1 /* 2 * errata functions 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU Library General Public License version 2. 6 */ 7 #ifndef _ERRATA_H_ 8 #define _ERRATA_H_ 9 #include <libcflat.h> 10 11 #include "config.h" 12 13 #ifndef CONFIG_ERRATA_FORCE 14 #define CONFIG_ERRATA_FORCE 0 15 #endif 16 17 #define _ERRATA(erratum) errata("ERRATA_" # erratum) 18 #define ERRATA(erratum) _ERRATA(erratum) 19 20 #define _ERRATA_RELAXED(erratum) errata_relaxed("ERRATA_" # erratum) 21 #define ERRATA_RELAXED(erratum) _ERRATA_RELAXED(erratum) 22 errata_force(void)23static inline bool errata_force(void) 24 { 25 char *s; 26 27 if (CONFIG_ERRATA_FORCE == 1) 28 return true; 29 30 s = getenv("ERRATA_FORCE"); 31 return s && (*s == '1' || *s == 'y' || *s == 'Y'); 32 } 33 errata(const char * erratum)34static inline bool errata(const char *erratum) 35 { 36 char *s; 37 38 if (errata_force()) 39 return true; 40 41 s = getenv(erratum); 42 43 return s && (*s == '1' || *s == 'y' || *s == 'Y'); 44 } 45 errata_relaxed(const char * erratum)46static inline bool errata_relaxed(const char *erratum) 47 { 48 char *s; 49 50 if (errata_force()) 51 return true; 52 53 s = getenv(erratum); 54 55 return !(s && (*s == '0' || *s == 'n' || *s == 'N')); 56 } 57 58 #endif 59