diff options
| author | Michael Ellerman <mpe@ellerman.id.au> | 2017-07-31 20:20:29 +1000 | 
|---|---|---|
| committer | Michael Ellerman <mpe@ellerman.id.au> | 2017-07-31 20:20:29 +1000 | 
| commit | bb272221e9db79f13d454e1f3fb6b05013be985e (patch) | |
| tree | 36f4acc50e3fabac71fadd34c720c0a6011db470 /include/linux/fwnode.h | |
| parent | 253fd51e2f533552ae35a0c661705da6c4842c1b (diff) | |
| parent | 5771a8c08880cdca3bfb4a3fc6d309d6bba20877 (diff) | |
Merge tag 'v4.13-rc1' into fixes
The fixes branch is based off a random pre-rc1 commit, because we had
some fixes that needed to go in before rc1 was released.
However we now need to fix some code that went in after that point, but
before rc1, so merge rc1 to get that code into fixes so we can fix it!
Diffstat (limited to 'include/linux/fwnode.h')
| -rw-r--r-- | include/linux/fwnode.h | 73 | 
1 files changed, 73 insertions, 0 deletions
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 3dff2398a5f0..50893a1646cf 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -12,6 +12,8 @@  #ifndef _LINUX_FWNODE_H_  #define _LINUX_FWNODE_H_ +#include <linux/types.h> +  enum fwnode_type {  	FWNODE_INVALID = 0,  	FWNODE_OF, @@ -22,9 +24,12 @@ enum fwnode_type {  	FWNODE_IRQCHIP  }; +struct fwnode_operations; +  struct fwnode_handle {  	enum fwnode_type type;  	struct fwnode_handle *secondary; +	const struct fwnode_operations *ops;  };  /** @@ -39,4 +44,72 @@ struct fwnode_endpoint {  	const struct fwnode_handle *local_fwnode;  }; +/** + * struct fwnode_operations - Operations for fwnode interface + * @get: Get a reference to an fwnode. + * @put: Put a reference to an fwnode. + * @property_present: Return true if a property is present. + * @property_read_integer_array: Read an array of integer properties. Return + *				 zero on success, a negative error code + *				 otherwise. + * @property_read_string_array: Read an array of string properties. Return zero + *				on success, a negative error code otherwise. + * @get_parent: Return the parent of an fwnode. + * @get_next_child_node: Return the next child node in an iteration. + * @get_named_child_node: Return a child node with a given name. + * @graph_get_next_endpoint: Return an endpoint node in an iteration. + * @graph_get_remote_endpoint: Return the remote endpoint node of a local + *			       endpoint node. + * @graph_get_port_parent: Return the parent node of a port node. + * @graph_parse_endpoint: Parse endpoint for port and endpoint id. + */ +struct fwnode_operations { +	void (*get)(struct fwnode_handle *fwnode); +	void (*put)(struct fwnode_handle *fwnode); +	bool (*device_is_available)(struct fwnode_handle *fwnode); +	bool (*property_present)(struct fwnode_handle *fwnode, +				 const char *propname); +	int (*property_read_int_array)(struct fwnode_handle *fwnode, +				       const char *propname, +				       unsigned int elem_size, void *val, +				       size_t nval); +	int (*property_read_string_array)(struct fwnode_handle *fwnode_handle, +					  const char *propname, +					  const char **val, size_t nval); +	struct fwnode_handle *(*get_parent)(struct fwnode_handle *fwnode); +	struct fwnode_handle * +	(*get_next_child_node)(struct fwnode_handle *fwnode, +			       struct fwnode_handle *child); +	struct fwnode_handle * +	(*get_named_child_node)(struct fwnode_handle *fwnode, const char *name); +	struct fwnode_handle * +	(*graph_get_next_endpoint)(struct fwnode_handle *fwnode, +				   struct fwnode_handle *prev); +	struct fwnode_handle * +	(*graph_get_remote_endpoint)(struct fwnode_handle *fwnode); +	struct fwnode_handle * +	(*graph_get_port_parent)(struct fwnode_handle *fwnode); +	int (*graph_parse_endpoint)(struct fwnode_handle *fwnode, +				    struct fwnode_endpoint *endpoint); +}; + +#define fwnode_has_op(fwnode, op)				\ +	((fwnode) && (fwnode)->ops && (fwnode)->ops->op) +#define fwnode_call_int_op(fwnode, op, ...)				\ +	(fwnode ? (fwnode_has_op(fwnode, op) ?				\ +		   (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : -ENXIO) : \ +	 -EINVAL) +#define fwnode_call_bool_op(fwnode, op, ...)				\ +	(fwnode ? (fwnode_has_op(fwnode, op) ?				\ +		   (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : false) : \ +	 false) +#define fwnode_call_ptr_op(fwnode, op, ...)		\ +	(fwnode_has_op(fwnode, op) ?			\ +	 (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : NULL) +#define fwnode_call_void_op(fwnode, op, ...)				\ +	do {								\ +		if (fwnode_has_op(fwnode, op))				\ +			(fwnode)->ops->op(fwnode, ## __VA_ARGS__);	\ +	} while (false) +  #endif  | 
