Move firmware specific code to firmware specific locations
Subsystems (4)
Sakari Ailus
reviewerv3 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.
The set depends on the ACPI graph support v5 (10/13 v5.1) patches I posted a moment ago.
The patches may be found with dependencies here:
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=acpi-graph-cleaned>
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).
--
Kind regards,
Sakari
Sakari Ailus
reviewerPATCH v3 1/4 device property: Read strings using string array reading functions
Always read strings using of_property_read_string_array() instead of of_property_read_string(). This allows using a single operation struct callback for accessing strings.
Same for pset_prop_read_string_array() and pset_prop_read_string().
--- drivers/base/property.c | 47 ++--------------------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-)
drivers/base/property.c +2 -45
@@ -158,31 +158,6 @@ static int pset_prop_read_string_array(struct property_set *pset,return 0 ; } -static int pset_prop_read_string (struct property_set *pset, -const char *propname,const char **strings) -{ -const struct property_entry *prop; -const char *const *pointer; - - prop =pset_prop_get (pset, propname); -if (!prop) -return -EINVAL ; -if (!prop->is_string) -return -EILSEQ ; -if (prop->is_array) { - pointer = prop->pointer.str; -if (!pointer) -return -ENODATA ; - }else { - pointer = &prop->value.str; -if (*pointer &&strnlen (*pointer, prop->length) >= prop->length) -return -EILSEQ ; - } - - *strings = *pointer; -return 0 ; -} -struct fwnode_handle *dev_fwnode (struct device *dev) { return IS_ENABLED(CONFIG_OF) && dev->of_node ?
@@ -606,19 +581,6 @@ static int __fwnode_property_read_string_array(struct fwnode_handle *fwnode,return -ENXIO ; } -static int __fwnode_property_read_string (struct fwnode_handle *fwnode, -const char *propname,const char **val) -{ -if (is_of_node (fwnode)) -return of_property_read_string (to_of_node (fwnode), propname, val); -else if (is_acpi_node (fwnode)) -return acpi_node_prop_read (fwnode, propname,DEV_PROP_STRING , - val,1 ); -else if (is_pset_node (fwnode)) -return pset_prop_read_string (to_pset_node (fwnode), propname, val); -return -ENXIO ; -} -/** * fwnode_property_read_string_array - return string array property of a node * @fwnode: Firmware node to get the property of
@@ -670,14 +632,9 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_string_array);int fwnode_property_read_string (struct fwnode_handle *fwnode,const char *propname,const char **val) { -int ret; +int ret =fwnode_property_read_string_array (fwnode, propname, val,1 ); - ret =__fwnode_property_read_string (fwnode, propname, val); -if (ret == -EINVAL && !IS_ERR_OR_NULL (fwnode) && - !IS_ERR_OR_NULL (fwnode->secondary)) - ret =__fwnode_property_read_string (fwnode->secondary, - propname, val); -return ret; +return ret <0 ? ret :0 ; }EXPORT_SYMBOL_GPL (fwnode_property_read_string);
Signature · 1 line
2.7.4
Sakari Ailus
reviewerPATCH v3 2/4 device property: Implement fwnode_get_next_parent() using fwnode interface
In reply to Sakari Ailusfwnode_get_next_parent() can be implemented using fwnode interface. Do that to avoid implementing an additional callback for the function in struct fwnode_operations.
--- drivers/base/property.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/base/property.c +2 -10
@@ -945,17 +945,9 @@ EXPORT_SYMBOL_GPL(device_add_properties);*/ struct fwnode_handle *fwnode_get_next_parent (struct fwnode_handle *fwnode) { -struct fwnode_handle *parent =NULL ; +struct fwnode_handle *parent =fwnode_call_ptr_op (fwnode, get_parent); -if (is_of_node (fwnode)) { -struct device_node *node; - - node =of_get_next_parent (to_of_node (fwnode)); -if (node) - parent = &node->fwnode; - }else if (is_acpi_node (fwnode)) { - parent =acpi_node_get_parent (fwnode); - } +fwnode_handle_put (fwnode);return parent; }
Signature · 1 line
2.7.4
A message that is not in the archive (sent off-list or not yet received): 1489671289-20406-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/[email protected]
PATCH v3 3/4 device property: Move FW type specific functionality to FW specific files
The 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.
--- drivers/acpi/property.c | 87 +++++++++++++++ drivers/acpi/scan.c | 1 + drivers/base/property.c | 280 +++++++++++++++++++----------------------------- drivers/of/base.c | 99 +++++++++++++++++ include/linux/acpi.h | 4 + include/linux/fwnode.h | 53 +++++++++ include/linux/of.h | 2 + 7 files changed, 355 insertions(+), 171 deletions(-)
drivers/acpi/property.c +87 -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);
@@ -1107,3 +1108,89 @@ 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) +{ +int array_len =acpi_node_prop_read (fwnode, propname,DEV_PROP_STRING , +NULL , nval); +int read_len; +int ret; + +/* Return if val is NULL or if there was an error */ +if (!val || array_len <0 ) +return array_len; + + read_len =min_t (int, nval, array_len); + + ret =acpi_node_prop_read (fwnode, propname,DEV_PROP_STRING , + val, read_len); +if (ret <0 ) +return ret; + +return read_len; +} + +static struct fwnode_handle *acpi_fwnode_get_parent ( +struct fwnode_handle *fwnode) +{ +return acpi_node_get_parent (fwnode); +} + +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_fwnode_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
@@ -1441,6 +1441,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 +109 -171
377 lines not on this page · raw message
drivers/of/base.c +99 -0
102 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 +53 -0
72 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 · 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
Rob Herring
maintainerRe: [PATCH v3 3/4] device property: Move FW type specific functionality to FW specific files
Quoted 11 lines · Sakari Ailus
The 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.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/acpi/property.c | 87 +++++++++++++++ drivers/acpi/scan.c | 1 + drivers/base/property.c | 280 +++++++++++++++++++----------------------------- drivers/of/base.c | 99 +++++++++++++++++
This is the opposite direction everything else has been moving. For example, I2C parsing is in drivers/i2c. But I guess this is a bit different.
In any case, please move this to drivers/of/property.c (and perhaps move all of of_property_* there too).
Rob
Sakari Ailus
reviewerRe: [PATCH v3 3/4] device property: Move FW type specific functionality to FW specific files
Hi Rob,
Quoted 14 lines · Rob Herring
Quoted 11 lines · Sakari Ailus
The 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.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/acpi/property.c | 87 +++++++++++++++ drivers/acpi/scan.c | 1 + drivers/base/property.c | 280 +++++++++++++++++++----------------------------- drivers/of/base.c | 99 +++++++++++++++++
Quoted 6 lines
This is the opposite direction everything else has been moving. For example, I2C parsing is in
drivers/i2c. But I guess this is a bit different.In any case, please move this to
drivers/of/property.c(and perhaps move all of of_property_* there too).
Ok.
There appear to be quite a few functions dealing with properties in drivers/of/base.c either directly reading their values or otherwise accessing them. Let me see if I can find a roughly coherent set of functions to move to property.c. I'll move the existing functions there first, creating a new patch before this one.
Signature · 4 lines
Kind regards, Sakari Ailus [email protected]
Sakari Ailus
reviewerRe: [PATCH v3 3/4] device property: Move FW type specific functionality to FW specific files
Cc Frank.
Quoted 33 lines · Sakari Ailus
Hi Rob,
Quoted 15 lines · Rob Herring
Quoted 5 lines · Sakari Ailus
The 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.
Quoted 7 lines
Signed-off-by Sakari Ailus <[email protected]>--- drivers/acpi/property.c | 87 +++++++++++++++ drivers/acpi/scan.c | 1 + drivers/base/property.c | 280 +++++++++++++++++++----------------------------- drivers/of/base.c | 99 +++++++++++++++++Quoted 6 lines
This is the opposite direction everything else has been moving. For example, I2C parsing is in
drivers/i2c. But I guess this is a bit different.In any case, please move this to
drivers/of/property.c(and perhaps move all of of_property_* there too).Ok.
There appear to be quite a few functions dealing with properties in
drivers/of/base.ceither directly reading their values or otherwise accessing them. Let me see if I can find a roughly coherent set of functions to move toproperty.c. I'll move the existing functions there first, creating a new patch before this one.
Signature · 2 lines
Sakari Ailus [email protected]
PATCH v3 4/4 device property: Move fwnode graph ops to firmware specific locations
In reply to a message not in the archiveMove firmware specific implementations of the fwnode graph operations to firmware specific locations.
--- drivers/acpi/property.c | 61 ++++++++++++++++++++++++++++++++ drivers/base/property.c | 92 +++---------------------------------------------- drivers/of/base.c | 70 +++++++++++++++++++++++++++++++++++++ include/linux/fwnode.h | 16 +++++++++ 4 files changed, 152 insertions(+), 87 deletions(-)
drivers/acpi/property.c +61 -0
@@ -1186,6 +1186,62 @@ static struct fwnode_handle *acpi_fwnode_get_named_child_node(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 struct fwnode_handle *acpi_fwnode_graph_get_remote_port ( +struct fwnode_handle *fwnode) +{ +struct fwnode_handle *port =NULL ; + +acpi_graph_get_remote_endpoint (fwnode,NULL , &port,NULL ); + +return port; +} + +static struct fwnode_handle *acpi_fwnode_graph_get_remote_port_parent ( +struct fwnode_handle *fwnode) +{ +struct fwnode_handle *parent =NULL ; + +acpi_graph_get_remote_endpoint (fwnode, &parent,NULL ,NULL ); + +return parent; +} + +static int acpi_fwnode_graph_parse_endpoint (struct fwnode_handle *fwnode, +struct fwnode_endpoint *endpoint) +{ +struct fwnode_handle *port_fwnode =fwnode_get_parent (fwnode); +struct fwnode_handle *iter; + + 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,
@@ -1193,4 +1249,9 @@ const struct fwnode_operations acpi_fwnode_ops = { .get_parent = acpi_fwnode_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_remote_port = acpi_fwnode_graph_get_remote_port, + .graph_get_remote_port_parent = acpi_fwnode_graph_get_remote_port_parent, + .graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, };
drivers/base/property.c +5 -87
123 lines not on this page · raw message
drivers/of/base.c +70 -0
80 lines not on this page · raw message
include/linux/fwnode.h +16 -0
@@ -57,6 +57,12 @@ 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 an endpoint +* node. +* @graph_get_remote_port: Return the remote port node of an endpoint node. +* @graph_get_remote_port_parent: Return the parent of a port node of the +* remote endpoint node of an endpoint node. */ struct fwnode_operations {void (*get)(struct fwnode_handle *fwnode);
@@ -75,6 +81,16 @@ struct fwnode_operations { 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_remote_port)( +struct fwnode_handle *fwnode); +struct fwnode_handle *(*graph_get_remote_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
A message that is not in the archive (sent off-list or not yet received): 1489671289-20406-5-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/[email protected]
Re: [PATCH v3 4/4] device property: Move fwnode graph ops to firmware specific locations
Quoted 10 lines · Sakari Ailus
Move firmware specific implementations of the fwnode graph operations to firmware specific locations.
--- drivers/acpi/property.c | 61 ++++++++++++++++++++++++++++++++ drivers/base/property.c | 92 +++---------------------------------------------- drivers/of/base.c | 70 +++++++++++++++++++++++++++++++++++++ include/linux/fwnode.h | 16 +++++++++ 4 files changed, 152 insertions(+), 87 deletions(-)
As I've mentioned before, this is just propagating APIs I would like to get rid of. See my series cleaning up DRM users[1].
Quoted 10 lines
drivers/of/base.c +2
-0@@ -2624,6 +2624,71 @@ static struct fwnode_handle *of_fwnode_get_named_child_node(return NULL ; } +static struct fwnode_handle *of_fwnode_graph_get_next_endpoint ( +struct fwnode_handle *fwnode,struct fwnode_handle *prev)
drivers/of/base.c static struct fwnode_handle *of_fwnode_get_named_child_node( · line 2638
Quoted 10 lines
drivers/of/base.c +10
-0+{ +struct device_node *node; + + node =of_graph_get_next_endpoint (to_of_node (fwnode), +to_of_node (prev)); +if (node) +return of_fwnode_handle (node); + +return NULL ; +}
For example, most callers of of_graph_get_next_endpoint really just want port=0, endpoint=0 and then they want the remote node. As the assignment of port and endpoint numbers are fixed for a device, drivers should be explicit about which port/endpoint they want. The actual handle to either the port or endpoint nodes are mostly irrelevant. We only really need the endpoint node handles when we have properties in the endpoints.
Rob
[1] https://lkml.org/lkml/2017/2/9/592
--
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
reviewerRe: [PATCH v3 4/4] device property: Move fwnode graph ops to firmware specific locations
Hi Rob,
Quoted 13 lines · Rob Herring
Quoted 10 lines · Sakari Ailus
Move firmware specific implementations of the fwnode graph operations to firmware specific locations.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/acpi/property.c | 61 ++++++++++++++++++++++++++++++++ drivers/base/property.c | 92 +++---------------------------------------------- drivers/of/base.c | 70 +++++++++++++++++++++++++++++++++++++ include/linux/fwnode.h | 16 +++++++++ 4 files changed, 152 insertions(+), 87 deletions(-)
Quoted 2 lines
As I've mentioned before, this is just propagating APIs I would like to get rid of. See my series cleaning up DRM users[1].
Why would you want to get rid of the existing APIs? They do fit well for the purpose they're currently used for on V4L2, at least. That could be because the current API was implemented *for* V4L2. If you'd like to add a new one, then at least I'd very much like to keep what exists at the moment.
Please see e.g. isp_fwnodes_parse() in drivers/media/platform/omap3isp/isp.c . That function is generic enough to be moved to the V4L2 framework, with a driver callback to handle driver specific matters.
Quoted 22 lines
Quoted 11 lines
drivers/of/base.c +2
-0@@ -2624,6 +2624,71 @@ static struct fwnode_handle *of_fwnode_get_named_child_node(return NULL ; } +static struct fwnode_handle *of_fwnode_graph_get_next_endpoint ( +struct fwnode_handle *fwnode,struct fwnode_handle *prev)drivers/of/base.c static struct fwnode_handle *of_fwnode_get_named_child_node( · line 2638
Quoted 10 lines
drivers/of/base.c +10
-0+{ +struct device_node *node; + + node =of_graph_get_next_endpoint (to_of_node (fwnode), +to_of_node (prev)); +if (node) +return of_fwnode_handle (node); + +return NULL ; +}
Quoted 7 lines
For example, most callers of
of_graph_get_next_endpointreally just want port=0, endpoint=0 and then they want the remote node. As the assignment of port and endpoint numbers are fixed for a device, drivers should be explicit about which port/endpoint they want. The actual handle to either the port or endpoint nodes are mostly irrelevant. We only really need the endpoint node handles when we have properties in the endpoints.
I certainly don't mind adding a new API if there are use cases the existing one does not serve well. But please don't remove the enumeration API. It's simply way more practical.
If you have one or two ports and an endpoint in each, perhaps it's ok just to try check if one more more of them are around. Some devices may have e.g. six ports today and I don't think that number will go down in the future, it's rather going to increase.
The caller can also find the endpoints without knowing the endpoint numbers in advance. In a number of devices' DT binding documentation it is not explicitly stated that endpoint IDs have a special meaning. I'm not fully certain everything would keep on working fine if the drivers that previously did not care about endpoint numbers would start e.g. requiring zero from now on.
An analogous interface is the _ENUM IOCTLs in V4L2, with the difference that it's towards the user space.
Signature · 4 lines
Kind regards, Sakari Ailus [email protected]
Sakari Ailus
reviewerRe: [PATCH v3 4/4] device property: Move fwnode graph ops to firmware specific locations
Cc Frank. (Oops.)
Quoted 81 lines · Sakari Ailus
Hi Rob,
Quoted 14 lines · Rob Herring
Quoted 11 lines · Sakari Ailus
Move firmware specific implementations of the fwnode graph operations to firmware specific locations.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/acpi/property.c | 61 ++++++++++++++++++++++++++++++++ drivers/base/property.c | 92 +++---------------------------------------------- drivers/of/base.c | 70 +++++++++++++++++++++++++++++++++++++ include/linux/fwnode.h | 16 +++++++++ 4 files changed, 152 insertions(+), 87 deletions(-)Quoted 2 lines
As I've mentioned before, this is just propagating APIs I would like to get rid of. See my series cleaning up DRM users[1].
Why would you want to get rid of the existing APIs? They do fit well for the purpose they're currently used for on V4L2, at least. That could be because the current API was implemented *for* V4L2. If you'd like to add a new one, then at least I'd very much like to keep what exists at the moment.
Please see e.g.
isp_fwnodes_parse()indrivers/media/platform/omap3isp/isp.c. That function is generic enough to be moved to the V4L2 framework, with a driver callback to handle driver specific matters.Quoted 23 lines
Quoted 12 lines
drivers/of/base.c +2
-0@@ -2624,6 +2624,71 @@ static struct fwnode_handle *of_fwnode_get_named_child_node( return NULL; } +static struct fwnode_handle *of_fwnode_graph_get_next_endpoint ( +struct fwnode_handle *fwnode,struct fwnode_handle *prev)drivers/of/base.c static struct fwnode_handle · line 2639
Quoted 10 lines
drivers/of/base.c +10
-0+{ +struct device_node *node; + + node =of_graph_get_next_endpoint (to_of_node (fwnode), +to_of_node (prev)); +if (node) +return of_fwnode_handle (node); + +return NULL ; +}Quoted 7 lines
For example, most callers of
of_graph_get_next_endpointreally just want port=0, endpoint=0 and then they want the remote node. As the assignment of port and endpoint numbers are fixed for a device, drivers should be explicit about which port/endpoint they want. The actual handle to either the port or endpoint nodes are mostly irrelevant. We only really need the endpoint node handles when we have properties in the endpoints.I certainly don't mind adding a new API if there are use cases the existing one does not serve well. But please don't remove the enumeration API. It's simply way more practical.
If you have one or two ports and an endpoint in each, perhaps it's ok just to try check if one more more of them are around. Some devices may have e.g. six ports today and I don't think that number will go down in the future, it's rather going to increase.
The caller can also find the endpoints without knowing the endpoint numbers in advance. In a number of devices' DT binding documentation it is not explicitly stated that endpoint IDs have a special meaning. I'm not fully certain everything would keep on working fine if the drivers that previously did not care about endpoint numbers would start e.g. requiring zero from now on.
An analogous interface is the
_ENUMIOCTLs in V4L2, with the difference that it's towards the user space.
Signature · 2 lines
Sakari Ailus [email protected]