Move firmware specific code to firmware specific locations
Subsystems (4)
Sakari Ailus
reviewerv5 cover Move firmware specific code to firmware specific locations
Hi folks,
This set moves firmware specific implementations of the device / fwnode property API to locations that are specific to firmware implementation, still leaving property set (which isn't really firmware) implementation in drivers/base/property.c.
This set depends on the OF patches here:
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=of>
NOTE: These patches are going in through another tree and may not be merged yet.
The patches this set and the dependencies may be found with dependencies here:
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=acpi-graph-cleaned>
since v4:
- Address Mika's comments on line wrapping and indentation.
- Order acpi_fwnode_get_parent() according to the list of operations in struct fwnode_operations.
- Add patch "device property: Add fwnode_graph_get_port_parent" to the set.
since v3:
- The two first patches have been already merged ("device property: Read strings using string array reading functions" and "device property:
Implement fwnode_get_next_parent()).
- Add "ACPI: Constify argument to acpi_device_is_present()".
- Add patch "device property: Introduce fwnode_device_is_available()".
- Add "device property: Add FW type agnostic fwnode_graph_get_remote_node".
- Rebase on current linux-pm master and fwnode cleanup patchset here:
<URL:http://www.spinics.net/lists/devicetree/msg177549.html>
- Add KernelDoc documentation for graph_parse_endpoint fwnode operation.
since v2:
- Move patches changing the implementation of reading strings and implementing fwnode_get_next_parent() using the fwnode interface alone in front of the set. I kept them separate as they do change the implementation of these operations.
- Merge patches adding the fwnode_operations and moving the implementations of the non-graph portions of the fwnode property API to firmware specific locations.
- Merge moving graph operations to the same struct into another patch. The graph operations in the ops struct are also added in this patch now.
since v1:
- Move the three bugfixes in front of the set into a separate patchset. There are no dependencies to those from the rest of the patches.
- Rebase on current ACPI graph support patches (themselves on PM tree 4.11-rc1 merge).
Sakari Ailus (5):
ACPI: Constify argument to acpi_device_is_present()
device property: Move FW type specific functionality to FW specific
files
device property: Move fwnode graph ops to firmware specific locations device property: Introduce fwnode_device_is_available() device property: Add FW type agnostic fwnode_graph_get_remote_node
drivers/acpi/device_pm.c | 4 +- drivers/acpi/internal.h | 2 +- drivers/acpi/property.c | 114 ++++++++++++++++ drivers/acpi/scan.c | 10 +- drivers/base/property.c | 332 +++++++++++++++++++---------------------------- drivers/of/property.c | 144 ++++++++++++++++++++ include/linux/acpi.h | 4 + include/linux/fwnode.h | 67 ++++++++++ include/linux/of.h | 2 + include/linux/property.h | 3 + 10 files changed, 472 insertions(+), 210 deletions(-)
Signature · 32 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Kieran Bingham (1): device property: Add fwnode_graph_get_port_parent Sakari Ailus (5): ACPI: Constify argument to acpi_device_is_present() device property: Move FW type specific functionality to FW specific files device property: Move fwnode graph ops to firmware specific locations device property: Introduce fwnode_device_is_available() device property: Add FW type agnostic fwnode_graph_get_remote_node drivers/acpi/device_pm.c | 4 +- drivers/acpi/internal.h | 2 +- drivers/acpi/property.c | 117 ++++++++++++++++ drivers/acpi/scan.c | 10 +- drivers/base/property.c | 347 ++++++++++++++++++++--------------------------- drivers/of/property.c | 148 ++++++++++++++++++++ include/linux/acpi.h | 4 + include/linux/fwnode.h | 69 ++++++++++ include/linux/of.h | 2 + include/linux/property.h | 5 + 10 files changed, 501 insertions(+), 207 deletions(-) -- 2.7.4
Sakari Ailus
reviewerPATCH v5 1/6 ACPI: Constify argument to acpi_device_is_present()
This will be needed in constifying the fwnode API.
The side effects the function had have been moved to the callers.
--- drivers/acpi/device_pm.c | 4 +++- drivers/acpi/internal.h | 2 +- drivers/acpi/scan.c | 9 +++------ 3 files changed, 7 insertions(+), 8 deletions(-)
drivers/acpi/device_pm.c +3 -1
@@ -262,8 +262,10 @@ int acpi_bus_init_power(struct acpi_device *device)return -EINVAL ; device->power.state =ACPI_STATE_UNKNOWN ; -if (!acpi_device_is_present (device)) +if (!acpi_device_is_present (device)) { + device->flags.initialized = false;return -ENXIO ; + } result =acpi_device_get_power (device, &state);if (result)
drivers/acpi/internal.h +1 -1
@@ -111,7 +111,7 @@ int acpi_device_setup_files(struct acpi_device *dev);void acpi_device_remove_files (struct acpi_device *dev);void acpi_device_add_finalize (struct acpi_device *device);void acpi_free_pnp_ids (struct acpi_device_pnp *pnp); -bool acpi_device_is_present (struct acpi_device *adev); +bool acpi_device_is_present (const struct acpi_device *adev);bool acpi_device_is_battery (struct acpi_device *adev);bool acpi_device_is_first_physical_node (struct acpi_device *adev,const struct device *dev);
drivers/acpi/scan.c +3 -6
@@ -1567,13 +1567,9 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,return 0 ; } -bool acpi_device_is_present (struct acpi_device *adev) +bool acpi_device_is_present (const struct acpi_device *adev) { -if (adev->status.present || adev->status.functional) -return true; - - adev->flags.initialized = false; -return false; +return adev->status.present || adev->status.functional; } static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,
@@ -1831,6 +1827,7 @@ static void acpi_bus_attach(struct acpi_device *device)acpi_bus_get_status (device);/* Skip devices that are not present. */ if (!acpi_device_is_present (device)) { + device->flags.initialized = false;acpi_device_clear_enumerated (device); device->flags.power_manageable =0 ;return ;
Signature · 1 line
2.7.4
Sakari Ailus
reviewerPATCH v5 2/6 device property: Move FW type specific functionality to FW specific files
In reply to Sakari AilusThe device and fwnode property API supports Devicetree, ACPI and pset properties. The implementation of this functionality for each firmware type was embedded in the fwnode property core. Move it out to firmware type specific locations, making it easier to maintain.
Depends-on: ("of: Move OF property and graph API from base.c to property.c")
--- drivers/acpi/property.c | 68 ++++++++++++++++ drivers/acpi/scan.c | 1 + drivers/base/property.c | 207 +++++++++++++++++++----------------------------- drivers/of/property.c | 102 ++++++++++++++++++++++++ include/linux/acpi.h | 4 + include/linux/fwnode.h | 54 +++++++++++++ include/linux/of.h | 2 + 7 files changed, 313 insertions(+), 125 deletions(-)
drivers/acpi/property.c +68 -0
@@ -57,6 +57,7 @@ static bool acpi_nondev_subnode_extract(const union acpi_object *desc, dn->name = link->package.elements[0 ].string.pointer; dn->fwnode.type =FWNODE_ACPI_DATA ; + dn->fwnode.ops = &acpi_fwnode_ops; dn->parent = parent;INIT_LIST_HEAD (&dn->data.subnodes);
@@ -1119,3 +1120,70 @@ int acpi_graph_get_remote_endpoint(struct fwnode_handle *fwnode,return 0 ; } + +static bool acpi_fwnode_property_present (struct fwnode_handle *fwnode, +const char *propname) +{ +return !acpi_node_prop_get (fwnode, propname,NULL ); +} + +static int acpi_fwnode_property_read_int_array (struct fwnode_handle *fwnode, +const char *propname, +unsigned int elem_size, +void *val,size_t nval) +{ +enum dev_prop_type type; + +switch (elem_size) { +case sizeof (u8): + type =DEV_PROP_U8 ; +break ; +case sizeof (u16): + type =DEV_PROP_U16 ; +break ; +case sizeof (u32): + type =DEV_PROP_U32 ; +break ; +case sizeof (u64): + type =DEV_PROP_U64 ; +break ; +default : +return -ENXIO ; + } + +return acpi_node_prop_read (fwnode, propname, type, val, nval); +} + +static int acpi_fwnode_property_read_string_array (struct fwnode_handle *fwnode, +const char *propname, +const char **val,size_t nval) +{ +return acpi_node_prop_read (fwnode, propname,DEV_PROP_STRING , + val, nval); +} + +static struct fwnode_handle * +acpi_fwnode_get_named_child_node (struct fwnode_handle *fwnode, +const char *childname) +{ +struct fwnode_handle *child; + +/* +* Find first matching named child node of this fwnode. +* For ACPI this will be a data only sub-node. +*/ +fwnode_for_each_child_node (fwnode, child) +if (acpi_data_node_match (child, childname)) +return child; + +return NULL ; +} + +const struct fwnode_operations acpi_fwnode_ops = { + .property_present = acpi_fwnode_property_present, + .property_read_int_array = acpi_fwnode_property_read_int_array, + .property_read_string_array = acpi_fwnode_property_read_string_array, + .get_parent = acpi_node_get_parent, + .get_next_child_node = acpi_get_next_subnode, + .get_named_child_node = acpi_fwnode_get_named_child_node, +};
drivers/acpi/scan.c +1 -0
@@ -1436,6 +1436,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, device->handle = handle; device->parent =acpi_bus_get_parent (handle); device->fwnode.type =FWNODE_ACPI ; + device->fwnode.ops = &acpi_fwnode_ops;acpi_set_device_status (device, sta);acpi_device_get_busid (device);acpi_set_pnp_ids (handle, &device->pnp, type);
drivers/base/property.c +82 -125
304 lines not on this page · raw message
drivers/of/property.c +102 -0
105 lines not on this page · raw message
include/linux/acpi.h +4 -0
@@ -56,6 +56,9 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev) acpi_fwnode_handle(adev) : NULL)#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 ) {struct fwnode_handle *fwnode;
@@ -65,6 +68,7 @@ static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)return NULL ; fwnode->type =FWNODE_ACPI_STATIC ; + fwnode->ops = &acpi_fwnode_ops;return fwnode; }
include/linux/fwnode.h +54 -0
73 lines not on this page · raw message
include/linux/of.h +2 -0
@@ -100,10 +100,12 @@ struct of_reconfig_data {/* initialize a node */ extern struct kobj_type of_node_ktype; +extern const struct fwnode_operations of_fwnode_ops;static inline void of_node_init (struct device_node *node) {kobject_init (&node->kobj, &of_node_ktype); node->fwnode.type =FWNODE_OF ; + node->fwnode.ops = &of_fwnode_ops; }/* true when node is initialized */
Signature · 1 line
2.7.4
A message that is not in the archive (sent off-list or not yet received): 1496231532-23601-3-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/[email protected]
Re: [PATCH v5 2/6] device property: Move FW type specific functionality to FW specific files
drivers/base/property.c int device_property_match_string(struct device *dev, const char *propname, · line 436
Quoted 3 lines · Sakari Ailus
drivers/base/property.c +3
-0+static int fwnode_property_read_int_array ( +struct fwnode_handle *fwnode,const char *propname, +unsigned int elem_size,void *val,size_t nval)
You forgot this one :)
Quoted 13 lines
drivers/base/property.c +13
-0+{ +int ret; + + ret =fwnode_call_int_op (fwnode, property_read_int_array, propname, + elem_size, val, nval); +if (ret == -EINVAL && !IS_ERR_OR_NULL (fwnode) && + !IS_ERR_OR_NULL (fwnode->secondary)) + ret =fwnode_call_int_op ( + fwnode->secondary, property_read_int_array, propname, + elem_size, val, nval); + +return ret; +}
[...]
Quoted 20 lines
include/linux/fwnode.h +20
-0+/** +* 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. +*/ +struct fwnode_operations { +void (*get)(struct fwnode_handle *fwnode); +void (*put)(struct fwnode_handle *fwnode); +bool (*property_present)(struct fwnode_handle *fwnode, +const char *propname); + int (*property_read_int_array)(struct fwnode_handle *fwnode,
include/linux/fwnode.h struct fwnode_endpoint { · line 76
Quoted 10 lines
include/linux/fwnode.h +10
-0+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);
I would do the following instead
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);
Yes, it is over 80 chars but it is more readable this way.
Just saying :) I'll leave this up to you.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1496231532-23601-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/[email protected]
PATCH v5 3/6 device property: Move fwnode graph ops to firmware specific locations
Move firmware specific implementations of the fwnode graph operations to firmware specific locations.
Depends-on: ("of: Make of_fwnode_handle() safer")
--- drivers/acpi/property.c | 40 ++++++++++++++++++++++ drivers/base/property.c | 91 +++++-------------------------------------------- drivers/of/property.c | 70 +++++++++++++++++++++++++++++-------- include/linux/fwnode.h | 14 ++++++++ 4 files changed, 117 insertions(+), 98 deletions(-)
drivers/acpi/property.c +40 -0
@@ -1179,6 +1179,42 @@ acpi_fwnode_get_named_child_node(struct fwnode_handle *fwnode,return NULL ; } +static struct fwnode_handle * +acpi_fwnode_graph_get_next_endpoint (struct fwnode_handle *fwnode, +struct fwnode_handle *prev) +{ +struct fwnode_handle *endpoint; + + endpoint =acpi_graph_get_next_endpoint (fwnode, prev); +if (IS_ERR (endpoint)) +return NULL ; + +return endpoint; +} + +static struct fwnode_handle * +acpi_fwnode_graph_get_remote_endpoint (struct fwnode_handle *fwnode) +{ +struct fwnode_handle *endpoint =NULL ; + +acpi_graph_get_remote_endpoint (fwnode,NULL ,NULL , &endpoint); + +return endpoint; +} + +static int acpi_fwnode_graph_parse_endpoint (struct fwnode_handle *fwnode, +struct fwnode_endpoint *endpoint) +{ +struct fwnode_handle *port_fwnode =fwnode_get_parent (fwnode); + + endpoint->local_fwnode = fwnode; + +fwnode_property_read_u32 (port_fwnode,"port" , &endpoint->port); +fwnode_property_read_u32 (fwnode,"endpoint" , &endpoint->id); + +return 0 ; +} +const struct fwnode_operations acpi_fwnode_ops = { .property_present = acpi_fwnode_property_present, .property_read_int_array = acpi_fwnode_property_read_int_array,
@@ -1186,4 +1222,8 @@ const struct fwnode_operations acpi_fwnode_ops = { .get_parent = acpi_node_get_parent, .get_next_child_node = acpi_get_next_subnode, .get_named_child_node = acpi_fwnode_get_named_child_node, + .graph_get_next_endpoint = acpi_fwnode_graph_get_next_endpoint, + .graph_get_remote_endpoint = acpi_fwnode_graph_get_remote_endpoint, + .graph_get_port_parent = acpi_node_get_parent, + .graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, };
drivers/base/property.c +8 -83
124 lines not on this page · raw message
drivers/of/property.c +55 -15
92 lines not on this page · raw message
include/linux/fwnode.h +14 -0
@@ -57,6 +57,11 @@ struct fwnode_endpoint {* @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);
@@ -76,6 +81,15 @@ struct fwnode_operations { 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) \
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Sakari Ailus
reviewerPATCH v5 4/6 device property: Introduce fwnode_device_is_available()
In reply to Sakari AilusAdd fwnode_device_is_available() to tell whether the device corresponding to a certain fwnode_handle is available for use.
--- drivers/acpi/property.c | 9 +++++++++ drivers/base/property.c | 10 ++++++++++ drivers/of/property.c | 6 ++++++ include/linux/fwnode.h | 1 + include/linux/property.h | 1 + 5 files changed, 27 insertions(+)
drivers/acpi/property.c +9 -0
@@ -1121,6 +1121,14 @@ int acpi_graph_get_remote_endpoint(struct fwnode_handle *fwnode,return 0 ; } +static bool acpi_fwnode_device_is_available (struct fwnode_handle *fwnode) +{ +if (!is_acpi_device_node (fwnode)) +return false; + +return acpi_device_is_present (to_acpi_device_node (fwnode)); +} +static bool acpi_fwnode_property_present (struct fwnode_handle *fwnode,const char *propname) {
@@ -1216,6 +1224,7 @@ static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode, }const struct fwnode_operations acpi_fwnode_ops = { + .device_is_available = acpi_fwnode_device_is_available, .property_present = acpi_fwnode_property_present, .property_read_int_array = acpi_fwnode_property_read_int_array, .property_read_string_array = acpi_fwnode_property_read_string_array,
drivers/base/property.c +10 -0
@@ -1021,6 +1021,16 @@ void fwnode_handle_put(struct fwnode_handle *fwnode)EXPORT_SYMBOL_GPL (fwnode_handle_put);/** +* fwnode_device_is_available - check if a device is available for use +* @fwnode: Pointer to the fwnode of the device. +*/ +bool fwnode_device_is_available (struct fwnode_handle *fwnode) +{ +return fwnode_call_int_op (fwnode, device_is_available); +} +EXPORT_SYMBOL_GPL (fwnode_device_is_available); + +/** * device_get_child_node_count - return the number of child nodes for device * @dev: Device to cound the child nodes for */
drivers/of/property.c +6 -0
@@ -775,6 +775,11 @@ static void of_fwnode_put(struct fwnode_handle *fwnode)of_node_put (to_of_node (fwnode)); } +static bool of_fwnode_device_is_available (struct fwnode_handle *fwnode) +{ +return of_device_is_available (to_of_node (fwnode)); +} +static bool of_fwnode_property_present (struct fwnode_handle *fwnode,const char *propname) {
@@ -895,6 +900,7 @@ static int of_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,const struct fwnode_operations of_fwnode_ops = { .get = of_fwnode_get, .put = of_fwnode_put, + .device_is_available = of_fwnode_device_is_available, .property_present = of_fwnode_property_present, .property_read_int_array = of_fwnode_property_read_int_array, .property_read_string_array = of_fwnode_property_read_string_array,
include/linux/fwnode.h +1 -0
@@ -66,6 +66,7 @@ struct fwnode_endpoint {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,
include/linux/property.h +1 -0
@@ -51,6 +51,7 @@ int device_property_read_string(struct device *dev, const char *propname,int device_property_match_string (struct device *dev,const char *propname,const char *string); +bool fwnode_device_is_available (struct fwnode_handle *fwnode);bool fwnode_property_present (struct fwnode_handle *fwnode,const char *propname); int fwnode_property_read_u8_array(struct fwnode_handle *fwnode, const char *propname, u8 *val,
Signature · 1 line
2.7.4
Sakari Ailus
reviewerPATCH v5 5/6 device property: Add FW type agnostic fwnode_graph_get_remote_node
In reply to Sakari AilusAdd fwnode_graph_get_remote_node() function which is equivalent to of_graph_get_remote_node() on OF.
--- drivers/base/property.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 39 insertions(+)
drivers/base/property.c +37 -0
@@ -1215,6 +1215,43 @@ fwnode_graph_get_remote_endpoint(struct fwnode_handle *fwnode)EXPORT_SYMBOL_GPL (fwnode_graph_get_remote_endpoint);/** +* fwnode_graph_get_remote_node - get remote parent node for given port/endpoint +* @fwnode: pointer to parent fwnode_handle containing graph port/endpoint +* @port_id: identifier of the parent port node +* @endpoint_id: identifier of the endpoint node +* +* Return: Remote fwnode handle associated with remote endpoint node linked +* to @node. Use fwnode_node_put() on it when done. +*/ +struct fwnode_handle *fwnode_graph_get_remote_node (struct fwnode_handle *fwnode, +u32 port_id,u32 endpoint_id) +{ +struct fwnode_handle *endpoint =NULL ; + +while ((endpoint =fwnode_graph_get_next_endpoint (fwnode, endpoint))) { +struct fwnode_endpoint fwnode_ep; +struct fwnode_handle *remote; +int ret; + + ret =fwnode_graph_parse_endpoint (endpoint, &fwnode_ep); +if (ret <0 ) +continue ; + +if (fwnode_ep.port != port_id || fwnode_ep.id != endpoint_id) +continue ; + + remote =fwnode_graph_get_remote_port_parent (endpoint); +if (!remote) +return NULL ; + +return fwnode_device_is_available (remote) ? remote :NULL ; + } + +return NULL ; +} +EXPORT_SYMBOL_GPL (fwnode_graph_get_remote_node); + +/** * fwnode_graph_parse_endpoint - parse common endpoint node properties * @fwnode: pointer to endpoint fwnode_handle * @endpoint: pointer to the fwnode endpoint data structure
include/linux/property.h +2 -0
@@ -281,6 +281,8 @@ struct fwnode_handle *fwnode_graph_get_remote_port( struct fwnode_handle *fwnode);struct fwnode_handle *fwnode_graph_get_remote_endpoint (struct fwnode_handle *fwnode); +struct fwnode_handle *fwnode_graph_get_remote_node (struct fwnode_handle *fwnode, +u32 port,u32 endpoint);int fwnode_graph_parse_endpoint (struct fwnode_handle *fwnode,struct fwnode_endpoint *endpoint);
Signature · 1 line
2.7.4
Sakari Ailus
reviewerPATCH v5 6/6 device property: Add fwnode_graph_get_port_parent
In reply to Sakari AilusFrom: Kieran Bingham <[email protected]>
Provide a helper to obtain the parent device fwnode without first parsing the remote-endpoint as per fwnode_graph_get_remote_port_parent.
--- drivers/base/property.c | 28 ++++++++++++++++++++++++---- include/linux/property.h | 2 ++ 2 files changed, 26 insertions(+), 4 deletions(-)
drivers/base/property.c +24 -4
@@ -1170,6 +1170,26 @@ fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,EXPORT_SYMBOL_GPL (fwnode_graph_get_next_endpoint);/** +* fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint +* @endpoint: Endpoint firmware node of the port +* +* Return: the firmware node of the device the @endpoint belongs to. +*/ +struct fwnode_handle * +fwnode_graph_get_port_parent (struct fwnode_handle *endpoint) +{ +struct fwnode_handle *port, *parent; + + port =fwnode_get_parent (endpoint); + parent =fwnode_call_ptr_op (port, graph_get_port_parent); + +fwnode_handle_put (port); + +return parent; +} +EXPORT_SYMBOL_GPL (fwnode_graph_get_port_parent); + +/** * fwnode_graph_get_remote_port_parent - Return fwnode of a remote device * @fwnode: Endpoint firmware node pointing to the remote endpoint *
@@ -1178,12 +1198,12 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);struct fwnode_handle *fwnode_graph_get_remote_port_parent (struct fwnode_handle *fwnode) { -struct fwnode_handle *port, *parent; +struct fwnode_handle *endpoint, *parent; - port =fwnode_graph_get_remote_port (fwnode); - parent =fwnode_call_ptr_op (port, graph_get_port_parent); + endpoint =fwnode_graph_get_remote_endpoint (fwnode); + parent =fwnode_graph_get_port_parent (endpoint); -fwnode_handle_put (port); +fwnode_handle_put (endpoint);return parent; }
include/linux/property.h +2 -0
@@ -275,6 +275,8 @@ void *device_get_mac_address(struct device *dev, char *addr, int alen);struct fwnode_handle *fwnode_graph_get_next_endpoint (struct fwnode_handle *fwnode,struct fwnode_handle *prev); +struct fwnode_handle * +fwnode_graph_get_port_parent (struct fwnode_handle *fwnode);struct fwnode_handle *fwnode_graph_get_remote_port_parent (struct fwnode_handle *fwnode); struct fwnode_handle *fwnode_graph_get_remote_port(
Signature · 1 line
2.7.4
Quoted 11 lines · Sakari Ailus
Kieran Bingham (1):
device property: Addfwnode_graph_get_port_parentSakari Ailus (5):
ACPI: Constify argument toacpi_device_is_present()
device property: Move FW type specific functionality to FW specific
files
device property: Move fwnode graph ops to firmware specific locations device property: Introducefwnode_device_is_available()device property: Add FW type agnosticfwnode_graph_get_remote_node
Quoted 11 lines
drivers/acpi/device_pm.c | 4 +- drivers/acpi/internal.h | 2 +- drivers/acpi/property.c | 117 ++++++++++++++++ drivers/acpi/scan.c | 10 +- drivers/base/property.c | 347 ++++++++++++++++++++--------------------------- drivers/of/property.c | 148 ++++++++++++++++++++ include/linux/acpi.h | 4 + include/linux/fwnode.h | 69 ++++++++++ include/linux/of.h | 2 + include/linux/property.h | 5 + 10 files changed, 501 insertions(+), 207 deletions(-)
In general looks good to me now. I commented on one patch but other than that no objections from me.
For the whole series,
Sakari Ailus
reviewerQuoted 7 lines · Mika Westerberg
In general looks good to me now. I commented on one patch but other than that no objections from me.
For the whole series,
Reviewed-by Mika Westerberg <[email protected]>
Great, thanks! I've changed the missed function definition and will post v6 in a moment.
Signature · 2 lines
Sakari Ailus [email protected]