1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 #ifndef _LINUX_OF_H 3 #define _LINUX_OF_H 4 /* 5 * Definitions for talking to the Open Firmware PROM on 6 * Power Macintosh and other computers. 7 * 8 * Copyright (C) 1996-2005 Paul Mackerras. 9 * 10 * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp. 11 * Updates for SPARC64 by David S. Miller 12 * Derived from PowerPC and Sparc prom.h files by Stephen Rothwell, IBM Corp. 13 */ 14 #include <linux/types.h> 15 #include <linux/bitops.h> 16 #include <linux/errno.h> 17 #include <linux/kobject.h> 18 #include <linux/mod_devicetable.h> 19 #include <linux/spinlock.h> 20 #include <linux/topology.h> 21 #include <linux/notifier.h> 22 #include <linux/property.h> 23 #include <linux/list.h> 24 25 #include <asm/byteorder.h> 26 #include <asm/errno.h> 27 28 typedef u32 phandle; 29 typedef u32 ihandle; 30 31 struct property { 32 char *name; 33 int length; 34 void *value; 35 struct property *next; 36 #if defined(CONFIG_OF_DYNAMIC) || defined(CONFIG_SPARC) 37 unsigned long _flags; 38 #endif 39 #if defined(CONFIG_OF_PROMTREE) 40 unsigned int unique_id; 41 #endif 42 #if defined(CONFIG_OF_KOBJ) 43 struct bin_attribute attr; 44 #endif 45 }; 46 47 #if defined(CONFIG_SPARC) 48 struct of_irq_controller; 49 #endif 50 51 struct device_node { 52 const char *name; 53 const char *type; 54 phandle phandle; 55 const char *full_name; 56 struct fwnode_handle fwnode; 57 58 struct property *properties; 59 struct property *deadprops; /* removed properties */ 60 struct device_node *parent; 61 struct device_node *child; 62 struct device_node *sibling; 63 #if defined(CONFIG_OF_KOBJ) 64 struct kobject kobj; 65 #endif 66 unsigned long _flags; 67 void *data; 68 #if defined(CONFIG_SPARC) 69 unsigned int unique_id; 70 struct of_irq_controller *irq_trans; 71 #endif 72 }; 73 74 #define MAX_PHANDLE_ARGS 16 75 struct of_phandle_args { 76 struct device_node *np; 77 int args_count; 78 uint32_t args[MAX_PHANDLE_ARGS]; 79 }; 80 81 struct of_phandle_iterator { 82 /* Common iterator information */ 83 const char *cells_name; 84 int cell_count; 85 const struct device_node *parent; 86 87 /* List size information */ 88 const __be32 *list_end; 89 const __be32 *phandle_end; 90 91 /* Current position state */ 92 const __be32 *cur; 93 uint32_t cur_count; 94 phandle phandle; 95 struct device_node *node; 96 }; 97 98 struct of_reconfig_data { 99 struct device_node *dn; 100 struct property *prop; 101 struct property *old_prop; 102 }; 103 104 /* initialize a node */ 105 extern struct kobj_type of_node_ktype; 106 extern const struct fwnode_operations of_fwnode_ops; 107 static inline void of_node_init(struct device_node *node) 108 { 109 #if defined(CONFIG_OF_KOBJ) 110 kobject_init(&node->kobj, &of_node_ktype); 111 #endif 112 node->fwnode.ops = &of_fwnode_ops; 113 } 114 115 #if defined(CONFIG_OF_KOBJ) 116 #define of_node_kobj(n) (&(n)->kobj) 117 #else 118 #define of_node_kobj(n) NULL 119 #endif 120 121 #ifdef CONFIG_OF_DYNAMIC 122 extern struct device_node *of_node_get(struct device_node *node); 123 extern void of_node_put(struct device_node *node); 124 #else /* CONFIG_OF_DYNAMIC */ 125 /* Dummy ref counting routines - to be implemented later */ 126 static inline struct device_node *of_node_get(struct device_node *node) 127 { 128 return node; 129 } 130 static inline void of_node_put(struct device_node *node) { } 131 #endif /* !CONFIG_OF_DYNAMIC */ 132 133 /* Pointer for first entry in chain of all nodes. */ 134 extern struct device_node *of_root; 135 extern struct device_node *of_chosen; 136 extern struct device_node *of_aliases; 137 extern struct device_node *of_stdout; 138 extern raw_spinlock_t devtree_lock; 139 140 /* 141 * struct device_node flag descriptions 142 * (need to be visible even when !CONFIG_OF) 143 */ 144 #define OF_DYNAMIC 1 /* (and properties) allocated via kmalloc */ 145 #define OF_DETACHED 2 /* detached from the device tree */ 146 #define OF_POPULATED 3 /* device already created */ 147 #define OF_POPULATED_BUS 4 /* platform bus created for children */ 148 #define OF_OVERLAY 5 /* allocated for an overlay */ 149 #define OF_OVERLAY_FREE_CSET 6 /* in overlay cset being freed */ 150 151 #define OF_BAD_ADDR ((u64)-1) 152 153 #ifdef CONFIG_OF 154 void of_core_init(void); 155 156 static inline bool is_of_node(const struct fwnode_handle *fwnode) 157 { 158 return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &of_fwnode_ops; 159 } 160 161 #define to_of_node(__fwnode) \ 162 ({ \ 163 typeof(__fwnode) __to_of_node_fwnode = (__fwnode); \ 164 \ 165 is_of_node(__to_of_node_fwnode) ? \ 166 container_of(__to_of_node_fwnode, \ 167 struct device_node, fwnode) : \ 168 NULL; \ 169 }) 170 171 #define of_fwnode_handle(node) \ 172 ({ \ 173 typeof(node) __of_fwnode_handle_node = (node); \ 174 \ 175 __of_fwnode_handle_node ? \ 176 &__of_fwnode_handle_node->fwnode : NULL; \ 177 }) 178 179 static inline bool of_have_populated_dt(void) 180 { 181 return of_root != NULL; 182 } 183 184 static inline bool of_node_is_root(const struct device_node *node) 185 { 186 return node && (node->parent == NULL); 187 } 188 189 static inline int of_node_check_flag(struct device_node *n, unsigned long flag) 190 { 191 return test_bit(flag, &n->_flags); 192 } 193 194 static inline int of_node_test_and_set_flag(struct device_node *n, 195 unsigned long flag) 196 { 197 return test_and_set_bit(flag, &n->_flags); 198 } 199 200 static inline void of_node_set_flag(struct device_node *n, unsigned long flag) 201 { 202 set_bit(flag, &n->_flags); 203 } 204 205 static inline void of_node_clear_flag(struct device_node *n, unsigned long flag) 206 { 207 clear_bit(flag, &n->_flags); 208 } 209 210 #if defined(CONFIG_OF_DYNAMIC) || defined(CONFIG_SPARC) 211 static inline int of_property_check_flag(struct property *p, unsigned long flag) 212 { 213 return test_bit(flag, &p->_flags); 214 } 215 216 static inline void of_property_set_flag(struct property *p, unsigned long flag) 217 { 218 set_bit(flag, &p->_flags); 219 } 220 221 static inline void of_property_clear_flag(struct property *p, unsigned long flag) 222 { 223 clear_bit(flag, &p->_flags); 224 } 225 #endif 226 227 extern struct device_node *__of_find_all_nodes(struct device_node *prev); 228 extern struct device_node *of_find_all_nodes(struct device_node *prev); 229 230 /* 231 * OF address retrieval & translation 232 */ 233 234 /* Helper to read a big number; size is in cells (not bytes) */ 235 static inline u64 of_read_number(const __be32 *cell, int size) 236 { 237 u64 r = 0; 238 while (size--) 239 r = (r << 32) | be32_to_cpu(*(cell++)); 240 return r; 241 } 242 243 /* Like of_read_number, but we want an unsigned long result */ 244 static inline unsigned long of_read_ulong(const __be32 *cell, int size) 245 { 246 /* toss away upper bits if unsigned long is smaller than u64 */ 247 return of_read_number(cell, size); 248 } 249 250 #if defined(CONFIG_SPARC) 251 #include <asm/prom.h> 252 #endif 253 254 #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) 255 #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) 256 257 extern bool of_node_name_eq(const struct device_node *np, const char *name); 258 extern bool of_node_name_prefix(const struct device_node *np, const char *prefix); 259 260 static inline const char *of_node_full_name(const struct device_node *np) 261 { 262 return np ? np->full_name : "<no-node>"; 263 } 264 265 #define for_each_of_allnodes_from(from, dn) \ 266 for (dn = __of_find_all_nodes(from); dn; dn = __of_find_all_nodes(dn)) 267 #define for_each_of_allnodes(dn) for_each_of_allnodes_from(NULL, dn) 268 extern struct device_node *of_find_node_by_name(struct device_node *from, 269 const char *name); 270 extern struct device_node *of_find_node_by_type(struct device_node *from, 271 const char *type); 272 extern struct device_node *of_find_compatible_node(struct device_node *from, 273 const char *type, const char *compat); 274 extern struct device_node *of_find_matching_node_and_match( 275 struct device_node *from, 276 const struct of_device_id *matches, 277 const struct of_device_id **match); 278 279 extern struct device_node *of_find_node_opts_by_path(const char *path, 280 const char **opts); 281 static inline struct device_node *of_find_node_by_path(const char *path) 282 { 283 return of_find_node_opts_by_path(path, NULL); 284 } 285 286 extern struct device_node *of_find_node_by_phandle(phandle handle); 287 extern struct device_node *of_get_parent(const struct device_node *node); 288 extern struct device_node *of_get_next_parent(struct device_node *node); 289 extern struct device_node *of_get_next_child(const struct device_node *node, 290 struct device_node *prev); 291 extern struct device_node *of_get_next_available_child( 292 const struct device_node *node, struct device_node *prev); 293 294 extern struct device_node *of_get_compatible_child(const struct device_node *parent, 295 const char *compatible); 296 extern struct device_node *of_get_child_by_name(const struct device_node *node, 297 const char *name); 298 299 /* cache lookup */ 300 extern struct device_node *of_find_next_cache_node(const struct device_node *); 301 extern int of_find_last_cache_level(unsigned int cpu); 302 extern struct device_node *of_find_node_with_property( 303 struct device_node *from, const char *prop_name); 304 305 extern struct property *of_find_property(const struct device_node *np, 306 const char *name, 307 int *lenp); 308 extern int of_property_count_elems_of_size(const struct device_node *np, 309 const char *propname, int elem_size); 310 extern int of_property_read_u32_index(const struct device_node *np, 311 const char *propname, 312 u32 index, u32 *out_value); 313 extern int of_property_read_u64_index(const struct device_node *np, 314 const char *propname, 315 u32 index, u64 *out_value); 316 extern int of_property_read_variable_u8_array(const struct device_node *np, 317 const char *propname, u8 *out_values, 318 size_t sz_min, size_t sz_max); 319 extern int of_property_read_variable_u16_array(const struct device_node *np, 320 const char *propname, u16 *out_values, 321 size_t sz_min, size_t sz_max); 322 extern int of_property_read_variable_u32_array(const struct device_node *np, 323 const char *propname, 324 u32 *out_values, 325 size_t sz_min, 326 size_t sz_max); 327 extern int of_property_read_u64(const struct device_node *np, 328 const char *propname, u64 *out_value); 329 extern int of_property_read_variable_u64_array(const struct device_node *np, 330 const char *propname, 331 u64 *out_values, 332 size_t sz_min, 333 size_t sz_max); 334 335 extern int of_property_read_string(const struct device_node *np, 336 const char *propname, 337 const char **out_string); 338 extern int of_property_match_string(const struct device_node *np, 339 const char *propname, 340 const char *string); 341 extern int of_property_read_string_helper(const struct device_node *np, 342 const char *propname, 343 const char **out_strs, size_t sz, int index); 344 extern int of_device_is_compatible(const struct device_node *device, 345 const char *); 346 extern int of_device_compatible_match(struct device_node *device, 347 const char *const *compat); 348 extern bool of_device_is_available(const struct device_node *device); 349 extern bool of_device_is_big_endian(const struct device_node *device); 350 extern const void *of_get_property(const struct device_node *node, 351 const char *name, 352 int *lenp); 353 extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); 354 extern struct device_node *of_get_next_cpu_node(struct device_node *prev); 355 356 #define for_each_property_of_node(dn, pp) \ 357 for (pp = dn->properties; pp != NULL; pp = pp->next) 358 359 extern int of_n_addr_cells(struct device_node *np); 360 extern int of_n_size_cells(struct device_node *np); 361 extern const struct of_device_id *of_match_node( 362 const struct of_device_id *matches, const struct device_node *node); 363 extern int of_modalias_node(struct device_node *node, char *modalias, int len); 364 extern void of_print_phandle_args(const char *msg, const struct of_phandle_args *args); 365 extern struct device_node *of_parse_phandle(const struct device_node *np, 366 const char *phandle_name, 367 int index); 368 extern int of_parse_phandle_with_args(const struct device_node *np, 369 const char *list_name, const char *cells_name, int index, 370 struct of_phandle_args *out_args); 371 extern int of_parse_phandle_with_args_map(const struct device_node *np, 372 const char *list_name, const char *stem_name, int index, 373 struct of_phandle_args *out_args); 374 extern int of_parse_phandle_with_fixed_args(const struct device_node *np, 375 const char *list_name, int cells_count, int index, 376 struct of_phandle_args *out_args); 377 extern int of_count_phandle_with_args(const struct device_node *np, 378 const char *list_name, const char *cells_name); 379 380 /* phandle iterator functions */ 381 extern int of_phandle_iterator_init(struct of_phandle_iterator *it, 382 const struct device_node *np, 383 const char *list_name, 384 const char *cells_name, 385 int cell_count); 386 387 extern int of_phandle_iterator_next(struct of_phandle_iterator *it); 388 extern int of_phandle_iterator_args(struct of_phandle_iterator *it, 389 uint32_t *args, 390 int size); 391 392 extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)); 393 extern int of_alias_get_id(struct device_node *np, const char *stem); 394 extern int of_alias_get_highest_id(const char *stem); 395 extern int of_alias_get_alias_list(const struct of_device_id *matches, 396 const char *stem, unsigned long *bitmap, 397 unsigned int nbits); 398 399 extern int of_machine_is_compatible(const char *compat); 400 401 extern int of_add_property(struct device_node *np, struct property *prop); 402 extern int of_remove_property(struct device_node *np, struct property *prop); 403 extern int of_update_property(struct device_node *np, struct property *newprop); 404 405 /* For updating the device tree at runtime */ 406 #define OF_RECONFIG_ATTACH_NODE 0x0001 407 #define OF_RECONFIG_DETACH_NODE 0x0002 408 #define OF_RECONFIG_ADD_PROPERTY 0x0003 409 #define OF_RECONFIG_REMOVE_PROPERTY 0x0004 410 #define OF_RECONFIG_UPDATE_PROPERTY 0x0005 411 412 extern int of_attach_node(struct device_node *); 413 extern int of_detach_node(struct device_node *); 414 415 #define of_match_ptr(_ptr) (_ptr) 416 417 /** 418 * of_property_read_u8_array - Find and read an array of u8 from a property. 419 * 420 * @np: device node from which the property value is to be read. 421 * @propname: name of the property to be searched. 422 * @out_values: pointer to return value, modified only if return value is 0. 423 * @sz: number of array elements to read 424 * 425 * Search for a property in a device node and read 8-bit value(s) from 426 * it. Returns 0 on success, -EINVAL if the property does not exist, 427 * -ENODATA if property does not have a value, and -EOVERFLOW if the 428 * property data isn't large enough. 429 * 430 * dts entry of array should be like: 431 * property = /bits/ 8 <0x50 0x60 0x70>; 432 * 433 * The out_values is modified only if a valid u8 value can be decoded. 434 */ 435 static inline int of_property_read_u8_array(const struct device_node *np, 436 const char *propname, 437 u8 *out_values, size_t sz) 438 { 439 int ret = of_property_read_variable_u8_array(np, propname, out_values, 440 sz, 0); 441 if (ret >= 0) 442 return 0; 443 else 444 return ret; 445 } 446 447 /** 448 * of_property_read_u16_array - Find and read an array of u16 from a property. 449 * 450 * @np: device node from which the property value is to be read. 451 * @propname: name of the property to be searched. 452 * @out_values: pointer to return value, modified only if return value is 0. 453 * @sz: number of array elements to read 454 * 455 * Search for a property in a device node and read 16-bit value(s) from 456 * it. Returns 0 on success, -EINVAL if the property does not exist, 457 * -ENODATA if property does not have a value, and -EOVERFLOW if the 458 * property data isn't large enough. 459 * 460 * dts entry of array should be like: 461 * property = /bits/ 16 <0x5000 0x6000 0x7000>; 462 * 463 * The out_values is modified only if a valid u16 value can be decoded. 464 */ 465 static inline int of_property_read_u16_array(const struct device_node *np, 466 const char *propname, 467 u16 *out_values, size_t sz) 468 { 469 int ret = of_property_read_variable_u16_array(np, propname, out_values, 470 sz, 0); 471 if (ret >= 0) 472 return 0; 473 else 474 return ret; 475 } 476 477 /** 478 * of_property_read_u32_array - Find and read an array of 32 bit integers 479 * from a property. 480 * 481 * @np: device node from which the property value is to be read. 482 * @propname: name of the property to be searched. 483 * @out_values: pointer to return value, modified only if return value is 0. 484 * @sz: number of array elements to read 485 * 486 * Search for a property in a device node and read 32-bit value(s) from 487 * it. Returns 0 on success, -EINVAL if the property does not exist, 488 * -ENODATA if property does not have a value, and -EOVERFLOW if the 489 * property data isn't large enough. 490 * 491 * The out_values is modified only if a valid u32 value can be decoded. 492 */ 493 static inline int of_property_read_u32_array(const struct device_node *np, 494 const char *propname, 495 u32 *out_values, size_t sz) 496 { 497 int ret = of_property_read_variable_u32_array(np, propname, out_values, 498 sz, 0); 499 if (ret >= 0) 500 return 0; 501 else 502 return ret; 503 } 504 505 /** 506 * of_property_read_u64_array - Find and read an array of 64 bit integers 507 * from a property. 508 * 509 * @np: device node from which the property value is to be read. 510 * @propname: name of the property to be searched. 511 * @out_values: pointer to return value, modified only if return value is 0. 512 * @sz: number of array elements to read 513 * 514 * Search for a property in a device node and read 64-bit value(s) from 515 * it. Returns 0 on success, -EINVAL if the property does not exist, 516 * -ENODATA if property does not have a value, and -EOVERFLOW if the 517 * property data isn't large enough. 518 * 519 * The out_values is modified only if a valid u64 value can be decoded. 520 */ 521 static inline int of_property_read_u64_array(const struct device_node *np, 522 const char *propname, 523 u64 *out_values, size_t sz) 524 { 525 int ret = of_property_read_variable_u64_array(np, propname, out_values, 526 sz, 0); 527 if (ret >= 0) 528 return 0; 529 else 530 return ret; 531 } 532 533 /* 534 * struct property *prop; 535 * const __be32 *p; 536 * u32 u; 537 * 538 * of_property_for_each_u32(np, "propname", prop, p, u) 539 * printk("U32 value: %x\n", u); 540 */ 541 const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur, 542 u32 *pu); 543 /* 544 * struct property *prop; 545 * const char *s; 546 * 547 * of_property_for_each_string(np, "propname", prop, s) 548 * printk("String value: %s\n", s); 549 */ 550 const char *of_prop_next_string(struct property *prop, const char *cur); 551 552 bool of_console_check(struct device_node *dn, char *name, int index); 553 554 extern int of_cpu_node_to_id(struct device_node *np); 555 556 int of_map_rid(struct device_node *np, u32 rid, 557 const char *map_name, const char *map_mask_name, 558 struct device_node **target, u32 *id_out); 559 560 #else /* CONFIG_OF */ 561 562 static inline void of_core_init(void) 563 { 564 } 565 566 static inline bool is_of_node(const struct fwnode_handle *fwnode) 567 { 568 return false; 569 } 570 571 static inline struct device_node *to_of_node(const struct fwnode_handle *fwnode) 572 { 573 return NULL; 574 } 575 576 static inline bool of_node_name_eq(const struct device_node *np, const char *name) 577 { 578 return false; 579 } 580 581 static inline bool of_node_name_prefix(const struct device_node *np, const char *prefix) 582 { 583 return false; 584 } 585 586 static inline const char* of_node_full_name(const struct device_node *np) 587 { 588 return "<no-node>"; 589 } 590 591 static inline struct device_node *of_find_node_by_name(struct device_node *from, 592 const char *name) 593 { 594 return NULL; 595 } 596 597 static inline struct device_node *of_find_node_by_type(struct device_node *from, 598 const char *type) 599 { 600 return NULL; 601 } 602 603 static inline struct device_node *of_find_matching_node_and_match( 604 struct device_node *from, 605 const struct of_device_id *matches, 606 const struct of_device_id **match) 607 { 608 return NULL; 609 } 610 611 static inline struct device_node *of_find_node_by_path(const char *path) 612 { 613 return NULL; 614 } 615 616 static inline struct device_node *of_find_node_opts_by_path(const char *path, 617 const char **opts) 618 { 619 return NULL; 620 } 621 622 static inline struct device_node *of_find_node_by_phandle(phandle handle) 623 { 624 return NULL; 625 } 626 627 static inline struct device_node *of_get_parent(const struct device_node *node) 628 { 629 return NULL; 630 } 631 632 static inline struct device_node *of_get_next_child( 633 const struct device_node *node, struct device_node *prev) 634 { 635 return NULL; 636 } 637 638 static inline struct device_node *of_get_next_available_child( 639 const struct device_node *node, struct device_node *prev) 640 { 641 return NULL; 642 } 643 644 static inline struct device_node *of_find_node_with_property( 645 struct device_node *from, const char *prop_name) 646 { 647 return NULL; 648 } 649 650 #define of_fwnode_handle(node) NULL 651 652 static inline bool of_have_populated_dt(void) 653 { 654 return false; 655 } 656 657 static inline struct device_node *of_get_compatible_child(const struct device_node *parent, 658 const char *compatible) 659 { 660 return NULL; 661 } 662 663 static inline struct device_node *of_get_child_by_name( 664 const struct device_node *node, 665 const char *name) 666 { 667 return NULL; 668 } 669 670 static inline int of_device_is_compatible(const struct device_node *device, 671 const char *name) 672 { 673 return 0; 674 } 675 676 static inline int of_device_compatible_match(struct device_node *device, 677 const char *const *compat) 678 { 679 return 0; 680 } 681 682 static inline bool of_device_is_available(const struct device_node *device) 683 { 684 return false; 685 } 686 687 static inline bool of_device_is_big_endian(const struct device_node *device) 688 { 689 return false; 690 } 691 692 static inline struct property *of_find_property(const struct device_node *np, 693 const char *name, 694 int *lenp) 695 { 696 return NULL; 697 } 698 699 static inline struct device_node *of_find_compatible_node( 700 struct device_node *from, 701 const char *type, 702 const char *compat) 703 { 704 return NULL; 705 } 706 707 static inline int of_property_count_elems_of_size(const struct device_node *np, 708 const char *propname, int elem_size) 709 { 710 return -ENOSYS; 711 } 712 713 static inline int of_property_read_u8_array(const struct device_node *np, 714 const char *propname, u8 *out_values, size_t sz) 715 { 716 return -ENOSYS; 717 } 718 719 static inline int of_property_read_u16_array(const struct device_node *np, 720 const char *propname, u16 *out_values, size_t sz) 721 { 722 return -ENOSYS; 723 } 724 725 static inline int of_property_read_u32_array(const struct device_node *np, 726 const char *propname, 727 u32 *out_values, size_t sz) 728 { 729 return -ENOSYS; 730 } 731 732 static inline int of_property_read_u64_array(const struct device_node *np, 733 const char *propname, 734 u64 *out_values, size_t sz) 735 { 736 return -ENOSYS; 737 } 738 739 static inline int of_property_read_u32_index(const struct device_node *np, 740 const char *propname, u32 index, u32 *out_value) 741 { 742 return -ENOSYS; 743 } 744 745 static inline int of_property_read_u64_index(const struct device_node *np, 746 const char *propname, u32 index, u64 *out_value) 747 { 748 return -ENOSYS; 749 } 750 751 static inline const void *of_get_property(const struct device_node *node, 752 const char *name, 753 int *lenp) 754 { 755 return NULL; 756 } 757 758 static inline struct device_node *of_get_cpu_node(int cpu, 759 unsigned int *thread) 760 { 761 return NULL; 762 } 763 764 static inline struct device_node *of_get_next_cpu_node(struct device_node *prev) 765 { 766 return NULL; 767 } 768 769 static inline int of_n_addr_cells(struct device_node *np) 770 { 771 return 0; 772 773 } 774 static inline int of_n_size_cells(struct device_node *np) 775 { 776 return 0; 777 } 778 779 static inline int of_property_read_variable_u8_array(const struct device_node *np, 780 const char *propname, u8 *out_values, 781 size_t sz_min, size_t sz_max) 782 { 783 return -ENOSYS; 784 } 785 786 static inline int of_property_read_variable_u16_array(const struct device_node *np, 787 const char *propname, u16 *out_values, 788 size_t sz_min, size_t sz_max) 789 { 790 return -ENOSYS; 791 } 792 793 static inline int of_property_read_variable_u32_array(const struct device_node *np, 794 const char *propname, 795 u32 *out_values, 796 size_t sz_min, 797 size_t sz_max) 798 { 799 return -ENOSYS; 800 } 801 802 static inline int of_property_read_u64(const struct device_node *np, 803 const char *propname, u64 *out_value) 804 { 805 return -ENOSYS; 806 } 807 808 static inline int of_property_read_variable_u64_array(const struct device_node *np, 809 const char *propname, 810 u64 *out_values, 811 size_t sz_min, 812 size_t sz_max) 813 { 814 return -ENOSYS; 815 } 816 817 static inline int of_property_read_string(const struct device_node *np, 818 const char *propname, 819 const char **out_string) 820 { 821 return -ENOSYS; 822 } 823 824 static inline int of_property_match_string(const struct device_node *np, 825 const char *propname, 826 const char *string) 827 { 828 return -ENOSYS; 829 } 830 831 static inline int of_property_read_string_helper(const struct device_node *np, 832 const char *propname, 833 const char **out_strs, size_t sz, int index) 834 { 835 return -ENOSYS; 836 } 837 838 static inline struct device_node *of_parse_phandle(const struct device_node *np, 839 const char *phandle_name, 840 int index) 841 { 842 return NULL; 843 } 844 845 static inline int of_parse_phandle_with_args(const struct device_node *np, 846 const char *list_name, 847 const char *cells_name, 848 int index, 849 struct of_phandle_args *out_args) 850 { 851 return -ENOSYS; 852 } 853 854 static inline int of_parse_phandle_with_args_map(const struct device_node *np, 855 const char *list_name, 856 const char *stem_name, 857 int index, 858 struct of_phandle_args *out_args) 859 { 860 return -ENOSYS; 861 } 862 863 static inline int of_parse_phandle_with_fixed_args(const struct device_node *np, 864 const char *list_name, int cells_count, int index, 865 struct of_phandle_args *out_args) 866 { 867 return -ENOSYS; 868 } 869 870 static inline int of_count_phandle_with_args(struct device_node *np, 871 const char *list_name, 872 const char *cells_name) 873 { 874 return -ENOSYS; 875 } 876 877 static inline int of_phandle_iterator_init(struct of_phandle_iterator *it, 878 const struct device_node *np, 879 const char *list_name, 880 const char *cells_name, 881 int cell_count) 882 { 883 return -ENOSYS; 884 } 885 886 static inline int of_phandle_iterator_next(struct of_phandle_iterator *it) 887 { 888 return -ENOSYS; 889 } 890 891 static inline int of_phandle_iterator_args(struct of_phandle_iterator *it, 892 uint32_t *args, 893 int size) 894 { 895 return 0; 896 } 897 898 static inline int of_alias_get_id(struct device_node *np, const char *stem) 899 { 900 return -ENOSYS; 901 } 902 903 static inline int of_alias_get_highest_id(const char *stem) 904 { 905 return -ENOSYS; 906 } 907 908 static inline int of_alias_get_alias_list(const struct of_device_id *matches, 909 const char *stem, unsigned long *bitmap, 910 unsigned int nbits) 911 { 912 return -ENOSYS; 913 } 914 915 static inline int of_machine_is_compatible(const char *compat) 916 { 917 return 0; 918 } 919 920 static inline bool of_console_check(const struct device_node *dn, const char *name, int index) 921 { 922 return false; 923 } 924 925 static inline const __be32 *of_prop_next_u32(struct property *prop, 926 const __be32 *cur, u32 *pu) 927 { 928 return NULL; 929 } 930 931 static inline const char *of_prop_next_string(struct property *prop, 932 const char *cur) 933 { 934 return NULL; 935 } 936 937 static inline int of_node_check_flag(struct device_node *n, unsigned long flag) 938 { 939 return 0; 940 } 941 942 static inline int of_node_test_and_set_flag(struct device_node *n, 943 unsigned long flag) 944 { 945 return 0; 946 } 947 948 static inline void of_node_set_flag(struct device_node *n, unsigned long flag) 949 { 950 } 951 952 static inline void of_node_clear_flag(struct device_node *n, unsigned long flag) 953 { 954 } 955 956 static inline int of_property_check_flag(struct property *p, unsigned long flag) 957 { 958 return 0; 959 } 960 961 static inline void of_property_set_flag(struct property *p, unsigned long flag) 962 { 963 } 964 965 static inline void of_property_clear_flag(struct property *p, unsigned long flag) 966 { 967 } 968 969 static inline int of_cpu_node_to_id(struct device_node *np) 970 { 971 return -ENODEV; 972 } 973 974 static inline int of_map_rid(struct device_node *np, u32 rid, 975 const char *map_name, const char *map_mask_name, 976 struct device_node **target, u32 *id_out) 977 { 978 return -EINVAL; 979 } 980 981 #define of_match_ptr(_ptr) NULL 982 #define of_match_node(_matches, _node) NULL 983 #endif /* CONFIG_OF */ 984 985 /* Default string compare functions, Allow arch asm/prom.h to override */ 986 #if !defined(of_compat_cmp) 987 #define of_compat_cmp(s1, s2, l) strcasecmp((s1), (s2)) 988 #define of_prop_cmp(s1, s2) strcmp((s1), (s2)) 989 #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) 990 #endif 991 992 static inline int of_prop_val_eq(struct property *p1, struct property *p2) 993 { 994 return p1->length == p2->length && 995 !memcmp(p1->value, p2->value, (size_t)p1->length); 996 } 997 998 #if defined(CONFIG_OF) && defined(CONFIG_NUMA) 999 extern int of_node_to_nid(struct device_node *np); 1000 #else 1001 static inline int of_node_to_nid(struct device_node *device) 1002 { 1003 return NUMA_NO_NODE; 1004 } 1005 #endif 1006 1007 #ifdef CONFIG_OF_NUMA 1008 extern int of_numa_init(void); 1009 #else 1010 static inline int of_numa_init(void) 1011 { 1012 return -ENOSYS; 1013 } 1014 #endif 1015 1016 static inline struct device_node *of_find_matching_node( 1017 struct device_node *from, 1018 const struct of_device_id *matches) 1019 { 1020 return of_find_matching_node_and_match(from, matches, NULL); 1021 } 1022 1023 static inline const char *of_node_get_device_type(const struct device_node *np) 1024 { 1025 return of_get_property(np, "device_type", NULL); 1026 } 1027 1028 static inline bool of_node_is_type(const struct device_node *np, const char *type) 1029 { 1030 const char *match = of_node_get_device_type(np); 1031 1032 return np && match && type && !strcmp(match, type); 1033 } 1034 1035 /** 1036 * of_property_count_u8_elems - Count the number of u8 elements in a property 1037 * 1038 * @np: device node from which the property value is to be read. 1039 * @propname: name of the property to be searched. 1040 * 1041 * Search for a property in a device node and count the number of u8 elements 1042 * in it. Returns number of elements on sucess, -EINVAL if the property does 1043 * not exist or its length does not match a multiple of u8 and -ENODATA if the 1044 * property does not have a value. 1045 */ 1046 static inline int of_property_count_u8_elems(const struct device_node *np, 1047 const char *propname) 1048 { 1049 return of_property_count_elems_of_size(np, propname, sizeof(u8)); 1050 } 1051 1052 /** 1053 * of_property_count_u16_elems - Count the number of u16 elements in a property 1054 * 1055 * @np: device node from which the property value is to be read. 1056 * @propname: name of the property to be searched. 1057 * 1058 * Search for a property in a device node and count the number of u16 elements 1059 * in it. Returns number of elements on sucess, -EINVAL if the property does 1060 * not exist or its length does not match a multiple of u16 and -ENODATA if the 1061 * property does not have a value. 1062 */ 1063 static inline int of_property_count_u16_elems(const struct device_node *np, 1064 const char *propname) 1065 { 1066 return of_property_count_elems_of_size(np, propname, sizeof(u16)); 1067 } 1068 1069 /** 1070 * of_property_count_u32_elems - Count the number of u32 elements in a property 1071 * 1072 * @np: device node from which the property value is to be read. 1073 * @propname: name of the property to be searched. 1074 * 1075 * Search for a property in a device node and count the number of u32 elements 1076 * in it. Returns number of elements on sucess, -EINVAL if the property does 1077 * not exist or its length does not match a multiple of u32 and -ENODATA if the 1078 * property does not have a value. 1079 */ 1080 static inline int of_property_count_u32_elems(const struct device_node *np, 1081 const char *propname) 1082 { 1083 return of_property_count_elems_of_size(np, propname, sizeof(u32)); 1084 } 1085 1086 /** 1087 * of_property_count_u64_elems - Count the number of u64 elements in a property 1088 * 1089 * @np: device node from which the property value is to be read. 1090 * @propname: name of the property to be searched. 1091 * 1092 * Search for a property in a device node and count the number of u64 elements 1093 * in it. Returns number of elements on sucess, -EINVAL if the property does 1094 * not exist or its length does not match a multiple of u64 and -ENODATA if the 1095 * property does not have a value. 1096 */ 1097 static inline int of_property_count_u64_elems(const struct device_node *np, 1098 const char *propname) 1099 { 1100 return of_property_count_elems_of_size(np, propname, sizeof(u64)); 1101 } 1102 1103 /** 1104 * of_property_read_string_array() - Read an array of strings from a multiple 1105 * strings property. 1106 * @np: device node from which the property value is to be read. 1107 * @propname: name of the property to be searched. 1108 * @out_strs: output array of string pointers. 1109 * @sz: number of array elements to read. 1110 * 1111 * Search for a property in a device tree node and retrieve a list of 1112 * terminated string values (pointer to data, not a copy) in that property. 1113 * 1114 * If @out_strs is NULL, the number of strings in the property is returned. 1115 */ 1116 static inline int of_property_read_string_array(const struct device_node *np, 1117 const char *propname, const char **out_strs, 1118 size_t sz) 1119 { 1120 return of_property_read_string_helper(np, propname, out_strs, sz, 0); 1121 } 1122 1123 /** 1124 * of_property_count_strings() - Find and return the number of strings from a 1125 * multiple strings property. 1126 * @np: device node from which the property value is to be read. 1127 * @propname: name of the property to be searched. 1128 * 1129 * Search for a property in a device tree node and retrieve the number of null 1130 * terminated string contain in it. Returns the number of strings on 1131 * success, -EINVAL if the property does not exist, -ENODATA if property 1132 * does not have a value, and -EILSEQ if the string is not null-terminated 1133 * within the length of the property data. 1134 */ 1135 static inline int of_property_count_strings(const struct device_node *np, 1136 const char *propname) 1137 { 1138 return of_property_read_string_helper(np, propname, NULL, 0, 0); 1139 } 1140 1141 /** 1142 * of_property_read_string_index() - Find and read a string from a multiple 1143 * strings property. 1144 * @np: device node from which the property value is to be read. 1145 * @propname: name of the property to be searched. 1146 * @index: index of the string in the list of strings 1147 * @out_string: pointer to null terminated return string, modified only if 1148 * return value is 0. 1149 * 1150 * Search for a property in a device tree node and retrieve a null 1151 * terminated string value (pointer to data, not a copy) in the list of strings 1152 * contained in that property. 1153 * Returns 0 on success, -EINVAL if the property does not exist, -ENODATA if 1154 * property does not have a value, and -EILSEQ if the string is not 1155 * null-terminated within the length of the property data. 1156 * 1157 * The out_string pointer is modified only if a valid string can be decoded. 1158 */ 1159 static inline int of_property_read_string_index(const struct device_node *np, 1160 const char *propname, 1161 int index, const char **output) 1162 { 1163 int rc = of_property_read_string_helper(np, propname, output, 1, index); 1164 return rc < 0 ? rc : 0; 1165 } 1166 1167 /** 1168 * of_property_read_bool - Findfrom a property 1169 * @np: device node from which the property value is to be read. 1170 * @propname: name of the property to be searched. 1171 * 1172 * Search for a property in a device node. 1173 * Returns true if the property exists false otherwise. 1174 */ 1175 static inline bool of_property_read_bool(const struct device_node *np, 1176 const char *propname) 1177 { 1178 struct property *prop = of_find_property(np, propname, NULL); 1179 1180 return prop ? true : false; 1181 } 1182 1183 static inline int of_property_read_u8(const struct device_node *np, 1184 const char *propname, 1185 u8 *out_value) 1186 { 1187 return of_property_read_u8_array(np, propname, out_value, 1); 1188 } 1189 1190 static inline int of_property_read_u16(const struct device_node *np, 1191 const char *propname, 1192 u16 *out_value) 1193 { 1194 return of_property_read_u16_array(np, propname, out_value, 1); 1195 } 1196 1197 static inline int of_property_read_u32(const struct device_node *np, 1198 const char *propname, 1199 u32 *out_value) 1200 { 1201 return of_property_read_u32_array(np, propname, out_value, 1); 1202 } 1203 1204 static inline int of_property_read_s32(const struct device_node *np, 1205 const char *propname, 1206 s32 *out_value) 1207 { 1208 return of_property_read_u32(np, propname, (u32*) out_value); 1209 } 1210 1211 #define of_for_each_phandle(it, err, np, ln, cn, cc) \ 1212 for (of_phandle_iterator_init((it), (np), (ln), (cn), (cc)), \ 1213 err = of_phandle_iterator_next(it); \ 1214 err == 0; \ 1215 err = of_phandle_iterator_next(it)) 1216 1217 #define of_property_for_each_u32(np, propname, prop, p, u) \ 1218 for (prop = of_find_property(np, propname, NULL), \ 1219 p = of_prop_next_u32(prop, NULL, &u); \ 1220 p; \ 1221 p = of_prop_next_u32(prop, p, &u)) 1222 1223 #define of_property_for_each_string(np, propname, prop, s) \ 1224 for (prop = of_find_property(np, propname, NULL), \ 1225 s = of_prop_next_string(prop, NULL); \ 1226 s; \ 1227 s = of_prop_next_string(prop, s)) 1228 1229 #define for_each_node_by_name(dn, name) \ 1230 for (dn = of_find_node_by_name(NULL, name); dn; \ 1231 dn = of_find_node_by_name(dn, name)) 1232 #define for_each_node_by_type(dn, type) \ 1233 for (dn = of_find_node_by_type(NULL, type); dn; \ 1234 dn = of_find_node_by_type(dn, type)) 1235 #define for_each_compatible_node(dn, type, compatible) \ 1236 for (dn = of_find_compatible_node(NULL, type, compatible); dn; \ 1237 dn = of_find_compatible_node(dn, type, compatible)) 1238 #define for_each_matching_node(dn, matches) \ 1239 for (dn = of_find_matching_node(NULL, matches); dn; \ 1240 dn = of_find_matching_node(dn, matches)) 1241 #define for_each_matching_node_and_match(dn, matches, match) \ 1242 for (dn = of_find_matching_node_and_match(NULL, matches, match); \ 1243 dn; dn = of_find_matching_node_and_match(dn, matches, match)) 1244 1245 #define for_each_child_of_node(parent, child) \ 1246 for (child = of_get_next_child(parent, NULL); child != NULL; \ 1247 child = of_get_next_child(parent, child)) 1248 #define for_each_available_child_of_node(parent, child) \ 1249 for (child = of_get_next_available_child(parent, NULL); child != NULL; \ 1250 child = of_get_next_available_child(parent, child)) 1251 1252 #define for_each_of_cpu_node(cpu) \ 1253 for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \ 1254 cpu = of_get_next_cpu_node(cpu)) 1255 1256 #define for_each_node_with_property(dn, prop_name) \ 1257 for (dn = of_find_node_with_property(NULL, prop_name); dn; \ 1258 dn = of_find_node_with_property(dn, prop_name)) 1259 1260 static inline int of_get_child_count(const struct device_node *np) 1261 { 1262 struct device_node *child; 1263 int num = 0; 1264 1265 for_each_child_of_node(np, child) 1266 num++; 1267 1268 return num; 1269 } 1270 1271 static inline int of_get_available_child_count(const struct device_node *np) 1272 { 1273 struct device_node *child; 1274 int num = 0; 1275 1276 for_each_available_child_of_node(np, child) 1277 num++; 1278 1279 return num; 1280 } 1281 1282 #if defined(CONFIG_OF) && !defined(MODULE) 1283 #define _OF_DECLARE(table, name, compat, fn, fn_type) \ 1284 static const struct of_device_id __of_table_##name \ 1285 __used __section(__##table##_of_table) \ 1286 = { .compatible = compat, \ 1287 .data = (fn == (fn_type)NULL) ? fn : fn } 1288 #else 1289 #define _OF_DECLARE(table, name, compat, fn, fn_type) \ 1290 static const struct of_device_id __of_table_##name \ 1291 __attribute__((unused)) \ 1292 = { .compatible = compat, \ 1293 .data = (fn == (fn_type)NULL) ? fn : fn } 1294 #endif 1295 1296 typedef int (*of_init_fn_2)(struct device_node *, struct device_node *); 1297 typedef int (*of_init_fn_1_ret)(struct device_node *); 1298 typedef void (*of_init_fn_1)(struct device_node *); 1299 1300 #define OF_DECLARE_1(table, name, compat, fn) \ 1301 _OF_DECLARE(table, name, compat, fn, of_init_fn_1) 1302 #define OF_DECLARE_1_RET(table, name, compat, fn) \ 1303 _OF_DECLARE(table, name, compat, fn, of_init_fn_1_ret) 1304 #define OF_DECLARE_2(table, name, compat, fn) \ 1305 _OF_DECLARE(table, name, compat, fn, of_init_fn_2) 1306 1307 /** 1308 * struct of_changeset_entry - Holds a changeset entry 1309 * 1310 * @node: list_head for the log list 1311 * @action: notifier action 1312 * @np: pointer to the device node affected 1313 * @prop: pointer to the property affected 1314 * @old_prop: hold a pointer to the original property 1315 * 1316 * Every modification of the device tree during a changeset 1317 * is held in a list of of_changeset_entry structures. 1318 * That way we can recover from a partial application, or we can 1319 * revert the changeset 1320 */ 1321 struct of_changeset_entry { 1322 struct list_head node; 1323 unsigned long action; 1324 struct device_node *np; 1325 struct property *prop; 1326 struct property *old_prop; 1327 }; 1328 1329 /** 1330 * struct of_changeset - changeset tracker structure 1331 * 1332 * @entries: list_head for the changeset entries 1333 * 1334 * changesets are a convenient way to apply bulk changes to the 1335 * live tree. In case of an error, changes are rolled-back. 1336 * changesets live on after initial application, and if not 1337 * destroyed after use, they can be reverted in one single call. 1338 */ 1339 struct of_changeset { 1340 struct list_head entries; 1341 }; 1342 1343 enum of_reconfig_change { 1344 OF_RECONFIG_NO_CHANGE = 0, 1345 OF_RECONFIG_CHANGE_ADD, 1346 OF_RECONFIG_CHANGE_REMOVE, 1347 }; 1348 1349 #ifdef CONFIG_OF_DYNAMIC 1350 extern int of_reconfig_notifier_register(struct notifier_block *); 1351 extern int of_reconfig_notifier_unregister(struct notifier_block *); 1352 extern int of_reconfig_notify(unsigned long, struct of_reconfig_data *rd); 1353 extern int of_reconfig_get_state_change(unsigned long action, 1354 struct of_reconfig_data *arg); 1355 1356 extern void of_changeset_init(struct of_changeset *ocs); 1357 extern void of_changeset_destroy(struct of_changeset *ocs); 1358 extern int of_changeset_apply(struct of_changeset *ocs); 1359 extern int of_changeset_revert(struct of_changeset *ocs); 1360 extern int of_changeset_action(struct of_changeset *ocs, 1361 unsigned long action, struct device_node *np, 1362 struct property *prop); 1363 1364 static inline int of_changeset_attach_node(struct of_changeset *ocs, 1365 struct device_node *np) 1366 { 1367 return of_changeset_action(ocs, OF_RECONFIG_ATTACH_NODE, np, NULL); 1368 } 1369 1370 static inline int of_changeset_detach_node(struct of_changeset *ocs, 1371 struct device_node *np) 1372 { 1373 return of_changeset_action(ocs, OF_RECONFIG_DETACH_NODE, np, NULL); 1374 } 1375 1376 static inline int of_changeset_add_property(struct of_changeset *ocs, 1377 struct device_node *np, struct property *prop) 1378 { 1379 return of_changeset_action(ocs, OF_RECONFIG_ADD_PROPERTY, np, prop); 1380 } 1381 1382 static inline int of_changeset_remove_property(struct of_changeset *ocs, 1383 struct device_node *np, struct property *prop) 1384 { 1385 return of_changeset_action(ocs, OF_RECONFIG_REMOVE_PROPERTY, np, prop); 1386 } 1387 1388 static inline int of_changeset_update_property(struct of_changeset *ocs, 1389 struct device_node *np, struct property *prop) 1390 { 1391 return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop); 1392 } 1393 #else /* CONFIG_OF_DYNAMIC */ 1394 static inline int of_reconfig_notifier_register(struct notifier_block *nb) 1395 { 1396 return -EINVAL; 1397 } 1398 static inline int of_reconfig_notifier_unregister(struct notifier_block *nb) 1399 { 1400 return -EINVAL; 1401 } 1402 static inline int of_reconfig_notify(unsigned long action, 1403 struct of_reconfig_data *arg) 1404 { 1405 return -EINVAL; 1406 } 1407 static inline int of_reconfig_get_state_change(unsigned long action, 1408 struct of_reconfig_data *arg) 1409 { 1410 return -EINVAL; 1411 } 1412 #endif /* CONFIG_OF_DYNAMIC */ 1413 1414 /** 1415 * of_device_is_system_power_controller - Tells if system-power-controller is found for device_node 1416 * @np: Pointer to the given device_node 1417 * 1418 * return true if present false otherwise 1419 */ 1420 static inline bool of_device_is_system_power_controller(const struct device_node *np) 1421 { 1422 return of_property_read_bool(np, "system-power-controller"); 1423 } 1424 1425 /** 1426 * Overlay support 1427 */ 1428 1429 enum of_overlay_notify_action { 1430 OF_OVERLAY_PRE_APPLY = 0, 1431 OF_OVERLAY_POST_APPLY, 1432 OF_OVERLAY_PRE_REMOVE, 1433 OF_OVERLAY_POST_REMOVE, 1434 }; 1435 1436 struct of_overlay_notify_data { 1437 struct device_node *overlay; 1438 struct device_node *target; 1439 }; 1440 1441 #ifdef CONFIG_OF_OVERLAY 1442 1443 int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size, 1444 int *ovcs_id); 1445 int of_overlay_remove(int *ovcs_id); 1446 int of_overlay_remove_all(void); 1447 1448 int of_overlay_notifier_register(struct notifier_block *nb); 1449 int of_overlay_notifier_unregister(struct notifier_block *nb); 1450 1451 #else 1452 1453 static inline int of_overlay_fdt_apply(void *overlay_fdt, int *ovcs_id) 1454 { 1455 return -ENOTSUPP; 1456 } 1457 1458 static inline int of_overlay_remove(int *ovcs_id) 1459 { 1460 return -ENOTSUPP; 1461 } 1462 1463 static inline int of_overlay_remove_all(void) 1464 { 1465 return -ENOTSUPP; 1466 } 1467 1468 static inline int of_overlay_notifier_register(struct notifier_block *nb) 1469 { 1470 return 0; 1471 } 1472 1473 static inline int of_overlay_notifier_unregister(struct notifier_block *nb) 1474 { 1475 return 0; 1476 } 1477 1478 #endif 1479 1480 #endif /* _LINUX_OF_H */ 1481