Skip to contentSkip to conversation

Move firmware specific code to firmware specific locations

PATCH In review Sakari Ailus 7 participants 17 messages Jun 6, 2017 – Jun 22, 2017 1 message not in the archive

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

v7 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 an immutable branch in Rob's tree here:

git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git dt/property-move

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 v6:

- Move changes intended to be in patch 2 from patch 3. This was related to NULL-safe of_fwnode_handle(). No other changes.

since v5:

- Rewrap fwnode_property_read_int_array() to match the layout of the rest of the file.

- Add Reviewed-by from Mika.

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).

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  | 348 ++++++++++++++++++++---------------------------
 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, 502 insertions(+), 207 deletions(-)
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
reviewer
#1 lore raw

PATCH v7 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
index 798d500..b404604 100644
@@ -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
index 66229ff..7300240 100644
@@ -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
index e39ec7b..b609cbf 100644
@@ -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

A message that is not in the archive (sent off-list or not yet received): 1496741861-8240-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/[email protected]

#3 lore raw

PATCH v7 2/6 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.

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 | 208 +++++++++++++++++++-----------------------------
 drivers/of/property.c   |  90 +++++++++++++++++++++
 include/linux/acpi.h    |   4 +
 include/linux/fwnode.h  |  54 +++++++++++++
 include/linux/of.h      |   2 +
 7 files changed, 302 insertions(+), 125 deletions(-)
drivers/acpi/property.c +68 -0
index 9364398..14013f6 100644
@@ -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
index b609cbf..fe379a0 100644
@@ -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 +83 -125

305 lines not on this page · raw message

drivers/of/property.c +90 -0

93 lines not on this page · raw message

include/linux/acpi.h +4 -0
index 137e4a3..b8f23c5 100644
@@ -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
index 29b7b738b..cdbfa88 100644
@@ -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
maintainer Acked-by on v7 2/6
#4 lore raw

Re: [PATCH v7 2/6] device property: Move FW type specific functionality to FW specific files

Quoted 23 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.

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 | 208 +++++++++++++++++++-----------------------------
 drivers/of/property.c   |  90 +++++++++++++++++++++
 include/linux/acpi.h    |   4 +
 include/linux/fwnode.h  |  54 +++++++++++++
 include/linux/of.h      |   2 +
 7 files changed, 302 insertions(+), 125 deletions(-)
drivers/acpi/property.c +0 -0
index 9364398..14013f6 100644

