Commit e7d0c41e authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'devprop-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull device properties framework updates from Rafael Wysocki:
 "These introduce fwnode operations for all of the separate types of
  'firmware nodes' that can be handled by the device properties
  framework, make the framework use const fwnode arguments all over, add
  a helper for the consolidated handling of node references and switch
  over the framework to the new UUID API.

  Specifics:

   - Introduce fwnode operations for all of the separate types of
     'firmware nodes' that can be handled by the device properties
     framework and drop the type field from struct fwnode_handle (Sakari
     Ailus, Arnd Bergmann).

   - Make the device properties framework use const fwnode arguments
     where possible (Sakari Ailus).

   - Add a helper for the consolidated handling of node references to
     the device properties framework (Sakari Ailus).

   - Switch over the ACPI part of the device properties framework to the
     new UUID API (Andy Shevchenko)"

* tag 'devprop-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  ACPI: device property: Switch to use new generic UUID API
  device property: export irqchip_fwnode_ops
  device property: Introduce fwnode_property_get_reference_args
  device property: Constify fwnode property API
  device property: Constify argument to pset fwnode backend
  ACPI: Constify internal fwnode arguments
  ACPI: Constify acpi_bus helper functions, switch to macros
  ACPI: Prepare for constifying acpi_get_next_subnode() fwnode argument
  device property: Get rid of struct fwnode_handle type field
  ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in is_acpi_data_node()
