diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-07-01 19:40:18 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-07-01 19:40:18 -0700 |
commit | 4da3064d1775810f10f7ddc1c34c3f1ff502a654 (patch) | |
tree | dc4cd9b546e5d702226f5e3e6bf165867140985c /scripts/dtc/dtc-parser.y | |
parent | 93899e39e86bfc021a190a9c26e8e516561f2756 (diff) | |
parent | 48a9b733e644ab4cc8e2a98950a36ddb12b8c54e (diff) | |
download | blackbird-obmc-linux-4da3064d1775810f10f7ddc1c34c3f1ff502a654.tar.gz blackbird-obmc-linux-4da3064d1775810f10f7ddc1c34c3f1ff502a654.zip |
Merge tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/glikely/linux
Pull devicetree updates from Grant Likely:
"A whole lot of bug fixes.
Nothing stands out here except the ability to enable CONFIG_OF on
every architecture, and an import of a newer version of dtc"
* tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/glikely/linux: (22 commits)
of/irq: Rename "intc_desc" to "of_intc_desc" to fix OF on sh
of/irq: Fix pSeries boot failure
Documentation: DT: Fix a typo in the filename "lantiq,<chip>-pinumx.txt"
of: define of_find_node_by_phandle for !CONFIG_OF
of/address: use atomic allocation in pci_register_io_range()
of: Add vendor prefix for Zodiac Inflight Innovations
dt/fdt: add empty versions of early_init_dt_*_memory_arch
of: clean-up unnecessary libfdt include paths
of: make unittest select OF_EARLY_FLATTREE instead of depend on it
of: make CONFIG_OF user selectable
MIPS: prepare for user enabling of CONFIG_OF
of/fdt: fix argument name and add comments of unflatten_dt_node()
of: return NUMA_NO_NODE from fallback of_node_to_nid()
tps6507x.txt: Remove executable permission
of/overlay: Grammar s/an negative/a negative/
of/fdt: Make fdt blob input parameters of unflatten functions const
of: add helper function to retrive match data
of: Grammar s/property exist/property exists/
of: Move OF flags to be visible even when !CONFIG_OF
scripts/dtc: Update to upstream version 9d3649bd3be245c9
...
Diffstat (limited to 'scripts/dtc/dtc-parser.y')
-rw-r--r-- | scripts/dtc/dtc-parser.y | 147 |
1 files changed, 46 insertions, 101 deletions
diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y index f412460f94d7..5a897e36562d 100644 --- a/scripts/dtc/dtc-parser.y +++ b/scripts/dtc/dtc-parser.y @@ -17,31 +17,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ - %{ #include <stdio.h> #include "dtc.h" #include "srcpos.h" -YYLTYPE yylloc; - extern int yylex(void); -extern void print_error(char const *fmt, ...); extern void yyerror(char const *s); +#define ERROR(loc, ...) \ + do { \ + srcpos_error((loc), "Error", __VA_ARGS__); \ + treesource_error = true; \ + } while (0) extern struct boot_info *the_boot_info; -extern int treesource_error; - -static unsigned long long eval_literal(const char *s, int base, int bits); -static unsigned char eval_char_literal(const char *s); +extern bool treesource_error; %} %union { char *propnodename; - char *literal; char *labelref; - unsigned int cbase; uint8_t byte; struct data data; @@ -65,9 +61,8 @@ static unsigned char eval_char_literal(const char *s); %token DT_DEL_PROP %token DT_DEL_NODE %token <propnodename> DT_PROPNODENAME -%token <literal> DT_LITERAL -%token <literal> DT_CHAR_LITERAL -%token <cbase> DT_BASE +%token <integer> DT_LITERAL +%token <integer> DT_CHAR_LITERAL %token <byte> DT_BYTE %token <data> DT_STRING %token <labelref> DT_LABEL @@ -145,6 +140,18 @@ devicetree: { $$ = merge_nodes($1, $3); } + + | devicetree DT_LABEL DT_REF nodedef + { + struct node *target = get_node_by_ref($1, $3); + + add_label(&target->labels, $2); + if (target) + merge_nodes(target, $4); + else + ERROR(&@3, "Label or path %s not found", $3); + $$ = $1; + } | devicetree DT_REF nodedef { struct node *target = get_node_by_ref($1, $2); @@ -152,17 +159,18 @@ devicetree: if (target) merge_nodes(target, $3); else - print_error("label or path, '%s', not found", $2); + ERROR(&@2, "Label or path %s not found", $2); $$ = $1; } | devicetree DT_DEL_NODE DT_REF ';' { struct node *target = get_node_by_ref($1, $3); - if (!target) - print_error("label or path, '%s', not found", $3); - else + if (target) delete_node(target); + else + ERROR(&@3, "Label or path %s not found", $3); + $$ = $1; } @@ -230,10 +238,9 @@ propdata: if ($6 != 0) if (fseek(f, $6, SEEK_SET) != 0) - print_error("Couldn't seek to offset %llu in \"%s\": %s", - (unsigned long long)$6, - $4.val, - strerror(errno)); + die("Couldn't seek to offset %llu in \"%s\": %s", + (unsigned long long)$6, $4.val, + strerror(errno)); d = data_copy_file(f, $8); @@ -274,18 +281,19 @@ propdataprefix: arrayprefix: DT_BITS DT_LITERAL '<' { - $$.data = empty_data; - $$.bits = eval_literal($2, 0, 7); - - if (($$.bits != 8) && - ($$.bits != 16) && - ($$.bits != 32) && - ($$.bits != 64)) - { - print_error("Only 8, 16, 32 and 64-bit elements" - " are currently supported"); - $$.bits = 32; + unsigned long long bits; + + bits = $2; + + if ((bits != 8) && (bits != 16) && + (bits != 32) && (bits != 64)) { + ERROR(&@2, "Array elements must be" + " 8, 16, 32 or 64-bits"); + bits = 32; } + + $$.data = empty_data; + $$.bits = bits; } | '<' { @@ -305,9 +313,8 @@ arrayprefix: * mask), all bits are one. */ if (($2 > mask) && (($2 | mask) != -1ULL)) - print_error( - "integer value out of range " - "%016lx (%d bits)", $1.bits); + ERROR(&@2, "Value out of range for" + " %d-bit array element", $1.bits); } $$.data = data_append_integer($1.data, $2, $1.bits); @@ -321,7 +328,7 @@ arrayprefix: REF_PHANDLE, $2); else - print_error("References are only allowed in " + ERROR(&@2, "References are only allowed in " "arrays with 32-bit elements."); $$.data = data_append_integer($1.data, val, $1.bits); @@ -334,13 +341,7 @@ arrayprefix: integer_prim: DT_LITERAL - { - $$ = eval_literal($1, 0, 64); - } | DT_CHAR_LITERAL - { - $$ = eval_char_literal($1); - } | '(' integer_expr ')' { $$ = $2; @@ -447,7 +448,7 @@ subnodes: } | subnode propdef { - print_error("syntax error: properties must precede subnodes"); + ERROR(&@2, "Properties must precede subnodes"); YYERROR; } ; @@ -470,63 +471,7 @@ subnode: %% -void print_error(char const *fmt, ...) -{ - va_list va; - - va_start(va, fmt); - srcpos_verror(&yylloc, fmt, va); - va_end(va); - - treesource_error = 1; -} - -void yyerror(char const *s) { - print_error("%s", s); -} - -static unsigned long long eval_literal(const char *s, int base, int bits) -{ - unsigned long long val; - char *e; - - errno = 0; - val = strtoull(s, &e, base); - if (*e) { - size_t uls = strspn(e, "UL"); - if (e[uls]) - print_error("bad characters in literal"); - } - if ((errno == ERANGE) - || ((bits < 64) && (val >= (1ULL << bits)))) - print_error("literal out of range"); - else if (errno != 0) - print_error("bad literal"); - return val; -} - -static unsigned char eval_char_literal(const char *s) +void yyerror(char const *s) { - int i = 1; - char c = s[0]; - - if (c == '\0') - { - print_error("empty character literal"); - return 0; - } - - /* - * If the first character in the character literal is a \ then process - * the remaining characters as an escape encoding. If the first - * character is neither an escape or a terminator it should be the only - * character in the literal and will be returned. - */ - if (c == '\\') - c = get_escape_char(s, &i); - - if (s[i] != '\0') - print_error("malformed character literal"); - - return c; + ERROR(&yylloc, "%s", s); } |