drivers/acpi/property.c static bool acpi_nondev_subnode_extract(const union acpi_object *desc, · line 60

Quoted 4 lines
drivers/acpi/property.c +1 -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;

Mainly in interest of not growing fwnode_handle, we could remove .type and just have checks like "ops == &acpi_fwnode_ops".

Otherwise, for patches 2,3,4:

reviewer
#5 lore raw

Re: [PATCH v7 2/6] device property: Move FW type specific functionality to FW specific files

Hi Rob,

Quoted 33 lines · Rob Herring
Quoted 23 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.

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 | 208 +++++++++++++++++++-----------------------------
 drivers/of/property.c   |  90 +++++++++++++++++++++
 include/linux/acpi.h    |   4 +
 include/linux/fwnode.h  |  54 +++++++++++++
 include/linux/of.h      |   2 +
 7 files changed, 302 insertions(+), 125 deletions(-)
drivers/acpi/property.c +0 -0
index 9364398..14013f6 100644

drivers/acpi/property.c static bool acpi_nondev_subnode_extract(const union acpi_object *desc, · line 60

Quoted 4 lines
drivers/acpi/property.c +1 -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;

Mainly in interest of not growing fwnode_handle, we could remove .type and just have checks like "ops == &acpi_fwnode_ops".

Quoted 3 lines

Otherwise, for patches 2,3,4:

Thanks for the ack!

The ops field is currently not unique for all types of fwnodes:

type ops
---------------------------------------
FWNODE_ACPI_STATIC acpi_fwnode_ops
FWNODE_ACPI_DATA acpi_fwnode_ops
FWNODE_ACPI acpi_fwnode_ops
FWNODE_OF of_fwnode_ops
FWNODE_PSET pset_fwnode_ops
FWNODE_IRQCHIP NULL

We could define three more ops for fwnodes (ACPI_STATIC, ACPI_DATA and IRQCHIP). I presume the effect on the total memory consumption is still a positive one. Especially it does not increase as much with the number of fwnodes.

I have a patch but I'll test it still a little before submitting it.

Signature · 4 lines
Kind regards,

Sakari Ailus
[email protected]
reviewer
#6 lore raw

PATCH v7 3/6 device property: Move fwnode graph ops to firmware specific locations

In reply to Sakari Ailus

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   | 52 ++++++++++++++++++++++++++++
 include/linux/fwnode.h  | 14 ++++++++
 4 files changed, 114 insertions(+), 83 deletions(-)
drivers/acpi/property.c +40 -0
index 14013f6..a24ca61 100644
@@ -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 +52 -0

62 lines not on this page · raw message

include/linux/fwnode.h +14 -0
index 8f64b3a..e315d86 100644
@@ -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 · 1 line
2.7.4
reviewer
#7 lore raw

PATCH v7 4/6 device property: Introduce fwnode_device_is_available()

In reply to Sakari Ailus

Add 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
index a24ca61..917c789 100644
@@ -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
index e1a58ac..b979f8a 100644
@@ -1022,6 +1022,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
index e859e41..c96389b 100644
@@ -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
index e315d86..9ab3754 100644
@@ -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
index 2f48261..7be014a 100644
@@ -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
reviewer
#8 lore raw

PATCH v7 5/6 device property: Add FW type agnostic fwnode_graph_get_remote_node

In reply to Sakari Ailus

Add 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
index b979f8a..ac3590b 100644
@@ -1216,6 +1216,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
index 7be014a..0597a74 100644
@@ -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
reviewer
#9 lore raw

PATCH v7 6/6 device property: Add fwnode_graph_get_port_parent

In reply to Sakari Ailus

From: 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
index ac3590b..692007e 100644
@@ -1171,6 +1171,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
  *
@@ -1179,12 +1199,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
index 0597a74..7e77039 100644
@@ -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
reviewer
#10 lore raw

PATCH 7/7 device property: Get rid of struct fwnode_handle type field

In reply to Sakari Ailus

Instead of relying on the struct fwnode_handle type field, define fwnode_operations structs for all separate types of fwnodes. To find out the type, compare to the ops field to relevant ops structs.

This change has two benefits:

1. it avoids adding the type field to each and every instance of struct fwnode_handle, thus saving memory and

2. makes the ops field the single factor that defines both the types of the fwnode as well as defines the implementation of its operations, decreasing the possibility of bugs when developing code dealing with fwnode internals.

The drawback is that there are a few fwnode_operations structs that are essentially used only for the pointer value.

---

Hi Rob and others,

This gets rid of the type field. The end result is perhaps somewhat more muddled (no explicit list of types, extra fwnode_operations structs) but the number of places where the node type is needed is really, really low. Let me know what do you think --- should we proceed with this approach (or not)?

Tested on both DT (ARM) and ACPI (x86-64).

Regards,
Sakari

 drivers/acpi/property.c   | 47 ++++++++++++++++++++++++++++-------------------
 drivers/acpi/scan.c       |  3 +--
 drivers/base/property.c   |  5 +++--
 drivers/of/property.c     |  1 +
 include/acpi/acpi_bus.h   | 19 +++++++++++++++----
 include/linux/acpi.h      |  8 ++------
 include/linux/fwnode.h    | 11 -----------
 include/linux/irqdomain.h |  4 +++-
 include/linux/of.h        |  3 +--
 kernel/irq/irqdomain.c    |  4 +++-
 10 files changed, 57 insertions(+), 48 deletions(-)
drivers/acpi/property.c +28 -19
index 917c789..0c56161 100644
@@ -56,8 +56,7 @@ static bool acpi_nondev_subnode_extract(const union acpi_object *desc,
 		return false;
 
 	dn->name = link->package.elements[0].string.pointer;
-	dn->fwnode.type = FWNODE_ACPI_DATA;
-	dn->fwnode.ops = &acpi_fwnode_ops;
+	dn->fwnode.ops = &acpi_data_fwnode_ops;
 	dn->parent = parent;
 	INIT_LIST_HEAD(&dn->data.subnodes);
 
@@ -469,10 +468,10 @@ EXPORT_SYMBOL_GPL(acpi_dev_get_property);
 
 static struct acpi_device_data *acpi_device_data_of_node(struct fwnode_handle *fwnode)
 {
-	if (fwnode->type == FWNODE_ACPI) {
+	if (is_acpi_device_node(fwnode)) {
 		struct acpi_device *adev = to_acpi_device_node(fwnode);
 		return &adev->data;
-	} else if (fwnode->type == FWNODE_ACPI_DATA) {
+	} else if (is_acpi_data_node(fwnode)) {
 		struct acpi_data_node *dn = to_acpi_data_node(fwnode);
 		return &dn->data;
 	}
@@ -903,7 +902,7 @@ struct fwnode_handle *acpi_get_next_subnode(struct fwnode_handle *fwnode,
 	struct acpi_device *adev = to_acpi_device_node(fwnode);
 	struct list_head *head, *next;
 
-	if (!child || child->type == FWNODE_ACPI) {
+	if (!child || is_acpi_device_node(child)) {
 		if (adev)
 			head = &adev->children;
 		else
@@ -927,7 +926,7 @@ struct fwnode_handle *acpi_get_next_subnode(struct fwnode_handle *fwnode,
 	}
 
  nondev:
-	if (!child || child->type == FWNODE_ACPI_DATA) {
+	if (!child || is_acpi_data_node(child)) {
 		struct acpi_data_node *data = to_acpi_data_node(fwnode);
 		struct acpi_data_node *dn;
 
@@ -1223,16 +1222,26 @@ static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
 	return 0;
 }
 
-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,
-	.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,
-};
+#define DECLARE_ACPI_FWNODE_OPS(ops) \
+	const struct fwnode_operations 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, \
+		.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, \
+	}; \
+	EXPORT_SYMBOL_GPL(ops)
+
+DECLARE_ACPI_FWNODE_OPS(acpi_device_fwnode_ops);
+DECLARE_ACPI_FWNODE_OPS(acpi_data_fwnode_ops);
+DECLARE_ACPI_FWNODE_OPS(acpi_static_fwnode_ops);
drivers/acpi/scan.c +1 -2
index fe379a0..53e268b 100644
@@ -1435,8 +1435,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
 	device->device_type = type;
 	device->handle = handle;
 	device->parent = acpi_bus_get_parent(handle);
-	device->fwnode.type = FWNODE_ACPI;
-	device->fwnode.ops = &acpi_fwnode_ops;
+	device->fwnode.ops = &acpi_device_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 +3 -2
index 692007e..09770fc 100644
@@ -25,9 +25,11 @@ struct property_set {
 	const struct property_entry *properties;
 };
 
+static const struct fwnode_operations pset_fwnode_ops;
+
 static inline bool is_pset_node(struct fwnode_handle *fwnode)
 {
-	return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_PDATA;
+	return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &pset_fwnode_ops;
 }
 
 static inline struct property_set *to_pset_node(struct fwnode_handle *fwnode)
@@ -900,7 +902,6 @@ int device_add_properties(struct device *dev,
 	if (IS_ERR(p))
 		return PTR_ERR(p);
 
-	p->fwnode.type = FWNODE_PDATA;
 	p->fwnode.ops = &pset_fwnode_ops;
 	set_secondary_fwnode(dev, &p->fwnode);
 	return 0;
drivers/of/property.c +1 -0
index c96389b..edd629b 100644
@@ -912,3 +912,4 @@ const struct fwnode_operations of_fwnode_ops = {
 	.graph_get_port_parent = of_fwnode_graph_get_port_parent,
 	.graph_parse_endpoint = of_fwnode_graph_parse_endpoint,
 };
+EXPORT_SYMBOL_GPL(of_fwnode_ops);
include/acpi/acpi_bus.h +15 -4
index 197f3ff..e724afc 100644
@@ -394,15 +394,21 @@ struct acpi_data_node {
 	struct completion kobj_done;
 };
 
+extern const struct fwnode_operations acpi_device_fwnode_ops;
+extern const struct fwnode_operations acpi_data_fwnode_ops;
+extern const struct fwnode_operations acpi_static_fwnode_ops;
+
 static inline bool is_acpi_node(struct fwnode_handle *fwnode)
 {
-	return !IS_ERR_OR_NULL(fwnode) && (fwnode->type == FWNODE_ACPI
-		|| fwnode->type == FWNODE_ACPI_DATA);
+	return !IS_ERR_OR_NULL(fwnode) &&
+		(fwnode->ops == &acpi_device_fwnode_ops
+		 || fwnode->ops == &acpi_data_fwnode_ops);
 }
 
 static inline bool is_acpi_device_node(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;
 }
 
 static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
@@ -413,7 +419,12 @@ static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwno
 
 static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
 {
-	return fwnode && fwnode->type == FWNODE_ACPI_DATA;
+	return fwnode && fwnode->ops == &acpi_data_fwnode_ops;
+}
+
+static inline bool is_acpi_static_node(struct fwnode_handle *fwnode)
+{
+	return fwnode && fwnode->ops == &acpi_static_fwnode_ops;
 }
 
 static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
include/linux/acpi.h +2 -6
index b8f23c5..ad19760 100644
@@ -56,9 +56,6 @@ 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;
@@ -67,15 +64,14 @@ static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
 	if (!fwnode)
 		return NULL;
 
-	fwnode->type = FWNODE_ACPI_STATIC;
-	fwnode->ops = &acpi_fwnode_ops;
+	fwnode->ops = &acpi_static_fwnode_ops;
 
 	return fwnode;
 }
 
 static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode)
 {
-	if (WARN_ON(!fwnode || fwnode->type != FWNODE_ACPI_STATIC))
+	if (WARN_ON(!fwnode || !is_acpi_static_node(fwnode)))
 		return;
 
 	kfree(fwnode);
include/linux/fwnode.h +0 -11
index 9ab3754..e7ca4c5 100644
@@ -14,20 +14,9 @@
 
 #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_handle {
-	enum fwnode_type type;
 	struct fwnode_handle *secondary;
 	const struct fwnode_operations *ops;
 };
include/linux/irqdomain.h +3 -1
index 9f36160..ee1910c 100644
@@ -233,9 +233,11 @@ static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node)
 	return node ? &node->fwnode : NULL;
 }
 
+extern const struct fwnode_operations irqchip_fwnode_ops;
+
 static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
 {
-	return fwnode && fwnode->type == FWNODE_IRQCHIP;
+	return fwnode && fwnode->ops == &irqchip_fwnode_ops;
 }
 
 static inline
include/linux/of.h +1 -2
index cdbfa88..6e39aa1 100644
@@ -104,7 +104,6 @@ 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;
 }
 
@@ -152,7 +151,7 @@ void of_core_init(void);
 
 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)						\
kernel/irq/irqdomain.c +3 -1
index 31805f2..e746c42 100644
@@ -31,6 +31,8 @@ struct irqchip_fwid {
 	void *data;
 };
 
+const struct fwnode_operations irqchip_fwnode_ops;
+
 /**
  * irq_domain_alloc_fwnode - Allocate a fwnode_handle suitable for
  *                           identifying an irq domain
@@ -55,7 +57,7 @@ struct fwnode_handle *irq_domain_alloc_fwnode(void *data)
 
 	fwid->name = name;
 	fwid->data = data;
-	fwid->fwnode.type = FWNODE_IRQCHIP;
+	fwid->fwnode.ops = &irqchip_fwnode_ops;
 	return &fwid->fwnode;
 }
 EXPORT_SYMBOL_GPL(irq_domain_alloc_fwnode);
Signature · 1 line
2.7.4
#11 lore raw

Re: [PATCH v7.1 7/7] device property: Get rid of struct fwnode_handle type field

Quoted 9 lines · Sakari Ailus
drivers/acpi/property.c +9 -0
+#define DECLARE_ACPI_FWNODE_OPS(ops) \
+	const struct fwnode_operations 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, \
+		.get_parent = acpi_node_get_parent, \

drivers/acpi/property.c static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode, · line 1243

Quoted 10 lines
drivers/acpi/property.c +10 -0
+		.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, \
+	}; \
+	EXPORT_SYMBOL_GPL(ops)

Can you align those backslashes, like

	const struct fwnode_operations ops = { 				\
		.device_is_available = acpi_fwnode_device_is_available, \
		.property_present = acpi_fwnode_property_present,	\
		...

other than that the patch looks good.

#12 lore raw

Re: [PATCH v7.1 7/7] device property: Get rid of struct fwnode_handle type field

Quoted 23 lines · Mika Westerberg
Quoted 9 lines · Sakari Ailus
drivers/acpi/property.c +9 -0
+#define DECLARE_ACPI_FWNODE_OPS(ops) \
+	const struct fwnode_operations 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, \
+		.get_parent = acpi_node_get_parent, \

drivers/acpi/property.c static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode, · line 1243

Quoted 10 lines
drivers/acpi/property.c +10 -0
+		.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, \
+	}; \
+	EXPORT_SYMBOL_GPL(ops)

Can you align those backslashes, like

Quoted 6 lines
	const struct fwnode_operations ops = { 				\
		.device_is_available = acpi_fwnode_device_is_available, \
		.property_present = acpi_fwnode_property_present,	\
		...

other than that the patch looks good.

Thanks for the review.

Fixed in v7.2.

Signature · 2 lines
Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
reviewer
#13 lore raw

PATCH 7/7 device property: Get rid of struct fwnode_handle type field

In reply to Sakari Ailus

Instead of relying on the struct fwnode_handle type field, define fwnode_operations structs for all separate types of fwnodes. To find out the type, compare to the ops field to relevant ops structs.

This change has two benefits:

1. it avoids adding the type field to each and every instance of struct fwnode_handle, thus saving memory and

2. makes the ops field the single factor that defines both the types of the fwnode as well as defines the implementation of its operations, decreasing the possibility of bugs when developing code dealing with fwnode internals.

---
changes since v7.1:

- Align backslashes in DECLARE_ACPI_FWNODE_OPS() macro.

 drivers/acpi/property.c   | 47 ++++++++++++++++++++++++++++-------------------
 drivers/acpi/scan.c       |  3 +--
 drivers/base/property.c   |  5 +++--
 drivers/of/property.c     |  1 +
 include/acpi/acpi_bus.h   | 19 +++++++++++++++----
 include/linux/acpi.h      |  8 ++------
 include/linux/fwnode.h    | 11 -----------
 include/linux/irqdomain.h |  4 +++-
 include/linux/of.h        |  3 +--
 kernel/irq/irqdomain.c    |  4 +++-
 10 files changed, 57 insertions(+), 48 deletions(-)
drivers/acpi/property.c +28 -19
index 917c789..4d3d897 100644
@@ -56,8 +56,7 @@ static bool acpi_nondev_subnode_extract(const union acpi_object *desc,
 		return false;
 
 	dn->name = link->package.elements[0].string.pointer;
-	dn->fwnode.type = FWNODE_ACPI_DATA;
-	dn->fwnode.ops = &acpi_fwnode_ops;
+	dn->fwnode.ops = &acpi_data_fwnode_ops;
 	dn->parent = parent;
 	INIT_LIST_HEAD(&dn->data.subnodes);
 
@@ -469,10 +468,10 @@ EXPORT_SYMBOL_GPL(acpi_dev_get_property);
 
 static struct acpi_device_data *acpi_device_data_of_node(struct fwnode_handle *fwnode)
 {
-	if (fwnode->type == FWNODE_ACPI) {
+	if (is_acpi_device_node(fwnode)) {
 		struct acpi_device *adev = to_acpi_device_node(fwnode);
 		return &adev->data;
-	} else if (fwnode->type == FWNODE_ACPI_DATA) {
+	} else if (is_acpi_data_node(fwnode)) {
 		struct acpi_data_node *dn = to_acpi_data_node(fwnode);
 		return &dn->data;
 	}
@@ -903,7 +902,7 @@ struct fwnode_handle *acpi_get_next_subnode(struct fwnode_handle *fwnode,
 	struct acpi_device *adev = to_acpi_device_node(fwnode);
 	struct list_head *head, *next;
 
-	if (!child || child->type == FWNODE_ACPI) {
+	if (!child || is_acpi_device_node(child)) {
 		if (adev)
 			head = &adev->children;
 		else
@@ -927,7 +926,7 @@ struct fwnode_handle *acpi_get_next_subnode(struct fwnode_handle *fwnode,
 	}
 
  nondev:
-	if (!child || child->type == FWNODE_ACPI_DATA) {
+	if (!child || is_acpi_data_node(child)) {
 		struct acpi_data_node *data = to_acpi_data_node(fwnode);
 		struct acpi_data_node *dn;
 
@@ -1223,16 +1222,26 @@ static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
 	return 0;
 }
 
-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,
-	.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,
-};
+#define DECLARE_ACPI_FWNODE_OPS(ops) \
+	const struct fwnode_operations 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,		\
+		.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, \
+	};								\
+	EXPORT_SYMBOL_GPL(ops)
+
+DECLARE_ACPI_FWNODE_OPS(acpi_device_fwnode_ops);
+DECLARE_ACPI_FWNODE_OPS(acpi_data_fwnode_ops);
+DECLARE_ACPI_FWNODE_OPS(acpi_static_fwnode_ops);
drivers/acpi/scan.c +1 -2
index fe379a0..53e268b 100644
@@ -1435,8 +1435,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
 	device->device_type = type;
 	device->handle = handle;
 	device->parent = acpi_bus_get_parent(handle);
-	device->fwnode.type = FWNODE_ACPI;
-	device->fwnode.ops = &acpi_fwnode_ops;
+	device->fwnode.ops = &acpi_device_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 +3 -2
index 692007e..09770fc 100644
@@ -25,9 +25,11 @@ struct property_set {
 	const struct property_entry *properties;
 };
 
+static const struct fwnode_operations pset_fwnode_ops;
+
 static inline bool is_pset_node(struct fwnode_handle *fwnode)
 {
-	return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_PDATA;
+	return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &pset_fwnode_ops;
 }
 
 static inline struct property_set *to_pset_node(struct fwnode_handle *fwnode)
@@ -900,7 +902,6 @@ int device_add_properties(struct device *dev,
 	if (IS_ERR(p))
 		return PTR_ERR(p);
 
-	p->fwnode.type = FWNODE_PDATA;
 	p->fwnode.ops = &pset_fwnode_ops;
 	set_secondary_fwnode(dev, &p->fwnode);
 	return 0;
drivers/of/property.c +1 -0
index c96389b..edd629b 100644
@@ -912,3 +912,4 @@ const struct fwnode_operations of_fwnode_ops = {
 	.graph_get_port_parent = of_fwnode_graph_get_port_parent,
 	.graph_parse_endpoint = of_fwnode_graph_parse_endpoint,
 };
+EXPORT_SYMBOL_GPL(of_fwnode_ops);
include/acpi/acpi_bus.h +15 -4
index 197f3ff..e724afc 100644
@@ -394,15 +394,21 @@ struct acpi_data_node {
 	struct completion kobj_done;
 };
 
+extern const struct fwnode_operations acpi_device_fwnode_ops;
+extern const struct fwnode_operations acpi_data_fwnode_ops;
+extern const struct fwnode_operations acpi_static_fwnode_ops;
+
 static inline bool is_acpi_node(struct fwnode_handle *fwnode)
 {
-	return !IS_ERR_OR_NULL(fwnode) && (fwnode->type == FWNODE_ACPI
-		|| fwnode->type == FWNODE_ACPI_DATA);
+	return !IS_ERR_OR_NULL(fwnode) &&
+		(fwnode->ops == &acpi_device_fwnode_ops
+		 || fwnode->ops == &acpi_data_fwnode_ops);
 }
 
 static inline bool is_acpi_device_node(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;
 }
 
 static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
@@ -413,7 +419,12 @@ static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwno
 
 static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
 {
-	return fwnode && fwnode->type == FWNODE_ACPI_DATA;
+	return fwnode && fwnode->ops == &acpi_data_fwnode_ops;
+}
+
+static inline bool is_acpi_static_node(struct fwnode_handle *fwnode)
+{
+	return fwnode && fwnode->ops == &acpi_static_fwnode_ops;
 }
 
 static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
include/linux/acpi.h +2 -6
index b8f23c5..ad19760 100644
@@ -56,9 +56,6 @@ 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;
@@ -67,15 +64,14 @@ static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
 	if (!fwnode)
 		return NULL;
 
-	fwnode->type = FWNODE_ACPI_STATIC;
-	fwnode->ops = &acpi_fwnode_ops;
+	fwnode->ops = &acpi_static_fwnode_ops;
 
 	return fwnode;
 }
 
 static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode)
 {
-	if (WARN_ON(!fwnode || fwnode->type != FWNODE_ACPI_STATIC))
+	if (WARN_ON(!fwnode || !is_acpi_static_node(fwnode)))
 		return;
 
 	kfree(fwnode);
include/linux/fwnode.h +0 -11
index 9ab3754..e7ca4c5 100644
@@ -14,20 +14,9 @@
 
 #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_handle {
-	enum fwnode_type type;
 	struct fwnode_handle *secondary;
 	const struct fwnode_operations *ops;
 };
include/linux/irqdomain.h +3 -1
index 9f36160..ee1910c 100644
@@ -233,9 +233,11 @@ static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node)
 	return node ? &node->fwnode : NULL;
 }
 
+extern const struct fwnode_operations irqchip_fwnode_ops;
+
 static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
 {
-	return fwnode && fwnode->type == FWNODE_IRQCHIP;
+	return fwnode && fwnode->ops == &irqchip_fwnode_ops;
 }
 
 static inline
include/linux/of.h +1 -2
index cdbfa88..6e39aa1 100644
@@ -104,7 +104,6 @@ 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;
 }
 
@@ -152,7 +151,7 @@ void of_core_init(void);
 
 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)						\
kernel/irq/irqdomain.c +3 -1
index 31805f2..e746c42 100644
@@ -31,6 +31,8 @@ struct irqchip_fwid {
 	void *data;
 };
 
+const struct fwnode_operations irqchip_fwnode_ops;
+
 /**
  * irq_domain_alloc_fwnode - Allocate a fwnode_handle suitable for
  *                           identifying an irq domain
@@ -55,7 +57,7 @@ struct fwnode_handle *irq_domain_alloc_fwnode(void *data)
 
 	fwid->name = name;
 	fwid->data = data;
-	fwid->fwnode.type = FWNODE_IRQCHIP;
+	fwid->fwnode.ops = &irqchip_fwnode_ops;
 	return &fwid->fwnode;
 }
 EXPORT_SYMBOL_GPL(irq_domain_alloc_fwnode);
Signature · 1 line
2.7.4
Reviewed-by on v1 7/7
#14 lore raw

Re: [PATCH v7.2 7/7] device property: Get rid of struct fwnode_handle type field

Quoted 9 lines · Sakari Ailus

Instead of relying on the struct fwnode_handle type field, define fwnode_operations structs for all separate types of fwnodes. To find out the type, compare to the ops field to relevant ops structs.

This change has two benefits:

1. it avoids adding the type field to each and every instance of struct fwnode_handle, thus saving memory and

Quoted 7 lines

2. makes the ops field the single factor that defines both the types of the fwnode as well as defines the implementation of its operations, decreasing the possibility of bugs when developing code dealing with fwnode internals.

#15 lore raw

Re: [PATCH v7.2 7/7] device property: Get rid of struct fwnode_handle type field

In reply to Sakari Ailus

On Tue, Jun 20, 2017 at 11:49:56AM +0300, Sakari Ailus wrote:

[...]

Quoted 13 lines
drivers/acpi/property.c +13 -0
+#define DECLARE_ACPI_FWNODE_OPS(ops) \
+	const struct fwnode_operations 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,		\
+		.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,		\

drivers/acpi/property.c static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode, · line 1247

Quoted 10 lines
drivers/acpi/property.c +10 -0
+		.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, \
+	};								\
+	EXPORT_SYMBOL_GPL(ops)
+
+DECLARE_ACPI_FWNODE_OPS(acpi_device_fwnode_ops);
+DECLARE_ACPI_FWNODE_OPS(acpi_data_fwnode_ops);
+DECLARE_ACPI_FWNODE_OPS(acpi_static_fwnode_ops);

I do not think it is a great idea to associate valid fwnode_operations to a static ACPI fwnode (which is just a tag - like the IRQCHIP one).

Thanks,
Lorenzo

Quoted 211 lines
drivers/acpi/scan.c +1 -2
index fe379a0..53e268b 100644
@@ -1435,8 +1435,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
 	device->device_type = type;
 	device->handle = handle;
 	device->parent = acpi_bus_get_parent(handle);
-	device->fwnode.type = FWNODE_ACPI;
-	device->fwnode.ops = &acpi_fwnode_ops;
+	device->fwnode.ops = &acpi_device_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 +3 -2
index 692007e..09770fc 100644
@@ -25,9 +25,11 @@ struct property_set {
 	const struct property_entry *properties;
 };
 
+static const struct fwnode_operations pset_fwnode_ops;
+
 static inline bool is_pset_node(struct fwnode_handle *fwnode)
 {
-	return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_PDATA;
+	return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &pset_fwnode_ops;
 }
 
 static inline struct property_set *to_pset_node(struct fwnode_handle *fwnode)
@@ -900,7 +902,6 @@ int device_add_properties(struct device *dev,
 	if (IS_ERR(p))
 		return PTR_ERR(p);
 
-	p->fwnode.type = FWNODE_PDATA;
 	p->fwnode.ops = &pset_fwnode_ops;
 	set_secondary_fwnode(dev, &p->fwnode);
 	return 0;
drivers/of/property.c +1 -0
index c96389b..edd629b 100644
@@ -912,3 +912,4 @@ const struct fwnode_operations of_fwnode_ops = {
 	.graph_get_port_parent = of_fwnode_graph_get_port_parent,
 	.graph_parse_endpoint = of_fwnode_graph_parse_endpoint,
 };
+EXPORT_SYMBOL_GPL(of_fwnode_ops);
include/acpi/acpi_bus.h +15 -4
index 197f3ff..e724afc 100644
@@ -394,15 +394,21 @@ struct acpi_data_node {
 	struct completion kobj_done;
 };
 
+extern const struct fwnode_operations acpi_device_fwnode_ops;
+extern const struct fwnode_operations acpi_data_fwnode_ops;
+extern const struct fwnode_operations acpi_static_fwnode_ops;
+
 static inline bool is_acpi_node(struct fwnode_handle *fwnode)
 {
-	return !IS_ERR_OR_NULL(fwnode) && (fwnode->type == FWNODE_ACPI
-		|| fwnode->type == FWNODE_ACPI_DATA);
+	return !IS_ERR_OR_NULL(fwnode) &&
+		(fwnode->ops == &acpi_device_fwnode_ops
+		 || fwnode->ops == &acpi_data_fwnode_ops);
 }
 
 static inline bool is_acpi_device_node(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;
 }
 
 static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
@@ -413,7 +419,12 @@ static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwno
 
 static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
 {
-	return fwnode && fwnode->type == FWNODE_ACPI_DATA;
+	return fwnode && fwnode->ops == &acpi_data_fwnode_ops;
+}
+
+static inline bool is_acpi_static_node(struct fwnode_handle *fwnode)
+{
+	return fwnode && fwnode->ops == &acpi_static_fwnode_ops;
 }
 
 static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
include/linux/acpi.h +2 -6
index b8f23c5..ad19760 100644
@@ -56,9 +56,6 @@ 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;
@@ -67,15 +64,14 @@ static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
 	if (!fwnode)
 		return NULL;
 
-	fwnode->type = FWNODE_ACPI_STATIC;
-	fwnode->ops = &acpi_fwnode_ops;
+	fwnode->ops = &acpi_static_fwnode_ops;
 
 	return fwnode;
 }
 
 static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode)
 {
-	if (WARN_ON(!fwnode || fwnode->type != FWNODE_ACPI_STATIC))
+	if (WARN_ON(!fwnode || !is_acpi_static_node(fwnode)))
 		return;
 
 	kfree(fwnode);
include/linux/fwnode.h +0 -11
index 9ab3754..e7ca4c5 100644
@@ -14,20 +14,9 @@
 
 #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_handle {
-	enum fwnode_type type;
 	struct fwnode_handle *secondary;
 	const struct fwnode_operations *ops;
 };
include/linux/irqdomain.h +3 -1
index 9f36160..ee1910c 100644
@@ -233,9 +233,11 @@ static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node)
 	return node ? &node->fwnode : NULL;
 }
 
+extern const struct fwnode_operations irqchip_fwnode_ops;
+
 static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
 {
-	return fwnode && fwnode->type == FWNODE_IRQCHIP;
+	return fwnode && fwnode->ops == &irqchip_fwnode_ops;
 }
 
 static inline
include/linux/of.h +1 -2
index cdbfa88..6e39aa1 100644
@@ -104,7 +104,6 @@ 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;
 }
 
@@ -152,7 +151,7 @@ void of_core_init(void);
 
 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)						\
kernel/irq/irqdomain.c +3 -1
index 31805f2..e746c42 100644
@@ -31,6 +31,8 @@ struct irqchip_fwid {
 	void *data;
 };
 
+const struct fwnode_operations irqchip_fwnode_ops;
+
 /**
  * irq_domain_alloc_fwnode - Allocate a fwnode_handle suitable for
  *                           identifying an irq domain
@@ -55,7 +57,7 @@ struct fwnode_handle *irq_domain_alloc_fwnode(void *data)
 
 	fwid->name = name;
 	fwid->data = data;
-	fwid->fwnode.type = FWNODE_IRQCHIP;
+	fwid->fwnode.ops = &irqchip_fwnode_ops;
 	return &fwid->fwnode;
 }
 EXPORT_SYMBOL_GPL(irq_domain_alloc_fwnode);
Signature · 1 line
2.7.4
#16 lore raw

Re: [PATCH v7.2 7/7] device property: Get rid of struct fwnode_handle type field

Quoted 22 lines · Lorenzo Pieralisi

On Tue, Jun 20, 2017 at 11:49:56AM +0300, Sakari Ailus wrote:

[...]

Quoted 18 lines
drivers/acpi/property.c +18 -0
+#define DECLARE_ACPI_FWNODE_OPS(ops) \
+     const struct fwnode_operations 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,         \
+             .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, \
+     };                                                              \
Quoted 8 lines

drivers/acpi/property.c static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode, · line 1247

Quoted 5 lines
drivers/acpi/property.c +5 -0
+     EXPORT_SYMBOL_GPL(ops)
+
+DECLARE_ACPI_FWNODE_OPS(acpi_device_fwnode_ops);
+DECLARE_ACPI_FWNODE_OPS(acpi_data_fwnode_ops);
+DECLARE_ACPI_FWNODE_OPS(acpi_static_fwnode_ops);

I do not think it is a great idea to associate valid fwnode_operations to a static ACPI fwnode (which is just a tag - like the IRQCHIP one).

Sakari, care to address this comment?

Thanks,
Rafael

#17 lore raw

Re: [PATCH v7.2 7/7] device property: Get rid of struct fwnode_handle type field

In reply to Lorenzo Pieralisi

Hi Lorenzo,

Quoted 22 lines · Lorenzo Pieralisi

On Tue, Jun 20, 2017 at 11:49:56AM +0300, Sakari Ailus wrote:

[...]

Quoted 18 lines
drivers/acpi/property.c +18 -0
+#define DECLARE_ACPI_FWNODE_OPS(ops) \
+	const struct fwnode_operations 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,		\
+		.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, \
+	};								\
Quoted 8 lines

drivers/acpi/property.c static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode, · line 1247

Quoted 5 lines
drivers/acpi/property.c +5 -0
+	EXPORT_SYMBOL_GPL(ops)
+
+DECLARE_ACPI_FWNODE_OPS(acpi_device_fwnode_ops);
+DECLARE_ACPI_FWNODE_OPS(acpi_data_fwnode_ops);
+DECLARE_ACPI_FWNODE_OPS(acpi_static_fwnode_ops);

I do not think it is a great idea to associate valid fwnode_operations to a static ACPI fwnode (which is just a tag - like the IRQCHIP one).

Thanks for the review!

I'll fix that in v8 of the set (by using a struct with all ops being NULL, just as for IRQCHIP).

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]