File Index
Files and directories
Sign in
FILE

property.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/property.h C
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * property.h - Unified device property interface.
  4 *
  5 * Copyright (C) 2014, Intel Corporation
  6 * Authors: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  7 *          Mika Westerberg <mika.westerberg@linux.intel.com>
  8 */
  9
 10#ifndef _LINUX_PROPERTY_H_
 11#define _LINUX_PROPERTY_H_
 12
 13#include <linux/args.h>
 14#include <linux/array_size.h>
 15#include <linux/bits.h>
 16#include <linux/cleanup.h>
 17#include <linux/fwnode.h>
 18#include <linux/stddef.h>
 19#include <linux/types.h>
 20#include <linux/util_macros.h>
 21
 22struct device;
 23
 24enum dev_prop_type {
 25	DEV_PROP_U8,
 26	DEV_PROP_U16,
 27	DEV_PROP_U32,
 28	DEV_PROP_U64,
 29	DEV_PROP_STRING,
 30	DEV_PROP_REF,
 31};
 32
 33const struct fwnode_handle *__dev_fwnode_const(const struct device *dev);
 34struct fwnode_handle *__dev_fwnode(struct device *dev);
 35#define dev_fwnode(dev)							\
 36	_Generic((dev),							\
 37		 const struct device *: __dev_fwnode_const,	\
 38		 struct device *: __dev_fwnode)(dev)
 39
 40bool device_property_present(const struct device *dev, const char *propname);
 41bool device_property_read_bool(const struct device *dev, const char *propname);
 42int device_property_read_u8_array(const struct device *dev, const char *propname,
 43				  u8 *val, size_t nval);
 44int device_property_read_u16_array(const struct device *dev, const char *propname,
 45				   u16 *val, size_t nval);
 46int device_property_read_u32_array(const struct device *dev, const char *propname,
 47				   u32 *val, size_t nval);
 48int device_property_read_u64_array(const struct device *dev, const char *propname,
 49				   u64 *val, size_t nval);
 50int device_property_read_string_array(const struct device *dev, const char *propname,
 51				      const char **val, size_t nval);
 52int device_property_read_string(const struct device *dev, const char *propname,
 53				const char **val);
 54int device_property_match_string(const struct device *dev,
 55				 const char *propname, const char *string);
 56
 57bool fwnode_property_present(const struct fwnode_handle *fwnode,
 58			     const char *propname);
 59bool fwnode_property_read_bool(const struct fwnode_handle *fwnode,
 60			     const char *propname);
 61int fwnode_property_read_u8_array(const struct fwnode_handle *fwnode,
 62				  const char *propname, u8 *val,
 63				  size_t nval);
 64int fwnode_property_read_u16_array(const struct fwnode_handle *fwnode,
 65				   const char *propname, u16 *val,
 66				   size_t nval);
 67int fwnode_property_read_u32_array(const struct fwnode_handle *fwnode,
 68				   const char *propname, u32 *val,
 69				   size_t nval);
 70int fwnode_property_read_u64_array(const struct fwnode_handle *fwnode,
 71				   const char *propname, u64 *val,
 72				   size_t nval);
 73int fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
 74				      const char *propname, const char **val,
 75				      size_t nval);
 76int fwnode_property_read_string(const struct fwnode_handle *fwnode,
 77				const char *propname, const char **val);
 78int fwnode_property_match_string(const struct fwnode_handle *fwnode,
 79				 const char *propname, const char *string);
 80
 81bool fwnode_device_is_available(const struct fwnode_handle *fwnode);
 82
 83static inline bool fwnode_device_is_big_endian(const struct fwnode_handle *fwnode)
 84{
 85	if (fwnode_property_present(fwnode, "big-endian"))
 86		return true;
 87	if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
 88	    fwnode_property_present(fwnode, "native-endian"))
 89		return true;
 90	return false;
 91}
 92
 93static inline
 94bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char *compat)
 95{
 96	return fwnode_property_match_string(fwnode, "compatible", compat) >= 0;
 97}
 98
 99/**
100 * device_is_big_endian - check if a device has BE registers
101 * @dev: Pointer to the struct device
102 *
103 * Returns: true if the device has a "big-endian" property, or if the kernel
104 * was compiled for BE *and* the device has a "native-endian" property.
105 * Returns false otherwise.
106 *
107 * Callers would nominally use ioread32be/iowrite32be if
108 * device_is_big_endian() == true, or readl/writel otherwise.
109 */
110static inline bool device_is_big_endian(const struct device *dev)
111{
112	return fwnode_device_is_big_endian(dev_fwnode(dev));
113}
114
115/**
116 * device_is_compatible - match 'compatible' property of the device with a given string
117 * @dev: Pointer to the struct device
118 * @compat: The string to match 'compatible' property with
119 *
120 * Returns: true if matches, otherwise false.
121 */
122static inline bool device_is_compatible(const struct device *dev, const char *compat)
123{
124	return fwnode_device_is_compatible(dev_fwnode(dev), compat);
125}
126
127int fwnode_property_match_property_string(const struct fwnode_handle *fwnode,
128					  const char *propname,
129					  const char * const *array, size_t n);
130
131static inline
132int device_property_match_property_string(const struct device *dev,
133					  const char *propname,
134					  const char * const *array, size_t n)
135{
136	return fwnode_property_match_property_string(dev_fwnode(dev), propname, array, n);
137}
138
139int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
140				       const char *prop, const char *nargs_prop,
141				       unsigned int nargs, unsigned int index,
142				       struct fwnode_reference_args *args);
143
144struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,
145					    const char *name,
146					    unsigned int index);
147
148const char *fwnode_get_name(const struct fwnode_handle *fwnode);
149const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode);
150bool fwnode_name_eq(const struct fwnode_handle *fwnode, const char *name);
151
152struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
153struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode);
154
155#define fwnode_for_each_parent_node(fwnode, parent)		\
156	for (parent = fwnode_get_parent(fwnode); parent;	\
157	     parent = fwnode_get_next_parent(parent))
158
159unsigned int fwnode_count_parents(const struct fwnode_handle *fwn);
160struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwn,
161					    unsigned int depth);
162struct fwnode_handle *fwnode_get_next_child_node(
163	const struct fwnode_handle *fwnode, struct fwnode_handle *child);
164struct fwnode_handle *fwnode_get_next_available_child_node(
165	const struct fwnode_handle *fwnode, struct fwnode_handle *child);
166
167#define fwnode_for_each_child_node(fwnode, child)			\
168	for (child = fwnode_get_next_child_node(fwnode, NULL); child;	\
169	     child = fwnode_get_next_child_node(fwnode, child))
170
171#define fwnode_for_each_named_child_node(fwnode, child, name)		\
172	fwnode_for_each_child_node(fwnode, child)			\
173		for_each_if(fwnode_name_eq(child, name))
174
175#define fwnode_for_each_available_child_node(fwnode, child)		       \
176	for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\
177	     child = fwnode_get_next_available_child_node(fwnode, child))
178
179#define fwnode_for_each_child_node_scoped(fwnode, child)		\
180	for (struct fwnode_handle *child __free(fwnode_handle) =	\
181		fwnode_get_next_child_node(fwnode, NULL);		\
182	     child; child = fwnode_get_next_child_node(fwnode, child))
183
184#define fwnode_for_each_available_child_node_scoped(fwnode, child)	\
185	for (struct fwnode_handle *child __free(fwnode_handle) =	\
186		fwnode_get_next_available_child_node(fwnode, NULL);	\
187	     child; child = fwnode_get_next_available_child_node(fwnode, child))
188
189struct fwnode_handle *device_get_next_child_node(const struct device *dev,
190						 struct fwnode_handle *child);
191
192#define device_for_each_child_node(dev, child)				\
193	for (child = device_get_next_child_node(dev, NULL); child;	\
194	     child = device_get_next_child_node(dev, child))
195
196#define device_for_each_named_child_node(dev, child, name)		\
197	device_for_each_child_node(dev, child)				\
198		for_each_if(fwnode_name_eq(child, name))
199
200#define device_for_each_child_node_scoped(dev, child)			\
201	for (struct fwnode_handle *child __free(fwnode_handle) =	\
202		device_get_next_child_node(dev, NULL);			\
203	     child; child = device_get_next_child_node(dev, child))
204
205#define device_for_each_named_child_node_scoped(dev, child, name)	\
206	device_for_each_child_node_scoped(dev, child)			\
207		for_each_if(fwnode_name_eq(child, name))
208
209struct fwnode_handle *fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
210						  const char *childname);
211struct fwnode_handle *device_get_named_child_node(const struct device *dev,
212						  const char *childname);
213
214struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
215
216/**
217 * fwnode_handle_put - Drop reference to a device node
218 * @fwnode: Pointer to the device node to drop the reference to.
219 *
220 * This has to be used when terminating device_for_each_child_node() iteration
221 * with break or return to prevent stale device node references from being left
222 * behind.
223 */
224static inline void fwnode_handle_put(struct fwnode_handle *fwnode)
225{
226	fwnode_call_void_op(fwnode, put);
227}
228
229DEFINE_FREE(fwnode_handle, struct fwnode_handle *, fwnode_handle_put(_T))
230
231int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index);
232int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name);
233
234unsigned int fwnode_get_child_node_count(const struct fwnode_handle *fwnode);
235
236static inline unsigned int device_get_child_node_count(const struct device *dev)
237{
238	return fwnode_get_child_node_count(dev_fwnode(dev));
239}
240
241unsigned int fwnode_get_named_child_node_count(const struct fwnode_handle *fwnode,
242					       const char *name);
243static inline unsigned int device_get_named_child_node_count(const struct device *dev,
244							     const char *name)
245{
246	return fwnode_get_named_child_node_count(dev_fwnode(dev), name);
247}
248
249static inline int device_property_read_u8(const struct device *dev,
250					  const char *propname, u8 *val)
251{
252	return device_property_read_u8_array(dev, propname, val, 1);
253}
254
255static inline int device_property_read_u16(const struct device *dev,
256					   const char *propname, u16 *val)
257{
258	return device_property_read_u16_array(dev, propname, val, 1);
259}
260
261static inline int device_property_read_u32(const struct device *dev,
262					   const char *propname, u32 *val)
263{
264	return device_property_read_u32_array(dev, propname, val, 1);
265}
266
267static inline int device_property_read_u64(const struct device *dev,
268					   const char *propname, u64 *val)
269{
270	return device_property_read_u64_array(dev, propname, val, 1);
271}
272
273static inline int device_property_count_u8(const struct device *dev, const char *propname)
274{
275	return device_property_read_u8_array(dev, propname, NULL, 0);
276}
277
278static inline int device_property_count_u16(const struct device *dev, const char *propname)
279{
280	return device_property_read_u16_array(dev, propname, NULL, 0);
281}
282
283static inline int device_property_count_u32(const struct device *dev, const char *propname)
284{
285	return device_property_read_u32_array(dev, propname, NULL, 0);
286}
287
288static inline int device_property_count_u64(const struct device *dev, const char *propname)
289{
290	return device_property_read_u64_array(dev, propname, NULL, 0);
291}
292
293static inline int device_property_string_array_count(const struct device *dev,
294						     const char *propname)
295{
296	return device_property_read_string_array(dev, propname, NULL, 0);
297}
298
299static inline int fwnode_property_read_u8(const struct fwnode_handle *fwnode,
300					  const char *propname, u8 *val)
301{
302	return fwnode_property_read_u8_array(fwnode, propname, val, 1);
303}
304
305static inline int fwnode_property_read_u16(const struct fwnode_handle *fwnode,
306					   const char *propname, u16 *val)
307{
308	return fwnode_property_read_u16_array(fwnode, propname, val, 1);
309}
310
311static inline int fwnode_property_read_u32(const struct fwnode_handle *fwnode,
312					   const char *propname, u32 *val)
313{
314	return fwnode_property_read_u32_array(fwnode, propname, val, 1);
315}
316
317static inline int fwnode_property_read_u64(const struct fwnode_handle *fwnode,
318					   const char *propname, u64 *val)
319{
320	return fwnode_property_read_u64_array(fwnode, propname, val, 1);
321}
322
323static inline int fwnode_property_count_u8(const struct fwnode_handle *fwnode,
324					   const char *propname)
325{
326	return fwnode_property_read_u8_array(fwnode, propname, NULL, 0);
327}
328
329static inline int fwnode_property_count_u16(const struct fwnode_handle *fwnode,
330					    const char *propname)
331{
332	return fwnode_property_read_u16_array(fwnode, propname, NULL, 0);
333}
334
335static inline int fwnode_property_count_u32(const struct fwnode_handle *fwnode,
336					    const char *propname)
337{
338	return fwnode_property_read_u32_array(fwnode, propname, NULL, 0);
339}
340
341static inline int fwnode_property_count_u64(const struct fwnode_handle *fwnode,
342					    const char *propname)
343{
344	return fwnode_property_read_u64_array(fwnode, propname, NULL, 0);
345}
346
347static inline int
348fwnode_property_string_array_count(const struct fwnode_handle *fwnode,
349				   const char *propname)
350{
351	return fwnode_property_read_string_array(fwnode, propname, NULL, 0);
352}
353
354struct software_node;
355
356/**
357 * struct software_node_ref_args - Reference property with additional arguments
358 * @swnode: Reference to a software node
359 * @fwnode: Alternative reference to a firmware node handle
360 * @nargs: Number of elements in @args array
361 * @args: Integer arguments
362 */
363struct software_node_ref_args {
364	const struct software_node *swnode;
365	struct fwnode_handle *fwnode;
366	unsigned int nargs;
367	u64 args[NR_FWNODE_REFERENCE_ARGS];
368};
369
370#define SOFTWARE_NODE_REFERENCE(_ref_, ...)			\
371(const struct software_node_ref_args) {				\
372	.swnode = _Generic(_ref_,				\
373			   const struct software_node *: _ref_,	\
374			   struct software_node *: _ref_,	\
375			   default: NULL),			\
376	.fwnode = _Generic(_ref_,				\
377			   struct fwnode_handle *: _ref_,	\
378			   default: NULL),			\
379	.nargs = COUNT_ARGS(__VA_ARGS__),			\
380	.args = { __VA_ARGS__ },				\
381}
382
383/**
384 * struct property_entry - "Built-in" device property representation.
385 * @name: Name of the property.
386 * @length: Length of data making up the value.
387 * @is_inline: True when the property value is stored inline.
388 * @type: Type of the data in unions.
389 * @pointer: Pointer to the property when it is not stored inline.
390 * @value: Value of the property when it is stored inline.
391 */
392struct property_entry {
393	const char *name;
394	size_t length;
395	bool is_inline;
396	enum dev_prop_type type;
397	union {
398		const void *pointer;
399		union {
400			u8 u8_data[sizeof(u64) / sizeof(u8)];
401			u16 u16_data[sizeof(u64) / sizeof(u16)];
402			u32 u32_data[sizeof(u64) / sizeof(u32)];
403			u64 u64_data[sizeof(u64) / sizeof(u64)];
404			const char *str[sizeof(u64) / sizeof(char *)];
405		} value;
406	};
407};
408
409/*
410 * Note: the below initializers for the anonymous union are carefully
411 * crafted to avoid gcc-4.4.4's problems with initialization of anon unions
412 * and structs.
413 */
414#define __PROPERTY_ENTRY_ARRAY_LEN(_name_, _elem_, _Type_, _val_, _len_)		\
415(struct property_entry) {								\
416	.name = _name_,									\
417	.length = (_len_) * sizeof_field(struct property_entry, value._elem_[0]),	\
418	.type = DEV_PROP_##_Type_,							\
419	{ .pointer = _val_ },								\
420}
421
422#define PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, _len_)		\
423	__PROPERTY_ENTRY_ARRAY_LEN(_name_, u8_data, U8, _val_, _len_)
424#define PROPERTY_ENTRY_U16_ARRAY_LEN(_name_, _val_, _len_)		\
425	__PROPERTY_ENTRY_ARRAY_LEN(_name_, u16_data, U16, _val_, _len_)
426#define PROPERTY_ENTRY_U32_ARRAY_LEN(_name_, _val_, _len_)		\
427	__PROPERTY_ENTRY_ARRAY_LEN(_name_, u32_data, U32, _val_, _len_)
428#define PROPERTY_ENTRY_U64_ARRAY_LEN(_name_, _val_, _len_)		\
429	__PROPERTY_ENTRY_ARRAY_LEN(_name_, u64_data, U64, _val_, _len_)
430#define PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, _len_)		\
431	__PROPERTY_ENTRY_ARRAY_LEN(_name_, str, STRING, _val_, _len_)
432
433#define PROPERTY_ENTRY_REF_ARRAY_LEN(_name_, _val_, _len_)		\
434(struct property_entry) {						\
435	.name = _name_,							\
436	.length = (_len_) * sizeof(struct software_node_ref_args),	\
437	.type = DEV_PROP_REF,						\
438	{ .pointer = _val_ },						\
439}
440
441#define PROPERTY_ENTRY_U8_ARRAY(_name_, _val_)				\
442	PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
443#define PROPERTY_ENTRY_U16_ARRAY(_name_, _val_)				\
444	PROPERTY_ENTRY_U16_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
445#define PROPERTY_ENTRY_U32_ARRAY(_name_, _val_)				\
446	PROPERTY_ENTRY_U32_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
447#define PROPERTY_ENTRY_U64_ARRAY(_name_, _val_)				\
448	PROPERTY_ENTRY_U64_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
449#define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_)			\
450	PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
451#define PROPERTY_ENTRY_REF_ARRAY(_name_, _val_)				\
452	PROPERTY_ENTRY_REF_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
453
454#define __PROPERTY_ENTRY_ELEMENT(_name_, _elem_, _Type_, _val_)		\
455(struct property_entry) {						\
456	.name = _name_,							\
457	.length = sizeof_field(struct property_entry, value._elem_[0]),	\
458	.is_inline = true,						\
459	.type = DEV_PROP_##_Type_,					\
460	{ .value = { ._elem_[0] = _val_ } },				\
461}
462
463#define PROPERTY_ENTRY_U8(_name_, _val_)				\
464	__PROPERTY_ENTRY_ELEMENT(_name_, u8_data, U8, _val_)
465#define PROPERTY_ENTRY_U16(_name_, _val_)				\
466	__PROPERTY_ENTRY_ELEMENT(_name_, u16_data, U16, _val_)
467#define PROPERTY_ENTRY_U32(_name_, _val_)				\
468	__PROPERTY_ENTRY_ELEMENT(_name_, u32_data, U32, _val_)
469#define PROPERTY_ENTRY_U64(_name_, _val_)				\
470	__PROPERTY_ENTRY_ELEMENT(_name_, u64_data, U64, _val_)
471#define PROPERTY_ENTRY_STRING(_name_, _val_)				\
472	__PROPERTY_ENTRY_ELEMENT(_name_, str, STRING, _val_)
473
474#define PROPERTY_ENTRY_REF(_name_, _ref_, ...)				\
475(struct property_entry) {						\
476	.name = _name_,							\
477	.length = sizeof(struct software_node_ref_args),		\
478	.type = DEV_PROP_REF,						\
479	{ .pointer = &SOFTWARE_NODE_REFERENCE(_ref_, ##__VA_ARGS__), },	\
480}
481
482#define PROPERTY_ENTRY_BOOL(_name_)		\
483(struct property_entry) {			\
484	.name = _name_,				\
485	.is_inline = true,			\
486}
487
488struct property_entry *
489property_entries_dup(const struct property_entry *properties);
490void property_entries_free(const struct property_entry *properties);
491
492bool device_dma_supported(const struct device *dev);
493enum dev_dma_attr device_get_dma_attr(const struct device *dev);
494
495const void *device_get_match_data(const struct device *dev);
496
497int device_get_phy_mode(struct device *dev);
498int fwnode_get_phy_mode(const struct fwnode_handle *fwnode);
499
500void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index);
501
502struct fwnode_handle *fwnode_graph_get_next_endpoint(
503	const struct fwnode_handle *fwnode, struct fwnode_handle *prev);
504struct fwnode_handle *
505fwnode_graph_get_port_parent(const struct fwnode_handle *fwnode);
506struct fwnode_handle *fwnode_graph_get_remote_port_parent(
507	const struct fwnode_handle *fwnode);
508struct fwnode_handle *fwnode_graph_get_remote_port(
509	const struct fwnode_handle *fwnode);
510struct fwnode_handle *fwnode_graph_get_remote_endpoint(
511	const struct fwnode_handle *fwnode);
512
513static inline bool fwnode_graph_is_endpoint(const struct fwnode_handle *fwnode)
514{
515	return fwnode_property_present(fwnode, "remote-endpoint");
516}
517
518/*
519 * Fwnode lookup flags
520 *
521 * @FWNODE_GRAPH_ENDPOINT_NEXT: In the case of no exact match, look for the
522 *				closest endpoint ID greater than the specified
523 *				one.
524 * @FWNODE_GRAPH_DEVICE_DISABLED: That the device to which the remote
525 *				  endpoint of the given endpoint belongs to,
526 *				  may be disabled, or that the endpoint is not
527 *				  connected.
528 */
529#define FWNODE_GRAPH_ENDPOINT_NEXT	BIT(0)
530#define FWNODE_GRAPH_DEVICE_DISABLED	BIT(1)
531
532struct fwnode_handle *
533fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode,
534				u32 port, u32 endpoint, unsigned long flags);
535unsigned int fwnode_graph_get_endpoint_count(const struct fwnode_handle *fwnode,
536					     unsigned long flags);
537
538#define fwnode_graph_for_each_endpoint(fwnode, child)				\
539	for (child = fwnode_graph_get_next_endpoint(fwnode, NULL); child;	\
540	     child = fwnode_graph_get_next_endpoint(fwnode, child))
541
542int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
543				struct fwnode_endpoint *endpoint);
544
545typedef void *(*devcon_match_fn_t)(const struct fwnode_handle *fwnode, const char *id,
546				   void *data);
547
548void *fwnode_connection_find_match(const struct fwnode_handle *fwnode,
549				   const char *con_id, void *data,
550				   devcon_match_fn_t match);
551
552static inline void *device_connection_find_match(const struct device *dev,
553						 const char *con_id, void *data,
554						 devcon_match_fn_t match)
555{
556	return fwnode_connection_find_match(dev_fwnode(dev), con_id, data, match);
557}
558
559int fwnode_connection_find_matches(const struct fwnode_handle *fwnode,
560				   const char *con_id, void *data,
561				   devcon_match_fn_t match,
562				   void **matches, unsigned int matches_len);
563
564/* -------------------------------------------------------------------------- */
565/* Software fwnode support - when HW description is incomplete or missing */
566
567/**
568 * struct software_node - Software node description
569 * @name: Name of the software node
570 * @parent: Parent of the software node
571 * @properties: Array of device properties
572 */
573struct software_node {
574	const char *name;
575	const struct software_node *parent;
576	const struct property_entry *properties;
577};
578
579#define SOFTWARE_NODE(_name_, _properties_, _parent_)	\
580	(struct software_node) {			\
581		.name = _name_,				\
582		.properties = _properties_,		\
583		.parent = _parent_,			\
584	}
585
586bool is_software_node(const struct fwnode_handle *fwnode);
587const struct software_node *
588to_software_node(const struct fwnode_handle *fwnode);
589struct fwnode_handle *software_node_fwnode(const struct software_node *node);
590
591const struct software_node *
592software_node_find_by_name(const struct software_node *parent,
593			   const char *name);
594
595int software_node_register_node_group(const struct software_node * const *node_group);
596void software_node_unregister_node_group(const struct software_node * const *node_group);
597
598int software_node_register(const struct software_node *node);
599void software_node_unregister(const struct software_node *node);
600
601struct fwnode_handle *
602fwnode_create_software_node(const struct property_entry *properties,
603			    const struct fwnode_handle *parent);
604void fwnode_remove_software_node(struct fwnode_handle *fwnode);
605
606int device_add_software_node(struct device *dev, const struct software_node *node);
607void device_remove_software_node(struct device *dev);
608
609int device_create_managed_software_node(struct device *dev,
610					const struct property_entry *properties,
611					const struct software_node *parent);
612
613#endif /* _LINUX_PROPERTY_H_ */
~/ Read-only file preview.