parents 53ac64aa 3689d3d6
This diff is collapsed.
...@@ -1549,8 +1549,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, ...@@ -1549,8 +1549,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
device->device_type = type; device->device_type = type;
device->handle = handle; device->handle = handle;
device->parent = acpi_bus_get_parent(handle); device->parent = acpi_bus_get_parent(handle);
device->fwnode.type = FWNODE_ACPI; device->fwnode.ops = &acpi_device_fwnode_ops;
device->fwnode.ops = &acpi_fwnode_ops;
acpi_set_device_status(device, sta); acpi_set_device_status(device, sta);
acpi_device_get_busid(device); acpi_device_get_busid(device);
acpi_set_pnp_ids(handle, &device->pnp, type); acpi_set_pnp_ids(handle, &device->pnp, type);
......
This diff is collapsed.
...@@ -828,23 +828,23 @@ static void of_fwnode_put(struct fwnode_handle *fwnode) ...@@ -828,23 +828,23 @@ static void of_fwnode_put(struct fwnode_handle *fwnode)
of_node_put(to_of_node(fwnode)); of_node_put(to_of_node(fwnode));
} }
static bool of_fwnode_device_is_available(struct fwnode_handle *fwnode) static bool of_fwnode_device_is_available(const struct fwnode_handle *fwnode)
{ {
return of_device_is_available(to_of_node(fwnode)); return of_device_is_available(to_of_node(fwnode));
} }
static bool of_fwnode_property_present(struct fwnode_handle *fwnode, static bool of_fwnode_property_present(const struct fwnode_handle *fwnode,
const char *propname) const char *propname)
{ {
return of_property_read_bool(to_of_node(fwnode), propname); return of_property_read_bool(to_of_node(fwnode), propname);
} }
static int of_fwnode_property_read_int_array(struct fwnode_handle *fwnode, static int of_fwnode_property_read_int_array(const struct fwnode_handle *fwnode,
const char *propname, const char *propname,
unsigned int elem_size, void *val, unsigned int elem_size, void *val,
size_t nval) size_t nval)
{ {
struct device_node *node = to_of_node(fwnode); const struct device_node *node = to_of_node(fwnode);
if (!val) if (!val)
return of_property_count_elems_of_size(node, propname, return of_property_count_elems_of_size(node, propname,
...@@ -864,24 +864,26 @@ static int of_fwnode_property_read_int_array(struct fwnode_handle *fwnode, ...@@ -864,24 +864,26 @@ static int of_fwnode_property_read_int_array(struct fwnode_handle *fwnode,
return -ENXIO; return -ENXIO;
} }
static int of_fwnode_property_read_string_array(struct fwnode_handle *fwnode, static int
const char *propname, of_fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
const char **val, size_t nval) const char *propname, const char **val,
size_t nval)
{ {
struct device_node *node = to_of_node(fwnode); const struct device_node *node = to_of_node(fwnode);
return val ? return val ?
of_property_read_string_array(node, propname, val, nval) : of_property_read_string_array(node, propname, val, nval) :
of_property_count_strings(node, propname); of_property_count_strings(node, propname);
} }
static struct fwnode_handle *of_fwnode_get_parent(struct fwnode_handle *fwnode) static struct fwnode_handle *
of_fwnode_get_parent(const struct fwnode_handle *fwnode)
{ {
return of_fwnode_handle(of_get_parent(to_of_node(fwnode))); return of_fwnode_handle(of_get_parent(to_of_node(fwnode)));
} }
static struct fwnode_handle * static struct fwnode_handle *
of_fwnode_get_next_child_node(struct fwnode_handle *fwnode, of_fwnode_get_next_child_node(const struct fwnode_handle *fwnode,
struct fwnode_handle *child) struct fwnode_handle *child)
{ {
return of_fwnode_handle(of_get_next_available_child(to_of_node(fwnode), return of_fwnode_handle(of_get_next_available_child(to_of_node(fwnode),
...@@ -889,10 +891,10 @@ of_fwnode_get_next_child_node(struct fwnode_handle *fwnode, ...@@ -889,10 +891,10 @@ of_fwnode_get_next_child_node(struct fwnode_handle *fwnode,
} }
static struct fwnode_handle * static struct fwnode_handle *
of_fwnode_get_named_child_node(struct fwnode_handle *fwnode, of_fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
const char *childname) const char *childname)
{ {
struct device_node *node = to_of_node(fwnode); const struct device_node *node = to_of_node(fwnode);
struct device_node *child; struct device_node *child;
for_each_available_child_of_node(node, child) for_each_available_child_of_node(node, child)
...@@ -902,8 +904,38 @@ of_fwnode_get_named_child_node(struct fwnode_handle *fwnode, ...@@ -902,8 +904,38 @@ of_fwnode_get_named_child_node(struct fwnode_handle *fwnode,
return NULL; return NULL;
} }
static int
of_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
const char *prop, const char *nargs_prop,
unsigned int nargs, unsigned int index,
struct fwnode_reference_args *args)
{
struct of_phandle_args of_args;
unsigned int i;
int ret;
if (nargs_prop)
ret = of_parse_phandle_with_args(to_of_node(fwnode), prop,
nargs_prop, index, &of_args);
else
ret = of_parse_phandle_with_fixed_args(to_of_node(fwnode), prop,
nargs, index, &of_args);
if (ret < 0)
return ret;
if (!args)
return 0;
args->nargs = of_args.args_count;
args->fwnode = of_fwnode_handle(of_args.np);
for (i = 0; i < NR_FWNODE_REFERENCE_ARGS; i++)
args->args[i] = i < of_args.args_count ? of_args.args[i] : 0;
return 0;
}
static struct fwnode_handle * static struct fwnode_handle *
of_fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode, of_fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
struct fwnode_handle *prev) struct fwnode_handle *prev)
{ {
return of_fwnode_handle(of_graph_get_next_endpoint(to_of_node(fwnode), return of_fwnode_handle(of_graph_get_next_endpoint(to_of_node(fwnode),
...@@ -911,7 +943,7 @@ of_fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode, ...@@ -911,7 +943,7 @@ of_fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
} }
static struct fwnode_handle * static struct fwnode_handle *
of_fwnode_graph_get_remote_endpoint(struct fwnode_handle *fwnode) of_fwnode_graph_get_remote_endpoint(const struct fwnode_handle *fwnode)
{ {
return of_fwnode_handle(of_parse_phandle(to_of_node(fwnode), return of_fwnode_handle(of_parse_phandle(to_of_node(fwnode),
"remote-endpoint", 0)); "remote-endpoint", 0));
...@@ -934,10 +966,10 @@ of_fwnode_graph_get_port_parent(struct fwnode_handle *fwnode) ...@@ -934,10 +966,10 @@ of_fwnode_graph_get_port_parent(struct fwnode_handle *fwnode)
return of_fwnode_handle(of_get_next_parent(np)); return of_fwnode_handle(of_get_next_parent(np));
} }
static int of_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode, static int of_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
struct fwnode_endpoint *endpoint) struct fwnode_endpoint *endpoint)
{ {
struct device_node *node = to_of_node(fwnode); const struct device_node *node = to_of_node(fwnode);
struct device_node *port_node = of_get_parent(node); struct device_node *port_node = of_get_parent(node);
endpoint->local_fwnode = fwnode; endpoint->local_fwnode = fwnode;
...@@ -960,8 +992,10 @@ const struct fwnode_operations of_fwnode_ops = { ...@@ -960,8 +992,10 @@ const struct fwnode_operations of_fwnode_ops = {
.get_parent = of_fwnode_get_parent, .get_parent = of_fwnode_get_parent,
.get_next_child_node = of_fwnode_get_next_child_node, .get_next_child_node = of_fwnode_get_next_child_node,
.get_named_child_node = of_fwnode_get_named_child_node, .get_named_child_node = of_fwnode_get_named_child_node,
.get_reference_args = of_fwnode_get_reference_args,
.graph_get_next_endpoint = of_fwnode_graph_get_next_endpoint, .graph_get_next_endpoint = of_fwnode_graph_get_next_endpoint,
.graph_get_remote_endpoint = of_fwnode_graph_get_remote_endpoint, .graph_get_remote_endpoint = of_fwnode_graph_get_remote_endpoint,
.graph_get_port_parent = of_fwnode_graph_get_port_parent, .graph_get_port_parent = of_fwnode_graph_get_port_parent,
.graph_parse_endpoint = of_fwnode_graph_parse_endpoint, .graph_parse_endpoint = of_fwnode_graph_parse_endpoint,
}; };
EXPORT_SYMBOL_GPL(of_fwnode_ops);
...@@ -395,35 +395,55 @@ struct acpi_data_node { ...@@ -395,35 +395,55 @@ struct acpi_data_node {
struct completion kobj_done; struct completion kobj_done;
}; };
static inline bool is_acpi_node(struct fwnode_handle *fwnode) extern const struct fwnode_operations acpi_device_fwnode_ops;
{ extern const struct fwnode_operations acpi_data_fwnode_ops;
return !IS_ERR_OR_NULL(fwnode) && (fwnode->type == FWNODE_ACPI extern const struct fwnode_operations acpi_static_fwnode_ops;
|| fwnode->type == FWNODE_ACPI_DATA);
}
static inline bool is_acpi_device_node(struct fwnode_handle *fwnode) static inline bool is_acpi_node(const struct fwnode_handle *fwnode)
{ {
return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_ACPI; return !IS_ERR_OR_NULL(fwnode) &&
(fwnode->ops == &acpi_device_fwnode_ops
|| fwnode->ops == &acpi_data_fwnode_ops);
} }
static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode) static inline bool is_acpi_device_node(const struct fwnode_handle *fwnode)
{ {
return is_acpi_device_node(fwnode) ? return !IS_ERR_OR_NULL(fwnode) &&
container_of(fwnode, struct acpi_device, fwnode) : NULL; fwnode->ops == &acpi_device_fwnode_ops;
} }
static inline bool is_acpi_data_node(struct fwnode_handle *fwnode) #define to_acpi_device_node(__fwnode) \
({ \
typeof(__fwnode) __to_acpi_device_node_fwnode = __fwnode; \
\
is_acpi_device_node(__to_acpi_device_node_fwnode) ? \
container_of(__to_acpi_device_node_fwnode, \
struct acpi_device, fwnode) : \
NULL; \
})
static inline bool is_acpi_data_node(const struct fwnode_handle *fwnode)
{ {
return fwnode && fwnode->type == FWNODE_ACPI_DATA; return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops;
} }
static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode) #define to_acpi_data_node(__fwnode) \
({ \
typeof(__fwnode) __to_acpi_data_node_fwnode = __fwnode; \
\
is_acpi_data_node(__to_acpi_data_node_fwnode) ? \
container_of(__to_acpi_data_node_fwnode, \
struct acpi_data_node, fwnode) : \
NULL; \
})
static inline bool is_acpi_static_node(const struct fwnode_handle *fwnode)
{ {
return is_acpi_data_node(fwnode) ? return !IS_ERR_OR_NULL(fwnode) &&
container_of(fwnode, struct acpi_data_node, fwnode) : NULL; fwnode->ops == &acpi_static_fwnode_ops;
} }
static inline bool acpi_data_node_match(struct fwnode_handle *fwnode, static inline bool acpi_data_node_match(const struct fwnode_handle *fwnode,
const char *name) const char *name)
{ {
return is_acpi_data_node(fwnode) ? return is_acpi_data_node(fwnode) ?
......
...@@ -57,9 +57,6 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev) ...@@ -57,9 +57,6 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
acpi_fwnode_handle(adev) : NULL) acpi_fwnode_handle(adev) : NULL)
#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
extern const struct fwnode_operations acpi_fwnode_ops;
static inline struct fwnode_handle *acpi_alloc_fwnode_static(void) static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
{ {
struct fwnode_handle *fwnode; struct fwnode_handle *fwnode;
...@@ -68,15 +65,14 @@ static inline struct fwnode_handle *acpi_alloc_fwnode_static(void) ...@@ -68,15 +65,14 @@ static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
if (!fwnode) if (!fwnode)
return NULL; return NULL;
fwnode->type = FWNODE_ACPI_STATIC; fwnode->ops = &acpi_static_fwnode_ops;
fwnode->ops = &acpi_fwnode_ops;
return fwnode; return fwnode;
} }
static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode) static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode)
{ {
if (WARN_ON(!fwnode || fwnode->type != FWNODE_ACPI_STATIC)) if (WARN_ON(!is_acpi_static_node(fwnode)))
return; return;
kfree(fwnode); kfree(fwnode);
...@@ -1034,13 +1030,14 @@ struct acpi_reference_args { ...@@ -1034,13 +1030,14 @@ struct acpi_reference_args {
}; };
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
int acpi_dev_get_property(struct acpi_device *adev, const char *name, int acpi_dev_get_property(const struct acpi_device *adev, const char *name,
acpi_object_type type, const union acpi_object **obj); acpi_object_type type, const union acpi_object **obj);
int __acpi_node_get_property_reference(struct fwnode_handle *fwnode, int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
const char *name, size_t index, size_t num_args, const char *name, size_t index, size_t num_args,
struct acpi_reference_args *args); struct acpi_reference_args *args);
static inline int acpi_node_get_property_reference(struct fwnode_handle *fwnode, static inline int acpi_node_get_property_reference(
const struct fwnode_handle *fwnode,
const char *name, size_t index, const char *name, size_t index,
struct acpi_reference_args *args) struct acpi_reference_args *args)
{ {
...@@ -1048,22 +1045,25 @@ static inline int acpi_node_get_property_reference(struct fwnode_handle *fwnode, ...@@ -1048,22 +1045,25 @@ static inline int acpi_node_get_property_reference(struct fwnode_handle *fwnode,
MAX_ACPI_REFERENCE_ARGS, args); MAX_ACPI_REFERENCE_ARGS, args);
} }
int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname, int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
void **valptr); void **valptr);
int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, int acpi_dev_prop_read_single(struct acpi_device *adev,
enum dev_prop_type proptype, void *val); const char *propname, enum dev_prop_type proptype,
int acpi_node_prop_read(struct fwnode_handle *fwnode, const char *propname, void *val);
enum dev_prop_type proptype, void *val, size_t nval); int acpi_node_prop_read(const struct fwnode_handle *fwnode,
int acpi_dev_prop_read(struct acpi_device *adev, const char *propname, const char *propname, enum dev_prop_type proptype,
void *val, size_t nval);
int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname,
enum dev_prop_type proptype, void *val, size_t nval); enum dev_prop_type proptype, void *val, size_t nval);
struct fwnode_handle *acpi_get_next_subnode(struct fwnode_handle *fwnode, struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
struct fwnode_handle *child); struct fwnode_handle *child);
struct fwnode_handle *acpi_node_get_parent(struct fwnode_handle *fwnode); struct fwnode_handle *acpi_node_get_parent(const struct fwnode_handle *fwnode);
struct fwnode_handle *acpi_graph_get_next_endpoint(struct fwnode_handle *fwnode, struct fwnode_handle *
acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
struct fwnode_handle *prev); struct fwnode_handle *prev);
int acpi_graph_get_remote_endpoint(struct fwnode_handle *fwnode, int acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode,
struct fwnode_handle **remote, struct fwnode_handle **remote,
struct fwnode_handle **port, struct fwnode_handle **port,
struct fwnode_handle **endpoint); struct fwnode_handle **endpoint);
...@@ -1131,35 +1131,36 @@ static inline int acpi_dev_get_property(struct acpi_device *adev, ...@@ -1131,35 +1131,36 @@ static inline int acpi_dev_get_property(struct acpi_device *adev,
} }
static inline int static inline int
__acpi_node_get_property_reference(struct fwnode_handle *fwnode, __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
const char *name, size_t index, size_t num_args, const char *name, size_t index, size_t num_args,
struct acpi_reference_args *args) struct acpi_reference_args *args)
{ {
return -ENXIO; return -ENXIO;
} }
static inline int acpi_node_get_property_reference(struct fwnode_handle *fwnode, static inline int
acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
const char *name, size_t index, const char *name, size_t index,
struct acpi_reference_args *args) struct acpi_reference_args *args)
{ {
return -ENXIO; return -ENXIO;
} }
static inline int acpi_node_prop_get(struct fwnode_handle *fwnode, static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,
const char *propname, const char *propname,
void **valptr) void **valptr)
{ {
return -ENXIO; return -ENXIO;
} }
static inline int acpi_dev_prop_get(struct acpi_device *adev, static inline int acpi_dev_prop_get(const struct acpi_device *adev,
const char *propname, const char *propname,
void **valptr) void **valptr)
{ {
return -ENXIO; return -ENXIO;
} }
static inline int acpi_dev_prop_read_single(struct acpi_device *adev, static inline int acpi_dev_prop_read_single(const struct acpi_device *adev,
const char *propname, const char *propname,
enum dev_prop_type proptype, enum dev_prop_type proptype,
void *val) void *val)
...@@ -1167,7 +1168,7 @@ static inline int acpi_dev_prop_read_single(struct acpi_device *adev, ...@@ -1167,7 +1168,7 @@ static inline int acpi_dev_prop_read_single(struct acpi_device *adev,
return -ENXIO; return -ENXIO;
} }
static inline int acpi_node_prop_read(struct fwnode_handle *fwnode, static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode,
const char *propname, const char *propname,
enum dev_prop_type proptype, enum dev_prop_type proptype,
void *val, size_t nval) void *val, size_t nval)
...@@ -1175,7 +1176,7 @@ static inline int acpi_node_prop_read(struct fwnode_handle *fwnode, ...@@ -1175,7 +1176,7 @@ static inline int acpi_node_prop_read(struct fwnode_handle *fwnode,
return -ENXIO; return -ENXIO;
} }
static inline int acpi_dev_prop_read(struct acpi_device *adev, static inline int acpi_dev_prop_read(const struct acpi_device *adev,
const char *propname, const char *propname,
enum dev_prop_type proptype, enum dev_prop_type proptype,
void *val, size_t nval) void *val, size_t nval)
...@@ -1184,26 +1185,27 @@ static inline int acpi_dev_prop_read(struct acpi_device *adev, ...@@ -1184,26 +1185,27 @@ static inline int acpi_dev_prop_read(struct acpi_device *adev,
} }
static inline struct fwnode_handle * static inline struct fwnode_handle *
acpi_get_next_subnode(struct fwnode_handle *fwnode, struct fwnode_handle *child) acpi_get_next_subnode(const struct fwnode_handle *fwnode,
struct fwnode_handle *child)
{ {
return NULL; return NULL;
} }
static inline struct fwnode_handle * static inline struct fwnode_handle *
acpi_node_get_parent(struct fwnode_handle *fwnode) acpi_node_get_parent(const struct fwnode_handle *fwnode)
{ {
return NULL; return NULL;
} }
static inline struct fwnode_handle * static inline struct fwnode_handle *
acpi_graph_get_next_endpoint(struct fwnode_handle *fwnode, acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
struct fwnode_handle *prev) struct fwnode_handle *prev)
{ {
return ERR_PTR(-ENXIO); return ERR_PTR(-ENXIO);
} }
static inline int static inline int
acpi_graph_get_remote_endpoint(struct fwnode_handle *fwnode, acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode,
struct fwnode_handle **remote, struct fwnode_handle **remote,
struct fwnode_handle **port, struct fwnode_handle **port,
struct fwnode_handle **endpoint) struct fwnode_handle **endpoint)
......
...@@ -14,20 +14,9 @@ ...@@ -14,20 +14,9 @@
#include <linux/types.h> #include <linux/types.h>
enum fwnode_type {
FWNODE_INVALID = 0,
FWNODE_OF,
FWNODE_ACPI,
FWNODE_ACPI_DATA,
FWNODE_ACPI_STATIC,
FWNODE_PDATA,
FWNODE_IRQCHIP
};
struct fwnode_operations; struct fwnode_operations;
struct fwnode_handle { struct fwnode_handle {
enum fwnode_type type;
struct fwnode_handle *secondary; struct fwnode_handle *secondary;
const struct fwnode_operations *ops; const struct fwnode_operations *ops;
}; };
...@@ -44,6 +33,20 @@ struct fwnode_endpoint { ...@@ -44,6 +33,20 @@ struct fwnode_endpoint {
const struct fwnode_handle *local_fwnode; const struct fwnode_handle *local_fwnode;
}; };
#define NR_FWNODE_REFERENCE_ARGS 8
/**
* struct fwnode_reference_args - Fwnode reference with additional arguments
* @fwnode:- A reference to the base fwnode
* @nargs: Number of elements in @args array
* @args: Integer arguments on the fwnode
*/
struct fwnode_reference_args {
struct fwnode_handle *fwnode;
unsigned int nargs;
unsigned int args[NR_FWNODE_REFERENCE_ARGS];
};
/** /**
* struct fwnode_operations - Operations for fwnode interface * struct fwnode_operations - Operations for fwnode interface
* @get: Get a reference to an fwnode. * @get: Get a reference to an fwnode.
...@@ -57,6 +60,7 @@ struct fwnode_endpoint { ...@@ -57,6 +60,7 @@ struct fwnode_endpoint {
* @get_parent: Return the parent of an fwnode. * @get_parent: Return the parent of an fwnode.
* @get_next_child_node: Return the next child node in an iteration. * @get_next_child_node: Return the next child node in an iteration.
* @get_named_child_node: Return a child node with a given name. * @get_named_child_node: Return a child node with a given name.
* @get_reference_args: Return a reference pointed to by a property, with args
* @graph_get_next_endpoint: Return an endpoint node in an iteration. * @graph_get_next_endpoint: Return an endpoint node in an iteration.
* @graph_get_remote_endpoint: Return the remote endpoint node of a local * @graph_get_remote_endpoint: Return the remote endpoint node of a local
* endpoint node. * endpoint node.
...@@ -66,30 +70,36 @@ struct fwnode_endpoint { ...@@ -66,30 +70,36 @@ struct fwnode_endpoint {
struct fwnode_operations { struct fwnode_operations {
void (*get)(struct fwnode_handle *fwnode); void (*get)(struct fwnode_handle *fwnode);
void (*put)(struct fwnode_handle *fwnode); void (*put)(struct fwnode_handle *fwnode);
bool (*device_is_available)(struct fwnode_handle *fwnode); bool (*device_is_available)(const struct fwnode_handle *fwnode);
bool (*property_present)(struct fwnode_handle *fwnode, bool (*property_present)(const struct fwnode_handle *fwnode,
const char *propname); const char *propname);
int (*property_read_int_array)(struct fwnode_handle *fwnode, int (*property_read_int_array)(const struct fwnode_handle *fwnode,
const char *propname, const char *propname,
unsigned int elem_size, void *val, unsigned int elem_size, void *val,
size_t nval); size_t nval);
int (*property_read_string_array)(struct fwnode_handle *fwnode_handle, int
const char *propname, (*property_read_string_array)(const struct fwnode_handle *fwnode_handle,
const char **val, size_t nval); const char *propname, const char **val,
struct fwnode_handle *(*get_parent)(struct fwnode_handle *fwnode); size_t nval);
struct fwnode_handle *(*get_parent)(const struct fwnode_handle *fwnode);
struct fwnode_handle * struct fwnode_handle *
(*get_next_child_node)(struct fwnode_handle *fwnode, (*get_next_child_node)(const struct fwnode_handle *fwnode,
struct fwnode_handle *child); struct fwnode_handle *child);
struct fwnode_handle * struct fwnode_handle *
(*get_named_child_node)(struct fwnode_handle *fwnode, const char *name); (*get_named_child_node)(const struct fwnode_handle *fwnode,
const char *name);
int (*get_reference_args)(const struct fwnode_handle *fwnode,
const char *prop, const char *nargs_prop,
unsigned int nargs, unsigned int index,
struct fwnode_reference_args *args);
struct fwnode_handle * struct fwnode_handle *
(*graph_get_next_endpoint)(struct fwnode_handle *fwnode, (*graph_get_next_endpoint)(const struct fwnode_handle *fwnode,
struct fwnode_handle *prev); struct fwnode_handle *prev);
struct fwnode_handle * struct fwnode_handle *
(*graph_get_remote_endpoint)(struct fwnode_handle *fwnode); (*graph_get_remote_endpoint)(const struct fwnode_handle *fwnode);
struct fwnode_handle * struct fwnode_handle *
(*graph_get_port_parent)(struct fwnode_handle *fwnode); (*graph_get_port_parent)(struct fwnode_handle *fwnode);
int (*graph_parse_endpoint)(struct fwnode_handle *fwnode, int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode,
struct fwnode_endpoint *endpoint); struct fwnode_endpoint *endpoint);
}; };
......
...@@ -265,9 +265,11 @@ static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node) ...@@ -265,9 +265,11 @@ static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node)
return node ? &node->fwnode : NULL; return node ? &node->fwnode : NULL;
} }
extern const struct fwnode_operations irqchip_fwnode_ops;
static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode) static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
{ {
return fwnode && fwnode->type == FWNODE_IRQCHIP; return fwnode && fwnode->ops == &irqchip_fwnode_ops;
} }
extern void irq_domain_update_bus_token(struct irq_domain *domain, extern void irq_domain_update_bus_token(struct irq_domain *domain,
......
...@@ -104,7 +104,6 @@ extern const struct fwnode_operations of_fwnode_ops; ...@@ -104,7 +104,6 @@ extern const struct fwnode_operations of_fwnode_ops;
static inline void of_node_init(struct device_node *node) static inline void of_node_init(struct device_node *node)
{ {
kobject_init(&node->kobj, &of_node_ktype); kobject_init(&node->kobj, &of_node_ktype);
node->fwnode.type = FWNODE_OF;
node->fwnode.ops = &of_fwnode_ops; node->fwnode.ops = &of_fwnode_ops;
} }
...@@ -152,7 +151,7 @@ void of_core_init(void); ...@@ -152,7 +151,7 @@ void of_core_init(void);
static inline bool is_of_node(const struct fwnode_handle *fwnode) static inline bool is_of_node(const struct fwnode_handle *fwnode)
{ {
return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_OF; return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &of_fwnode_ops;
} }
#define to_of_node(__fwnode) \ #define to_of_node(__fwnode) \
......
...@@ -51,46 +51,52 @@ int device_property_read_string(struct device *dev, const char *propname, ...@@ -51,46 +51,52 @@ int device_property_read_string(struct device *dev, const char *propname,
int device_property_match_string(struct device *dev, int device_property_match_string(struct device *dev,
const char *propname, const char *string); const char *propname, const char *string);
bool fwnode_device_is_available(struct fwnode_handle *fwnode); bool fwnode_device_is_available(const struct fwnode_handle *fwnode);
bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname); bool fwnode_property_present(const struct fwnode_handle *fwnode,
int fwnode_property_read_u8_array(struct fwnode_handle *fwnode, const char *propname);
int fwnode_property_read_u8_array(const struct fwnode_handle *fwnode,
const char *propname, u8 *val, const char *propname, u8 *val,
size_t nval); size_t nval);
int fwnode_property_read_u16_array(struct fwnode_handle *fwnode, int fwnode_property_read_u16_array(const struct fwnode_handle *fwnode,
const char *propname, u16 *val, const char *propname, u16 *val,
size_t nval); size_t nval);
int fwnode_property_read_u32_array(struct fwnode_handle *fwnode, int fwnode_property_read_u32_array(const struct fwnode_handle *fwnode,
const char *propname, u32 *val, const char *propname, u32 *val,
size_t nval); size_t nval);
int fwnode_property_read_u64_array(struct fwnode_handle *fwnode, int fwnode_property_read_u64_array(const struct fwnode_handle *fwnode,
const char *propname, u64 *val, const char *propname, u64 *val,
size_t nval); size_t nval);
int fwnode_property_read_string_array(struct fwnode_handle *fwnode, int fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
const char *propname, const char **val, const char *propname, const char **val,
size_t nval); size_t nval);
int fwnode_property_read_string(struct fwnode_handle *fwnode, int fwnode_property_read_string(const struct fwnode_handle *fwnode,
const char *propname, const char **val); const char *propname, const char **val);
int fwnode_property_match_string(struct fwnode_handle *fwnode, int fwnode_property_match_string(const struct fwnode_handle *fwnode,
const char *propname, const char *string); const char *propname, const char *string);
int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
const char *prop, const char *nargs_prop,
unsigned int nargs, unsigned int index,
struct fwnode_reference_args *args);
struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode); struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode); struct fwnode_handle *fwnode_get_next_parent(
struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *fwnode, struct fwnode_handle *fwnode);
struct fwnode_handle *child); struct fwnode_handle *fwnode_get_next_child_node(
const struct fwnode_handle *fwnode, struct fwnode_handle *child);
#define fwnode_for_each_child_node(fwnode, child) \ #define fwnode_for_each_child_node(fwnode, child) \
for (child = fwnode_get_next_child_node(fwnode, NULL); child; \ for (child = fwnode_get_next_child_node(fwnode, NULL); child; \
child = fwnode_get_next_child_node(fwnode, child)) child = fwnode_get_next_child_node(fwnode, child))
struct fwnode_handle *device_get_next_child_node(struct device *dev, struct fwnode_handle *device_get_next_child_node(
struct fwnode_handle *child); struct device *dev, struct fwnode_handle *child);
#define device_for_each_child_node(dev, child) \ #define device_for_each_child_node(dev, child) \
for (child = device_get_next_child_node(dev, NULL); child; \ for (child = device_get_next_child_node(dev, NULL); child; \
child = device_get_next_child_node(dev, child)) child = device_get_next_child_node(dev, child))
struct fwnode_handle *fwnode_get_named_child_node(struct fwnode_handle *fwnode, struct fwnode_handle *fwnode_get_named_child_node(
const char *childname); const struct fwnode_handle *fwnode, const char *childname);
struct fwnode_handle *device_get_named_child_node(struct device *dev, struct fwnode_handle *device_get_named_child_node(struct device *dev,
const char *childname); const char *childname);
...@@ -129,31 +135,31 @@ static inline int device_property_read_u64(struct device *dev, ...@@ -129,31 +135,31 @@ static inline int device_property_read_u64(struct device *dev,
return device_property_read_u64_array(dev, propname, val, 1); return device_property_read_u64_array(dev, propname, val, 1);
} }
static inline bool fwnode_property_read_bool(struct fwnode_handle *fwnode, static inline bool fwnode_property_read_bool(const struct fwnode_handle *fwnode,
const char *propname) const char *propname)
{ {
return fwnode_property_present(fwnode, propname); return fwnode_property_present(fwnode, propname);
} }
static inline int fwnode_property_read_u8(struct fwnode_handle *fwnode, static inline int fwnode_property_read_u8(const struct fwnode_handle *fwnode,
const char *propname, u8 *val) const char *propname, u8 *val)
{ {
return fwnode_property_read_u8_array(fwnode, propname, val, 1); return fwnode_property_read_u8_array(fwnode, propname, val, 1);
} }
static inline int fwnode_property_read_u16(struct fwnode_handle *fwnode, static inline int fwnode_property_read_u16(const struct fwnode_handle *fwnode,
const char *propname, u16 *val) const char *propname, u16 *val)
{ {
return fwnode_property_read_u16_array(fwnode, propname, val, 1); return fwnode_property_read_u16_array(fwnode, propname, val, 1);
} }
static inline int fwnode_property_read_u32(struct fwnode_handle *fwnode, static inline int fwnode_property_read_u32(const struct fwnode_handle *fwnode,
const char *propname, u32 *val) const char *propname, u32 *val)
{ {
return fwnode_property_read_u32_array(fwnode, propname, val, 1); return fwnode_property_read_u32_array(fwnode, propname, val, 1);
} }
static inline int fwnode_property_read_u64(struct fwnode_handle *fwnode, static inline int fwnode_property_read_u64(const struct fwnode_handle *fwnode,
const char *propname, u64 *val) const char *propname, u64 *val)
{ {
return fwnode_property_read_u64_array(fwnode, propname, val, 1); return fwnode_property_read_u64_array(fwnode, propname, val, 1);
...@@ -274,19 +280,20 @@ int device_get_phy_mode(struct device *dev); ...@@ -274,19 +280,20 @@ int device_get_phy_mode(struct device *dev);
void *device_get_mac_address(struct device *dev, char *addr, int alen); void *device_get_mac_address(struct device *dev, char *addr, int alen);
struct fwnode_handle *fwnode_graph_get_next_endpoint( struct fwnode_handle *fwnode_graph_get_next_endpoint(
struct fwnode_handle *fwnode, struct fwnode_handle *prev); const struct fwnode_handle *fwnode, struct fwnode_handle *prev);
struct fwnode_handle * struct fwnode_handle *
fwnode_graph_get_port_parent(struct fwnode_handle *fwnode); fwnode_graph_get_port_parent(const struct fwnode_handle *fwnode);
struct fwnode_handle *fwnode_graph_get_remote_port_parent( struct fwnode_handle *fwnode_graph_get_remote_port_parent(
struct fwnode_handle *fwnode); const struct fwnode_handle *fwnode);
struct fwnode_handle *fwnode_graph_get_remote_port( struct fwnode_handle *fwnode_graph_get_remote_port(
struct fwnode_handle *fwnode); const struct fwnode_handle *fwnode);
struct fwnode_handle *fwnode_graph_get_remote_endpoint( struct fwnode_handle *fwnode_graph_get_remote_endpoint(
struct fwnode_handle *fwnode); const struct fwnode_handle *fwnode);
struct fwnode_handle *fwnode_graph_get_remote_node(struct fwnode_handle *fwnode, struct fwnode_handle *
u32 port, u32 endpoint); fwnode_graph_get_remote_node(const struct fwnode_handle *fwnode, u32 port,
u32 endpoint);
int fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode, int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
struct fwnode_endpoint *endpoint); struct fwnode_endpoint *endpoint);
#endif /* _LINUX_PROPERTY_H_ */ #endif /* _LINUX_PROPERTY_H_ */
...@@ -41,6 +41,9 @@ static inline void debugfs_add_domain_dir(struct irq_domain *d) { } ...@@ -41,6 +41,9 @@ static inline void debugfs_add_domain_dir(struct irq_domain *d) { }
static inline void debugfs_remove_domain_dir(struct irq_domain *d) { } static inline void debugfs_remove_domain_dir(struct irq_domain *d) { }
#endif #endif
const struct fwnode_operations irqchip_fwnode_ops;
EXPORT_SYMBOL_GPL(irqchip_fwnode_ops);
/** /**
* irq_domain_alloc_fwnode - Allocate a fwnode_handle suitable for * irq_domain_alloc_fwnode - Allocate a fwnode_handle suitable for
* identifying an irq domain * identifying an irq domain
...@@ -86,7 +89,7 @@ struct fwnode_handle *__irq_domain_alloc_fwnode(unsigned int type, int id, ...@@ -86,7 +89,7 @@ struct fwnode_handle *__irq_domain_alloc_fwnode(unsigned int type, int id,
fwid->type = type; fwid->type = type;
fwid->name = n; fwid->name = n;
fwid->data = data; fwid->data = data;
fwid->fwnode.type = FWNODE_IRQCHIP; fwid->fwnode.ops = &irqchip_fwnode_ops;
return &fwid->fwnode; return &fwid->fwnode;
} }
EXPORT_SYMBOL_GPL(__irq_domain_alloc_fwnode); EXPORT_SYMBOL_GPL(__irq_domain_alloc_fwnode);
...@@ -193,10 +196,8 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size, ...@@ -193,10 +196,8 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
} }
if (!domain->name) { if (!domain->name) {
if (fwnode) { if (fwnode)
pr_err("Invalid fwnode type (%d) for irqdomain\n", pr_err("Invalid fwnode type for irqdomain\n");
fwnode->type);
}
domain->name = kasprintf(GFP_KERNEL, "unknown-%d", domain->name = kasprintf(GFP_KERNEL, "unknown-%d",
atomic_inc_return(&unknown_domains)); atomic_inc_return(&unknown_domains));
if (!domain->name) { if (!domain->name) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment