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