All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments
@ 2017-07-21 11:39 Sakari Ailus
  2017-07-21 11:39 ` [PATCH v3 2/8] device property: Get rid of struct fwnode_handle type field Sakari Ailus
                   ` (6 more replies)
  0 siblings, 7 replies; 23+ messages in thread
From: Sakari Ailus @ 2017-07-21 11:39 UTC (permalink / raw)
  To: linux-acpi
  Cc: devicetree, sudeep.holla, lorenzo.pieralisi, mika.westerberg,
	rafael, mark.rutland, broonie, robh, ahs3, frowand.list,
	erik.veijola, andriy.shevchenko

Hello everyone,

This set removes the struct fwnode_handle type field and constifies the
fwnode arguments in the fwnode property API more or less the way they are
const in OF property API.

Comments are welcome.

All the dependent patches are now in linux-pm master branch.

<URL:http://www.spinics.net/lists/linux-acpi/msg75957.html>

v1 can be found here:

<URL:http://www.spinics.net/lists/linux-acpi/msg74564.html>

changes since v2:

- Add 8th patch "device property: Introduce
  fwnode_property_get_reference_args". This allows obtaining references
  with integer arguments using the fwnode interface.

  The functionality will be soon needed in adding support for nvmem
  framework on ACPI as well as in referring to e.g. lens and flash devices
  on V4L2.

- Add Rob's ack on "device property: Constify fwnode property API".

changes since v1:

- Rebase and resolve the conflicts. As there is no longer fwnode->type
  field, __irq_domain_add() won't print the wrong type in an error
  message anymore.

- Add patch "device property: Get rid of struct fwnode_handle type field"
  which wasn't merged from set "Move firmware specific code to firmware
  specific locations". Addressed the ACPI static node bug in that patch
  --- static ACPI nodes have NULL ops now, just like the old IRQCHIP type.

- Add patch "ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in
  is_acpi_data_node" which extends the error code checks for ACPI data
  node. s. This is in line with existing is_acpi_node() and
  is_acpi_device_node().

- Dropped the V4L2 patches from the set; they're better suitable to be
  merged through the media tree. (For more patches touching the same areas
  are being worked on.)

- Rename fwnode argument in to_pset_node() macro as __to_pset_node_fwnode
  in order to avoid masking local variables where the macro is used. (The
  compiler won't warn about this. Ouch.)

- Clean up patch "ACPI: Constify acpi_get_next_subnode() fwnode argument"
  by separating the root device node (adev) from the child device node
  (child_adev, which is const). Also rename the patch as "ACPI: Prepare
  for constifying acpi_get_next_subnode() fwnode argument".

- Squash patch "ACPI: Constify acpi_graph_get_child_prop_value() fwnode
  argument" with "device property: Constify fwnode property API". The
  former makes a change which is interdependent with the changes made by
  latter (for const-ness).

Sakari Ailus (8):
  ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in
    is_acpi_data_node
  device property: Get rid of struct fwnode_handle type field
  ACPI: Prepare for constifying acpi_get_next_subnode() fwnode argument
  ACPI: Constify acpi_bus helper functions, switch to macros
  ACPI: Constify internal fwnode arguments
  device property: Constify argument to pset fwnode backend
  device property: Constify fwnode property API
  device property: Introduce fwnode_property_get_reference_args

 drivers/acpi/property.c   | 181 +++++++++++++++++++++++++++++-----------------
 drivers/acpi/scan.c       |   3 +-
 drivers/base/property.c   | 131 +++++++++++++++++++++------------
 drivers/of/property.c     |  66 +++++++++++++----
 include/acpi/acpi_bus.h   |  52 +++++++++----
 include/linux/acpi.h      |  68 ++++++++---------
 include/linux/fwnode.h    |  56 ++++++++------
 include/linux/irqdomain.h |   4 +-
 include/linux/of.h        |   3 +-
 include/linux/property.h  |  67 +++++++++--------
 kernel/irq/irqdomain.c    |  10 +--
 11 files changed, 402 insertions(+), 239 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v3 1/8] ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in is_acpi_data_node
       [not found] ` <1500637177-16095-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2017-07-21 11:39   ` Sakari Ailus
  2017-07-21 11:59     ` Andy Shevchenko
  2017-07-21 11:39   ` [PATCH v3 4/8] ACPI: Constify acpi_bus helper functions, switch to macros Sakari Ailus
  2017-07-21 11:52   ` [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments Rafael J. Wysocki
  2 siblings, 1 reply; 23+ messages in thread
From: Sakari Ailus @ 2017-07-21 11:39 UTC (permalink / raw)
  To: linux-acpi-u79uwXL29TY76Z2rM5mHXA
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, sudeep.holla-5wv7dgnIgG8,
	lorenzo.pieralisi-5wv7dgnIgG8,
	mika.westerberg-VuQAYsv1563Yd54FQh9/CA,
	rafael-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, robh-DgEjT+Ai2ygdnm+yROfE0A,
	ahs3-H+wXaHxf7aLQT0dZR+AlfA, frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	erik.veijola-ral2JQCrhuEAvxtiuMwx3w,
	andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA

The is_acpi_data_node() function takes a struct fwnode_handle pointer as
its argument. The validity of the pointer is first checked. Extend the
check to cover error values as is done by similar is_acpi_node() and
is_acpi_device_node() functions.

Signed-off-by: Sakari Ailus <sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 include/acpi/acpi_bus.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 68bc6be..7569123 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -414,7 +414,7 @@ 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 !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_ACPI_DATA;
 }
 
 static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v3 2/8] device property: Get rid of struct fwnode_handle type field
  2017-07-21 11:39 [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments Sakari Ailus
@ 2017-07-21 11:39 ` Sakari Ailus
  2017-07-21 11:39 ` [PATCH v3 3/8] ACPI: Prepare for constifying acpi_get_next_subnode() fwnode argument Sakari Ailus
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Sakari Ailus @ 2017-07-21 11:39 UTC (permalink / raw)
  To: linux-acpi
  Cc: devicetree, sudeep.holla, lorenzo.pieralisi, mika.westerberg,
	rafael, mark.rutland, broonie, robh, ahs3, frowand.list,
	erik.veijola, andriy.shevchenko

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.

Suggested-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 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   | 20 ++++++++++++++++----
 include/linux/acpi.h      |  8 ++------
 include/linux/fwnode.h    | 11 -----------
 include/linux/irqdomain.h |  4 +++-
 include/linux/of.h        |  3 +--
 kernel/irq/irqdomain.c    | 10 +++++-----
 10 files changed, 60 insertions(+), 52 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 917c789..cb6a3b3 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -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);
+const struct fwnode_operations acpi_static_fwnode_ops;
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 3389729..943536c 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1467,8 +1467,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);
diff --git a/drivers/base/property.c b/drivers/base/property.c
index edf02c1..857e4d3 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -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;
diff --git a/drivers/of/property.c b/drivers/of/property.c
index eda50b4..2d59888 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -952,3 +952,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);
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 7569123..91b1e58 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -395,15 +395,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)
@@ -414,7 +420,7 @@ 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 !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_ACPI_DATA;
+	return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops;
 }
 
 static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
@@ -423,6 +429,12 @@ static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwn
 		container_of(fwnode, struct acpi_data_node, fwnode) : NULL;
 }
 
+static inline bool is_acpi_static_node(struct fwnode_handle *fwnode)
+{
+	return !IS_ERR_OR_NULL(fwnode) &&
+		fwnode->ops == &acpi_static_fwnode_ops;
+}
+
 static inline bool acpi_data_node_match(struct fwnode_handle *fwnode,
 					const char *name)
 {
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index c749eef..71b763f 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -57,9 +57,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;
@@ -68,15 +65,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(!is_acpi_static_node(fwnode)))
 		return;
 
 	kfree(fwnode);
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 50893a1..c5dbc48 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -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;
 };
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index cac77a5..d242738 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -265,9 +265,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;
 }
 
 extern void irq_domain_update_bus_token(struct irq_domain *domain,
diff --git a/include/linux/of.h b/include/linux/of.h
index 4a8a709..cfc3411 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -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)						\
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index f1f2514..e064fd1 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -41,6 +41,8 @@ static inline void debugfs_add_domain_dir(struct irq_domain *d) { }
 static inline void debugfs_remove_domain_dir(struct irq_domain *d) { }
 #endif
 
+const struct fwnode_operations irqchip_fwnode_ops;
+
 /**
  * irq_domain_alloc_fwnode - Allocate a fwnode_handle suitable for
  *                           identifying an irq domain
@@ -86,7 +88,7 @@ struct fwnode_handle *__irq_domain_alloc_fwnode(unsigned int type, int id,
 	fwid->type = type;
 	fwid->name = n;
 	fwid->data = data;
-	fwid->fwnode.type = FWNODE_IRQCHIP;
+	fwid->fwnode.ops = &irqchip_fwnode_ops;
 	return &fwid->fwnode;
 }
 EXPORT_SYMBOL_GPL(__irq_domain_alloc_fwnode);
@@ -193,10 +195,8 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
 	}
 
 	if (!domain->name) {
-		if (fwnode) {
-			pr_err("Invalid fwnode type (%d) for irqdomain\n",
-			       fwnode->type);
-		}
+		if (fwnode)
+			pr_err("Invalid fwnode type for irqdomain\n");
 		domain->name = kasprintf(GFP_KERNEL, "unknown-%d",
 					 atomic_inc_return(&unknown_domains));
 		if (!domain->name) {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v3 3/8] ACPI: Prepare for constifying acpi_get_next_subnode() fwnode argument
  2017-07-21 11:39 [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments Sakari Ailus
  2017-07-21 11:39 ` [PATCH v3 2/8] device property: Get rid of struct fwnode_handle type field Sakari Ailus
@ 2017-07-21 11:39 ` Sakari Ailus
  2017-07-21 12:30   ` Andy Shevchenko
       [not found] ` <1500637177-16095-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Sakari Ailus @ 2017-07-21 11:39 UTC (permalink / raw)
  To: linux-acpi
  Cc: devicetree, sudeep.holla, lorenzo.pieralisi, mika.westerberg,
	rafael, mark.rutland, broonie, robh, ahs3, frowand.list,
	erik.veijola, andriy.shevchenko

Make local variables const (head) or add new variables; adev was used for
two purposes: to refer the root device node and its children. The two
purposes are separated by this patch.

This is preparation for making fwnode arguments const for fwnode ops.
Don't constify the argument itself quite yet as this is used as a callback
function.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/acpi/property.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index cb6a3b3..04c60a2 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -899,8 +899,10 @@ int acpi_node_prop_read(struct fwnode_handle *fwnode,  const char *propname,
 struct fwnode_handle *acpi_get_next_subnode(struct fwnode_handle *fwnode,
 					    struct fwnode_handle *child)
 {
-	struct acpi_device *adev = to_acpi_device_node(fwnode);
-	struct list_head *head, *next;
+	const struct acpi_device *adev = to_acpi_device_node(fwnode);
+	struct acpi_device *child_adev = NULL;
+	const struct list_head *head;
+	struct list_head *next;
 
 	if (!child || is_acpi_device_node(child)) {
 		if (adev)
@@ -912,26 +914,27 @@ struct fwnode_handle *acpi_get_next_subnode(struct fwnode_handle *fwnode,
 			goto nondev;
 
 		if (child) {
-			adev = to_acpi_device_node(child);
-			next = adev->node.next;
+			child_adev = to_acpi_device_node(child);
+			next = child_adev->node.next;
 			if (next == head) {
 				child = NULL;
 				goto nondev;
 			}
-			adev = list_entry(next, struct acpi_device, node);
+			child_adev = list_entry(next, struct acpi_device, node);
 		} else {
-			adev = list_first_entry(head, struct acpi_device, node);
+			child_adev = list_first_entry(head, struct acpi_device,
+						      node);
 		}
-		return acpi_fwnode_handle(adev);
+		return acpi_fwnode_handle(child_adev);
 	}
 
  nondev:
 	if (!child || is_acpi_data_node(child)) {
-		struct acpi_data_node *data = to_acpi_data_node(fwnode);
+		const struct acpi_data_node *data = to_acpi_data_node(fwnode);
 		struct acpi_data_node *dn;
 
-		if (adev)
-			head = &adev->data.subnodes;
+		if (child_adev)
+			head = &child_adev->data.subnodes;
 		else if (data)
 			head = &data->data.subnodes;
 		else
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v3 4/8] ACPI: Constify acpi_bus helper functions, switch to macros
       [not found] ` <1500637177-16095-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  2017-07-21 11:39   ` [PATCH v3 1/8] ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in is_acpi_data_node Sakari Ailus
@ 2017-07-21 11:39   ` Sakari Ailus
  2017-07-21 11:52   ` [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments Rafael J. Wysocki
  2 siblings, 0 replies; 23+ messages in thread
From: Sakari Ailus @ 2017-07-21 11:39 UTC (permalink / raw)
  To: linux-acpi-u79uwXL29TY76Z2rM5mHXA
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, sudeep.holla-5wv7dgnIgG8,
	lorenzo.pieralisi-5wv7dgnIgG8,
	mika.westerberg-VuQAYsv1563Yd54FQh9/CA,
	rafael-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, robh-DgEjT+Ai2ygdnm+yROfE0A,
	ahs3-H+wXaHxf7aLQT0dZR+AlfA, frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	erik.veijola-ral2JQCrhuEAvxtiuMwx3w,
	andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA

Constify arguments to is_acpi_node(), is_acpi_device_node(),
is_acpi_static_node() and acpi_data_node_match(). Make
to_acpi_device_node() and to_acpi_data_node() macros that can cope with
const and non-const arguments.

Signed-off-by: Sakari Ailus <sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 include/acpi/acpi_bus.h | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 91b1e58..89bc213 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -399,43 +399,51 @@ 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)
+static inline bool is_acpi_node(const struct fwnode_handle *fwnode)
 {
 	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)
+static inline bool is_acpi_device_node(const struct fwnode_handle *fwnode)
 {
 	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)
-{
-	return is_acpi_device_node(fwnode) ?
-		container_of(fwnode, struct acpi_device, fwnode) : NULL;
-}
-
-static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
+#define to_acpi_device_node(__fwnode)					\
+	({								\
+		typeof(__fwnode) __to_acpi_device_node_fwnode = __fwnode; \
+									\
+		is_acpi_device_node(__to_acpi_device_node_fwnode) ?	\
+			container_of(__to_acpi_device_node_fwnode,	\
+				     struct acpi_device, fwnode) :	\
+			NULL;						\
+	})
+
+static inline bool is_acpi_data_node(const struct fwnode_handle *fwnode)
 {
 	return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops;
 }
 
-static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
-{
-	return is_acpi_data_node(fwnode) ?
-		container_of(fwnode, struct acpi_data_node, fwnode) : NULL;
-}
-
-static inline bool is_acpi_static_node(struct fwnode_handle *fwnode)
+#define to_acpi_data_node(__fwnode)					\
+	({								\
+		typeof(__fwnode) __to_acpi_data_node_fwnode = __fwnode;	\
+									\
+		is_acpi_data_node(__to_acpi_data_node_fwnode) ?		\
+			container_of(__to_acpi_data_node_fwnode,	\
+				     struct acpi_data_node, fwnode) :	\
+			NULL;						\
+	})
+
+static inline bool is_acpi_static_node(const struct fwnode_handle *fwnode)
 {
 	return !IS_ERR_OR_NULL(fwnode) &&
 		fwnode->ops == &acpi_static_fwnode_ops;
 }
 
-static inline bool acpi_data_node_match(struct fwnode_handle *fwnode,
+static inline bool acpi_data_node_match(const struct fwnode_handle *fwnode,
 					const char *name)
 {
 	return is_acpi_data_node(fwnode) ?
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v3 5/8] ACPI: Constify internal fwnode arguments
  2017-07-21 11:39 [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments Sakari Ailus
                   ` (2 preceding siblings ...)
       [not found] ` <1500637177-16095-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2017-07-21 11:39 ` Sakari Ailus
  2017-07-21 11:39 ` [PATCH v3 6/8] device property: Constify argument to pset fwnode backend Sakari Ailus
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Sakari Ailus @ 2017-07-21 11:39 UTC (permalink / raw)
  To: linux-acpi
  Cc: devicetree, sudeep.holla, lorenzo.pieralisi, mika.westerberg,
	rafael, mark.rutland, broonie, robh, ahs3, frowand.list,
	erik.veijola, andriy.shevchenko

Constify internal ACPI fwnode arguments in preparation for the same in
fwnode API.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/acpi/property.c | 34 ++++++++++++++++++----------------
 include/linux/acpi.h    | 40 ++++++++++++++++++++++------------------
 2 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 04c60a2..043bfca 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -19,7 +19,7 @@
 
 #include "internal.h"
 
-static int acpi_data_get_property_array(struct acpi_device_data *data,
+static int acpi_data_get_property_array(const struct acpi_device_data *data,
 					const char *name,
 					acpi_object_type type,
 					const union acpi_object **obj);
@@ -417,7 +417,7 @@ void acpi_free_properties(struct acpi_device *adev)
  *         %-EINVAL if the property doesn't exist,
  *         %-EPROTO if the property value type doesn't match @type.
  */
-static int acpi_data_get_property(struct acpi_device_data *data,
+static int acpi_data_get_property(const struct acpi_device_data *data,
 				  const char *name, acpi_object_type type,
 				  const union acpi_object **obj)
 {
@@ -459,20 +459,21 @@ static int acpi_data_get_property(struct acpi_device_data *data,
  * @type: Expected property type.
  * @obj: Location to store the property value (if not %NULL).
  */
-int acpi_dev_get_property(struct acpi_device *adev, const char *name,
+int acpi_dev_get_property(const struct acpi_device *adev, const char *name,
 			  acpi_object_type type, const union acpi_object **obj)
 {
 	return adev ? acpi_data_get_property(&adev->data, name, type, obj) : -EINVAL;
 }
 EXPORT_SYMBOL_GPL(acpi_dev_get_property);
 
-static struct acpi_device_data *acpi_device_data_of_node(struct fwnode_handle *fwnode)
+static const struct acpi_device_data *
+acpi_device_data_of_node(const struct fwnode_handle *fwnode)
 {
 	if (is_acpi_device_node(fwnode)) {
-		struct acpi_device *adev = to_acpi_device_node(fwnode);
+		const struct acpi_device *adev = to_acpi_device_node(fwnode);
 		return &adev->data;
 	} else if (is_acpi_data_node(fwnode)) {
-		struct acpi_data_node *dn = to_acpi_data_node(fwnode);
+		const struct acpi_data_node *dn = to_acpi_data_node(fwnode);
 		return &dn->data;
 	}
 	return NULL;
@@ -484,8 +485,8 @@ static struct acpi_device_data *acpi_device_data_of_node(struct fwnode_handle *f
  * @propname: Name of the property.
  * @valptr: Location to store a pointer to the property value (if not %NULL).
  */
-int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname,
-		       void **valptr)
+int acpi_node_prop_get(const struct fwnode_handle *fwnode,
+		       const char *propname, void **valptr)
 {
 	return acpi_data_get_property(acpi_device_data_of_node(fwnode),
 				      propname, ACPI_TYPE_ANY,
@@ -511,7 +512,7 @@ int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname,
  *         %-EPROTO if the property is not a package or the type of its elements
  *           doesn't match @type.
  */
-static int acpi_data_get_property_array(struct acpi_device_data *data,
+static int acpi_data_get_property_array(const struct acpi_device_data *data,
 					const char *name,
 					acpi_object_type type,
 					const union acpi_object **obj)
@@ -571,13 +572,13 @@ static int acpi_data_get_property_array(struct acpi_device_data *data,
  *
  * Return: %0 on success, negative error code on failure.
  */
-int __acpi_node_get_property_reference(struct fwnode_handle *fwnode,
+int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 	const char *propname, size_t index, size_t num_args,
 	struct acpi_reference_args *args)
 {
 	const union acpi_object *element, *end;
 	const union acpi_object *obj;
-	struct acpi_device_data *data;
+	const struct acpi_device_data *data;
 	struct acpi_device *device;
 	int ret, idx = 0;
 
@@ -673,7 +674,7 @@ int __acpi_node_get_property_reference(struct fwnode_handle *fwnode,
 }
 EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference);
 
-static int acpi_data_prop_read_single(struct acpi_device_data *data,
+static int acpi_data_prop_read_single(const struct acpi_device_data *data,
 				      const char *propname,
 				      enum dev_prop_type proptype, void *val)
 {
@@ -812,7 +813,7 @@ static int acpi_copy_property_array_string(const union acpi_object *items,
 	return nval;
 }
 
-static int acpi_data_prop_read(struct acpi_device_data *data,
+static int acpi_data_prop_read(const struct acpi_device_data *data,
 			       const char *propname,
 			       enum dev_prop_type proptype,
 			       void *val, size_t nval)
@@ -866,7 +867,7 @@ static int acpi_data_prop_read(struct acpi_device_data *data,
 	return ret;
 }
 
-int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
+int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname,
 		       enum dev_prop_type proptype, void *val, size_t nval)
 {
 	return adev ? acpi_data_prop_read(&adev->data, propname, proptype, val, nval) : -EINVAL;
@@ -884,8 +885,9 @@ int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
  * of the property.  Otherwise, read at most @nval values to the array at the
  * location pointed to by @val.
  */
-int acpi_node_prop_read(struct fwnode_handle *fwnode,  const char *propname,
-		        enum dev_prop_type proptype, void *val, size_t nval)
+int acpi_node_prop_read(const struct fwnode_handle *fwnode,
+			const char *propname, enum dev_prop_type proptype,
+			void *val, size_t nval)
 {
 	return acpi_data_prop_read(acpi_device_data_of_node(fwnode),
 				   propname, proptype, val, nval);
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 71b763f..4d9fb61 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1003,13 +1003,14 @@ struct acpi_reference_args {
 };
 
 #ifdef CONFIG_ACPI
-int acpi_dev_get_property(struct acpi_device *adev, const char *name,
+int acpi_dev_get_property(const struct acpi_device *adev, const char *name,
 			  acpi_object_type type, const union acpi_object **obj);
-int __acpi_node_get_property_reference(struct fwnode_handle *fwnode,
+int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 				const char *name, size_t index, size_t num_args,
 				struct acpi_reference_args *args);
 
-static inline int acpi_node_get_property_reference(struct fwnode_handle *fwnode,
+static inline int acpi_node_get_property_reference(
+				const struct fwnode_handle *fwnode,
 				const char *name, size_t index,
 				struct acpi_reference_args *args)
 {
@@ -1017,13 +1018,15 @@ static inline int acpi_node_get_property_reference(struct fwnode_handle *fwnode,
 		MAX_ACPI_REFERENCE_ARGS, args);
 }
 
-int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname,
+int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
 		       void **valptr);
-int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
-			      enum dev_prop_type proptype, void *val);
-int acpi_node_prop_read(struct fwnode_handle *fwnode, const char *propname,
-		        enum dev_prop_type proptype, void *val, size_t nval);
-int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
+int acpi_dev_prop_read_single(struct acpi_device *adev,
+			      const char *propname, enum dev_prop_type proptype,
+			      void *val);
+int acpi_node_prop_read(const struct fwnode_handle *fwnode,
+			const char *propname, enum dev_prop_type proptype,
+			void *val, size_t nval);
+int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname,
 		       enum dev_prop_type proptype, void *val, size_t nval);
 
 struct fwnode_handle *acpi_get_next_subnode(struct fwnode_handle *fwnode,
@@ -1100,35 +1103,36 @@ static inline int acpi_dev_get_property(struct acpi_device *adev,
 }
 
 static inline int
-__acpi_node_get_property_reference(struct fwnode_handle *fwnode,
+__acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 				const char *name, size_t index, size_t num_args,
 				struct acpi_reference_args *args)
 {
 	return -ENXIO;
 }
 
-static inline int acpi_node_get_property_reference(struct fwnode_handle *fwnode,
-				const char *name, size_t index,
-				struct acpi_reference_args *args)
+static inline int
+acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
+				 const char *name, size_t index,
+				 struct acpi_reference_args *args)
 {
 	return -ENXIO;
 }
 
-static inline int acpi_node_prop_get(struct fwnode_handle *fwnode,
+static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,
 				     const char *propname,
 				     void **valptr)
 {
 	return -ENXIO;
 }
 
-static inline int acpi_dev_prop_get(struct acpi_device *adev,
+static inline int acpi_dev_prop_get(const struct acpi_device *adev,
 				    const char *propname,
 				    void **valptr)
 {
 	return -ENXIO;
 }
 
-static inline int acpi_dev_prop_read_single(struct acpi_device *adev,
+static inline int acpi_dev_prop_read_single(const struct acpi_device *adev,
 					    const char *propname,
 					    enum dev_prop_type proptype,
 					    void *val)
@@ -1136,7 +1140,7 @@ static inline int acpi_dev_prop_read_single(struct acpi_device *adev,
 	return -ENXIO;
 }
 
-static inline int acpi_node_prop_read(struct fwnode_handle *fwnode,
+static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode,
 				      const char *propname,
 				      enum dev_prop_type proptype,
 				      void *val, size_t nval)
@@ -1144,7 +1148,7 @@ static inline int acpi_node_prop_read(struct fwnode_handle *fwnode,
 	return -ENXIO;
 }
 
-static inline int acpi_dev_prop_read(struct acpi_device *adev,
+static inline int acpi_dev_prop_read(const struct acpi_device *adev,
 				     const char *propname,
 				     enum dev_prop_type proptype,
 				     void *val, size_t nval)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v3 6/8] device property: Constify argument to pset fwnode backend
  2017-07-21 11:39 [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments Sakari Ailus
                   ` (3 preceding siblings ...)
  2017-07-21 11:39 ` [PATCH v3 5/8] ACPI: Constify internal " Sakari Ailus
@ 2017-07-21 11:39 ` Sakari Ailus
  2017-07-21 11:39 ` [PATCH v3 7/8] device property: Constify fwnode property API Sakari Ailus
  2017-07-21 11:39 ` [PATCH v3 8/8] device property: Introduce fwnode_property_get_reference_args Sakari Ailus
  6 siblings, 0 replies; 23+ messages in thread
From: Sakari Ailus @ 2017-07-21 11:39 UTC (permalink / raw)
  To: linux-acpi
  Cc: devicetree, sudeep.holla, lorenzo.pieralisi, mika.westerberg,
	rafael, mark.rutland, broonie, robh, ahs3, frowand.list,
	erik.veijola, andriy.shevchenko

Internally constify pset fwnode backend. Do not touch the pset fwnode
operations yet.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/base/property.c | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 857e4d3..8fde824 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -27,19 +27,23 @@ struct property_set {
 
 static const struct fwnode_operations pset_fwnode_ops;
 
-static inline bool is_pset_node(struct fwnode_handle *fwnode)
+static inline bool is_pset_node(const struct fwnode_handle *fwnode)
 {
 	return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &pset_fwnode_ops;
 }
 
-static inline struct property_set *to_pset_node(struct fwnode_handle *fwnode)
-{
-	return is_pset_node(fwnode) ?
-		container_of(fwnode, struct property_set, fwnode) : NULL;
-}
-
-static const struct property_entry *pset_prop_get(struct property_set *pset,
-						  const char *name)
+#define to_pset_node(__fwnode)						\
+	({								\
+		typeof(__fwnode) __to_pset_node_fwnode = __fwnode;	\
+									\
+		is_pset_node(__to_pset_node_fwnode) ?			\
+			container_of(__to_pset_node_fwnode,		\
+				     struct property_set, fwnode) :	\
+			NULL;						\
+	})
+
+static const struct property_entry *
+pset_prop_get(const struct property_set *pset, const char *name)
 {
 	const struct property_entry *prop;
 
@@ -53,7 +57,7 @@ static const struct property_entry *pset_prop_get(struct property_set *pset,
 	return NULL;
 }
 
-static const void *pset_prop_find(struct property_set *pset,
+static const void *pset_prop_find(const struct property_set *pset,
 				  const char *propname, size_t length)
 {
 	const struct property_entry *prop;
@@ -73,7 +77,7 @@ static const void *pset_prop_find(struct property_set *pset,
 	return pointer;
 }
 
-static int pset_prop_read_u8_array(struct property_set *pset,
+static int pset_prop_read_u8_array(const struct property_set *pset,
 				   const char *propname,
 				   u8 *values, size_t nval)
 {
@@ -88,7 +92,7 @@ static int pset_prop_read_u8_array(struct property_set *pset,
 	return 0;
 }
 
-static int pset_prop_read_u16_array(struct property_set *pset,
+static int pset_prop_read_u16_array(const struct property_set *pset,
 				    const char *propname,
 				    u16 *values, size_t nval)
 {
@@ -103,7 +107,7 @@ static int pset_prop_read_u16_array(struct property_set *pset,
 	return 0;
 }
 
-static int pset_prop_read_u32_array(struct property_set *pset,
+static int pset_prop_read_u32_array(const struct property_set *pset,
 				    const char *propname,
 				    u32 *values, size_t nval)
 {
@@ -118,7 +122,7 @@ static int pset_prop_read_u32_array(struct property_set *pset,
 	return 0;
 }
 
-static int pset_prop_read_u64_array(struct property_set *pset,
+static int pset_prop_read_u64_array(const struct property_set *pset,
 				    const char *propname,
 				    u64 *values, size_t nval)
 {
@@ -133,7 +137,7 @@ static int pset_prop_read_u64_array(struct property_set *pset,
 	return 0;
 }
 
-static int pset_prop_count_elems_of_size(struct property_set *pset,
+static int pset_prop_count_elems_of_size(const struct property_set *pset,
 					 const char *propname, size_t length)
 {
 	const struct property_entry *prop;
@@ -145,7 +149,7 @@ static int pset_prop_count_elems_of_size(struct property_set *pset,
 	return prop->length / length;
 }
 
-static int pset_prop_read_string_array(struct property_set *pset,
+static int pset_prop_read_string_array(const struct property_set *pset,
 				       const char *propname,
 				       const char **strings, size_t nval)
 {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v3 7/8] device property: Constify fwnode property API
  2017-07-21 11:39 [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments Sakari Ailus
                   ` (4 preceding siblings ...)
  2017-07-21 11:39 ` [PATCH v3 6/8] device property: Constify argument to pset fwnode backend Sakari Ailus
@ 2017-07-21 11:39 ` Sakari Ailus
  2017-07-21 11:39 ` [PATCH v3 8/8] device property: Introduce fwnode_property_get_reference_args Sakari Ailus
  6 siblings, 0 replies; 23+ messages in thread
From: Sakari Ailus @ 2017-07-21 11:39 UTC (permalink / raw)
  To: linux-acpi
  Cc: devicetree, sudeep.holla, lorenzo.pieralisi, mika.westerberg,
	rafael, mark.rutland, broonie, robh, ahs3, frowand.list,
	erik.veijola, andriy.shevchenko

Make fwnode arguments to the fwnode property API const.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
 drivers/acpi/property.c  | 52 +++++++++++++++++++++++----------------
 drivers/base/property.c  | 64 ++++++++++++++++++++++++++----------------------
 drivers/of/property.c    | 34 +++++++++++++------------
 include/linux/acpi.h     | 20 ++++++++-------
 include/linux/fwnode.h   | 26 +++++++++++---------
 include/linux/property.h | 63 ++++++++++++++++++++++++-----------------------
 6 files changed, 142 insertions(+), 117 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 043bfca..f8d6005 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -898,7 +898,7 @@ int acpi_node_prop_read(const struct fwnode_handle *fwnode,
  * @fwnode: Firmware node to find the next child node for.
  * @child: Handle to one of the device's child nodes or a null handle.
  */
-struct fwnode_handle *acpi_get_next_subnode(struct fwnode_handle *fwnode,
+struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
 					    struct fwnode_handle *child)
 {
 	const struct acpi_device *adev = to_acpi_device_node(fwnode);
@@ -967,7 +967,7 @@ struct fwnode_handle *acpi_get_next_subnode(struct fwnode_handle *fwnode,
  * Returns parent node of an ACPI device or data firmware node or %NULL if
  * not available.
  */
-struct fwnode_handle *acpi_node_get_parent(struct fwnode_handle *fwnode)
+struct fwnode_handle *acpi_node_get_parent(const struct fwnode_handle *fwnode)
 {
 	if (is_acpi_data_node(fwnode)) {
 		/* All data nodes have parent pointer so just return that */
@@ -996,8 +996,8 @@ struct fwnode_handle *acpi_node_get_parent(struct fwnode_handle *fwnode)
  * %NULL if there is no next endpoint, ERR_PTR() in case of error. In case
  * of success the next endpoint is returned.
  */
-struct fwnode_handle *acpi_graph_get_next_endpoint(struct fwnode_handle *fwnode,
-						   struct fwnode_handle *prev)
+struct fwnode_handle *acpi_graph_get_next_endpoint(
+	const struct fwnode_handle *fwnode, struct fwnode_handle *prev)
 {
 	struct fwnode_handle *port = NULL;
 	struct fwnode_handle *endpoint;
@@ -1044,7 +1044,8 @@ struct fwnode_handle *acpi_graph_get_next_endpoint(struct fwnode_handle *fwnode,
  * the child node on success, NULL otherwise.
  */
 static struct fwnode_handle *acpi_graph_get_child_prop_value(
-	struct fwnode_handle *fwnode, const char *prop_name, unsigned int val)
+	const struct fwnode_handle *fwnode, const char *prop_name,
+	unsigned int val)
 {
 	struct fwnode_handle *child;
 
@@ -1073,17 +1074,18 @@ static struct fwnode_handle *acpi_graph_get_child_prop_value(
  * fields requested by the caller. Returns %0 in case of success and
  * negative errno otherwise.
  */
-int acpi_graph_get_remote_endpoint(struct fwnode_handle *fwnode,
+int acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode,
 				   struct fwnode_handle **parent,
 				   struct fwnode_handle **port,
 				   struct fwnode_handle **endpoint)
 {
+	struct fwnode_handle *fwnode;
 	unsigned int port_nr, endpoint_nr;
 	struct acpi_reference_args args;
 	int ret;
 
 	memset(&args, 0, sizeof(args));
-	ret = acpi_node_get_property_reference(fwnode, "remote-endpoint", 0,
+	ret = acpi_node_get_property_reference(__fwnode, "remote-endpoint", 0,
 					       &args);
 	if (ret)
 		return ret;
@@ -1125,7 +1127,7 @@ int acpi_graph_get_remote_endpoint(struct fwnode_handle *fwnode,
 	return 0;
 }
 
-static bool acpi_fwnode_device_is_available(struct fwnode_handle *fwnode)
+static bool acpi_fwnode_device_is_available(const struct fwnode_handle *fwnode)
 {
 	if (!is_acpi_device_node(fwnode))
 		return false;
@@ -1133,16 +1135,17 @@ static bool acpi_fwnode_device_is_available(struct fwnode_handle *fwnode)
 	return acpi_device_is_present(to_acpi_device_node(fwnode));
 }
 
-static bool acpi_fwnode_property_present(struct fwnode_handle *fwnode,
+static bool acpi_fwnode_property_present(const 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)
+static int
+acpi_fwnode_property_read_int_array(const struct fwnode_handle *fwnode,
+				    const char *propname,
+				    unsigned int elem_size, void *val,
+				    size_t nval)
 {
 	enum dev_prop_type type;
 
@@ -1166,16 +1169,17 @@ static int acpi_fwnode_property_read_int_array(struct fwnode_handle *fwnode,
 	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)
+static int
+acpi_fwnode_property_read_string_array(const 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,
+acpi_fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
 				 const char *childname)
 {
 	struct fwnode_handle *child;
@@ -1192,7 +1196,7 @@ acpi_fwnode_get_named_child_node(struct fwnode_handle *fwnode,
 }
 
 static struct fwnode_handle *
-acpi_fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
+acpi_fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
 				    struct fwnode_handle *prev)
 {
 	struct fwnode_handle *endpoint;
@@ -1205,7 +1209,7 @@ acpi_fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
 }
 
 static struct fwnode_handle *
-acpi_fwnode_graph_get_remote_endpoint(struct fwnode_handle *fwnode)
+acpi_fwnode_graph_get_remote_endpoint(const struct fwnode_handle *fwnode)
 {
 	struct fwnode_handle *endpoint = NULL;
 
@@ -1214,7 +1218,13 @@ acpi_fwnode_graph_get_remote_endpoint(struct fwnode_handle *fwnode)
 	return endpoint;
 }
 
-static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
+static struct fwnode_handle *
+acpi_fwnode_get_parent(struct fwnode_handle *fwnode)
+{
+	return acpi_node_get_parent(fwnode);
+}
+
+static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
 					    struct fwnode_endpoint *endpoint)
 {
 	struct fwnode_handle *port_fwnode = fwnode_get_parent(fwnode);
@@ -1242,7 +1252,7 @@ static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
 			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_get_port_parent = acpi_fwnode_get_parent,	\
 		.graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, \
 	};								\
 	EXPORT_SYMBOL_GPL(ops)
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 8fde824..673e235 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -193,18 +193,18 @@ struct fwnode_handle *dev_fwnode(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(dev_fwnode);
 
-static bool pset_fwnode_property_present(struct fwnode_handle *fwnode,
+static bool pset_fwnode_property_present(const struct fwnode_handle *fwnode,
 					 const char *propname)
 {
 	return !!pset_prop_get(to_pset_node(fwnode), propname);
 }
 
-static int pset_fwnode_read_int_array(struct fwnode_handle *fwnode,
+static int pset_fwnode_read_int_array(const struct fwnode_handle *fwnode,
 				      const char *propname,
 				      unsigned int elem_size, void *val,
 				      size_t nval)
 {
-	struct property_set *node = to_pset_node(fwnode);
+	const struct property_set *node = to_pset_node(fwnode);
 
 	if (!val)
 		return pset_prop_count_elems_of_size(node, propname, elem_size);
@@ -223,9 +223,10 @@ static int pset_fwnode_read_int_array(struct fwnode_handle *fwnode,
 	return -ENXIO;
 }
 
-static int pset_fwnode_property_read_string_array(struct fwnode_handle *fwnode,
-						  const char *propname,
-						  const char **val, size_t nval)
+static int
+pset_fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
+				       const char *propname,
+				       const char **val, size_t nval)
 {
 	return pset_prop_read_string_array(to_pset_node(fwnode), propname,
 					   val, nval);
@@ -255,7 +256,8 @@ EXPORT_SYMBOL_GPL(device_property_present);
  * @fwnode: Firmware node whose property to check
  * @propname: Name of the property
  */
-bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
+bool fwnode_property_present(const struct fwnode_handle *fwnode,
+			     const char *propname)
 {
 	bool ret;
 
@@ -437,7 +439,7 @@ int device_property_match_string(struct device *dev, const char *propname,
 }
 EXPORT_SYMBOL_GPL(device_property_match_string);
 
-static int fwnode_property_read_int_array(struct fwnode_handle *fwnode,
+static int fwnode_property_read_int_array(const struct fwnode_handle *fwnode,
 					  const char *propname,
 					  unsigned int elem_size, void *val,
 					  size_t nval)
@@ -473,7 +475,7 @@ static int fwnode_property_read_int_array(struct fwnode_handle *fwnode,
  *	   %-EOVERFLOW if the size of the property is not as expected,
  *	   %-ENXIO if no suitable firmware interface is present.
  */
-int fwnode_property_read_u8_array(struct fwnode_handle *fwnode,
+int fwnode_property_read_u8_array(const struct fwnode_handle *fwnode,
 				  const char *propname, u8 *val, size_t nval)
 {
 	return fwnode_property_read_int_array(fwnode, propname, sizeof(u8),
@@ -499,7 +501,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u8_array);
  *	   %-EOVERFLOW if the size of the property is not as expected,
  *	   %-ENXIO if no suitable firmware interface is present.
  */
-int fwnode_property_read_u16_array(struct fwnode_handle *fwnode,
+int fwnode_property_read_u16_array(const struct fwnode_handle *fwnode,
 				   const char *propname, u16 *val, size_t nval)
 {
 	return fwnode_property_read_int_array(fwnode, propname, sizeof(u16),
@@ -525,7 +527,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u16_array);
  *	   %-EOVERFLOW if the size of the property is not as expected,
  *	   %-ENXIO if no suitable firmware interface is present.
  */
-int fwnode_property_read_u32_array(struct fwnode_handle *fwnode,
+int fwnode_property_read_u32_array(const struct fwnode_handle *fwnode,
 				   const char *propname, u32 *val, size_t nval)
 {
 	return fwnode_property_read_int_array(fwnode, propname, sizeof(u32),
@@ -551,7 +553,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u32_array);
  *	   %-EOVERFLOW if the size of the property is not as expected,
  *	   %-ENXIO if no suitable firmware interface is present.
  */
-int fwnode_property_read_u64_array(struct fwnode_handle *fwnode,
+int fwnode_property_read_u64_array(const struct fwnode_handle *fwnode,
 				   const char *propname, u64 *val, size_t nval)
 {
 	return fwnode_property_read_int_array(fwnode, propname, sizeof(u64),
@@ -577,7 +579,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u64_array);
  *	   %-EOVERFLOW if the size of the property is not as expected,
  *	   %-ENXIO if no suitable firmware interface is present.
  */
-int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
+int fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
 				      const char *propname, const char **val,
 				      size_t nval)
 {
@@ -609,7 +611,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_string_array);
  *	   %-EPROTO or %-EILSEQ if the property is not a string,
  *	   %-ENXIO if no suitable firmware interface is present.
  */
-int fwnode_property_read_string(struct fwnode_handle *fwnode,
+int fwnode_property_read_string(const struct fwnode_handle *fwnode,
 				const char *propname, const char **val)
 {
 	int ret = fwnode_property_read_string_array(fwnode, propname, val, 1);
@@ -633,7 +635,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_string);
  *	   %-EPROTO if the property is not an array of strings,
  *	   %-ENXIO if no suitable firmware interface is present.
  */
-int fwnode_property_match_string(struct fwnode_handle *fwnode,
+int fwnode_property_match_string(const struct fwnode_handle *fwnode,
 	const char *propname, const char *string)
 {
 	const char **values;
@@ -940,7 +942,7 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_parent);
  * Return parent firmware node of the given node if possible or %NULL if no
  * parent was available.
  */
-struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode)
+struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode)
 {
 	return fwnode_call_ptr_op(fwnode, get_parent);
 }
@@ -951,8 +953,9 @@ EXPORT_SYMBOL_GPL(fwnode_get_parent);
  * @fwnode: Firmware node to find the next child node for.
  * @child: Handle to one of the node's child nodes or a %NULL handle.
  */
-struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *fwnode,
-						 struct fwnode_handle *child)
+struct fwnode_handle *
+fwnode_get_next_child_node(const struct fwnode_handle *fwnode,
+			   struct fwnode_handle *child)
 {
 	return fwnode_call_ptr_op(fwnode, get_next_child_node, child);
 }
@@ -983,8 +986,9 @@ EXPORT_SYMBOL_GPL(device_get_next_child_node);
  * @fwnode: Firmware node to find the named child node for.
  * @childname: String to match child node name against.
  */
-struct fwnode_handle *fwnode_get_named_child_node(struct fwnode_handle *fwnode,
-						  const char *childname)
+struct fwnode_handle *
+fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
+			    const char *childname)
 {
 	return fwnode_call_ptr_op(fwnode, get_named_child_node, childname);
 }
@@ -1030,7 +1034,7 @@ 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)
+bool fwnode_device_is_available(const struct fwnode_handle *fwnode)
 {
 	return fwnode_call_bool_op(fwnode, device_is_available);
 }
@@ -1168,7 +1172,7 @@ EXPORT_SYMBOL(device_get_mac_address);
  * are available.
  */
 struct fwnode_handle *
-fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
+fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
 			       struct fwnode_handle *prev)
 {
 	return fwnode_call_ptr_op(fwnode, graph_get_next_endpoint, prev);
@@ -1182,7 +1186,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
  * Return: the firmware node of the device the @endpoint belongs to.
  */
 struct fwnode_handle *
-fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
+fwnode_graph_get_port_parent(const struct fwnode_handle *endpoint)
 {
 	struct fwnode_handle *port, *parent;
 
@@ -1202,7 +1206,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_port_parent);
  * Extracts firmware node of a remote device the @fwnode points to.
  */
 struct fwnode_handle *
-fwnode_graph_get_remote_port_parent(struct fwnode_handle *fwnode)
+fwnode_graph_get_remote_port_parent(const struct fwnode_handle *fwnode)
 {
 	struct fwnode_handle *endpoint, *parent;
 
@@ -1221,7 +1225,8 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_port_parent);
  *
  * Extracts firmware node of a remote port the @fwnode points to.
  */
-struct fwnode_handle *fwnode_graph_get_remote_port(struct fwnode_handle *fwnode)
+struct fwnode_handle *
+fwnode_graph_get_remote_port(const struct fwnode_handle *fwnode)
 {
 	return fwnode_get_next_parent(fwnode_graph_get_remote_endpoint(fwnode));
 }
@@ -1234,7 +1239,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_port);
  * Extracts firmware node of a remote endpoint the @fwnode points to.
  */
 struct fwnode_handle *
-fwnode_graph_get_remote_endpoint(struct fwnode_handle *fwnode)
+fwnode_graph_get_remote_endpoint(const struct fwnode_handle *fwnode)
 {
 	return fwnode_call_ptr_op(fwnode, graph_get_remote_endpoint);
 }
@@ -1249,8 +1254,9 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_endpoint);
  * 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 *
+fwnode_graph_get_remote_node(const struct fwnode_handle *fwnode, u32 port_id,
+			     u32 endpoint_id)
 {
 	struct fwnode_handle *endpoint = NULL;
 
@@ -1286,7 +1292,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_node);
  * information in @endpoint. The caller must hold a reference to
  * @fwnode.
  */
-int fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
+int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
 				struct fwnode_endpoint *endpoint)
 {
 	memset(endpoint, 0, sizeof(*endpoint));
diff --git a/drivers/of/property.c b/drivers/of/property.c
index 2d59888..ae46a6f 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -815,23 +815,23 @@ 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)
+static bool of_fwnode_device_is_available(const struct fwnode_handle *fwnode)
 {
 	return of_device_is_available(to_of_node(fwnode));
 }
 
-static bool of_fwnode_property_present(struct fwnode_handle *fwnode,
+static bool of_fwnode_property_present(const struct fwnode_handle *fwnode,
 				       const char *propname)
 {
 	return of_property_read_bool(to_of_node(fwnode), propname);
 }
 
-static int of_fwnode_property_read_int_array(struct fwnode_handle *fwnode,
+static int of_fwnode_property_read_int_array(const struct fwnode_handle *fwnode,
 					     const char *propname,
 					     unsigned int elem_size, void *val,
 					     size_t nval)
 {
-	struct device_node *node = to_of_node(fwnode);
+	const struct device_node *node = to_of_node(fwnode);
 
 	if (!val)
 		return of_property_count_elems_of_size(node, propname,
@@ -851,24 +851,26 @@ static int of_fwnode_property_read_int_array(struct fwnode_handle *fwnode,
 	return -ENXIO;
 }
 
-static int of_fwnode_property_read_string_array(struct fwnode_handle *fwnode,
-						const char *propname,
-						const char **val, size_t nval)
+static int
+of_fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
+				     const char *propname, const char **val,
+				     size_t nval)
 {
-	struct device_node *node = to_of_node(fwnode);
+	const struct device_node *node = to_of_node(fwnode);
 
 	return val ?
 		of_property_read_string_array(node, propname, val, nval) :
 		of_property_count_strings(node, propname);
 }
 
-static struct fwnode_handle *of_fwnode_get_parent(struct fwnode_handle *fwnode)
+static struct fwnode_handle *
+of_fwnode_get_parent(const struct fwnode_handle *fwnode)
 {
 	return of_fwnode_handle(of_get_parent(to_of_node(fwnode)));
 }
 
 static struct fwnode_handle *
-of_fwnode_get_next_child_node(struct fwnode_handle *fwnode,
+of_fwnode_get_next_child_node(const struct fwnode_handle *fwnode,
 			      struct fwnode_handle *child)
 {
 	return of_fwnode_handle(of_get_next_available_child(to_of_node(fwnode),
@@ -876,10 +878,10 @@ of_fwnode_get_next_child_node(struct fwnode_handle *fwnode,
 }
 
 static struct fwnode_handle *
-of_fwnode_get_named_child_node(struct fwnode_handle *fwnode,
+of_fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
 			       const char *childname)
 {
-	struct device_node *node = to_of_node(fwnode);
+	const struct device_node *node = to_of_node(fwnode);
 	struct device_node *child;
 
 	for_each_available_child_of_node(node, child)
@@ -890,7 +892,7 @@ of_fwnode_get_named_child_node(struct fwnode_handle *fwnode,
 }
 
 static struct fwnode_handle *
-of_fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
+of_fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
 				  struct fwnode_handle *prev)
 {
 	return of_fwnode_handle(of_graph_get_next_endpoint(to_of_node(fwnode),
@@ -898,7 +900,7 @@ of_fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
 }
 
 static struct fwnode_handle *
-of_fwnode_graph_get_remote_endpoint(struct fwnode_handle *fwnode)
+of_fwnode_graph_get_remote_endpoint(const struct fwnode_handle *fwnode)
 {
 	return of_fwnode_handle(of_parse_phandle(to_of_node(fwnode),
 						 "remote-endpoint", 0));
@@ -921,10 +923,10 @@ of_fwnode_graph_get_port_parent(struct fwnode_handle *fwnode)
 	return of_fwnode_handle(of_get_next_parent(np));
 }
 
-static int of_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
+static int of_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
 					  struct fwnode_endpoint *endpoint)
 {
-	struct device_node *node = to_of_node(fwnode);
+	const struct device_node *node = to_of_node(fwnode);
 	struct device_node *port_node = of_get_parent(node);
 
 	endpoint->local_fwnode = fwnode;
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 4d9fb61..8b9edf8 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1029,13 +1029,14 @@ int acpi_node_prop_read(const struct fwnode_handle *fwnode,
 int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname,
 		       enum dev_prop_type proptype, void *val, size_t nval);
 
-struct fwnode_handle *acpi_get_next_subnode(struct fwnode_handle *fwnode,
+struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
 					    struct fwnode_handle *child);
-struct fwnode_handle *acpi_node_get_parent(struct fwnode_handle *fwnode);
+struct fwnode_handle *acpi_node_get_parent(const struct fwnode_handle *fwnode);
 
-struct fwnode_handle *acpi_graph_get_next_endpoint(struct fwnode_handle *fwnode,
-						   struct fwnode_handle *prev);
-int acpi_graph_get_remote_endpoint(struct fwnode_handle *fwnode,
+struct fwnode_handle *
+acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
+			     struct fwnode_handle *prev);
+int acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode,
 				   struct fwnode_handle **remote,
 				   struct fwnode_handle **port,
 				   struct fwnode_handle **endpoint);
@@ -1157,26 +1158,27 @@ static inline int acpi_dev_prop_read(const struct acpi_device *adev,
 }
 
 static inline struct fwnode_handle *
-acpi_get_next_subnode(struct fwnode_handle *fwnode, struct fwnode_handle *child)
+acpi_get_next_subnode(const struct fwnode_handle *fwnode,
+		      struct fwnode_handle *child)
 {
 	return NULL;
 }
 
 static inline struct fwnode_handle *
-acpi_node_get_parent(struct fwnode_handle *fwnode)
+acpi_node_get_parent(const struct fwnode_handle *fwnode)
 {
 	return NULL;
 }
 
 static inline struct fwnode_handle *
-acpi_graph_get_next_endpoint(struct fwnode_handle *fwnode,
+acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
 			     struct fwnode_handle *prev)
 {
 	return ERR_PTR(-ENXIO);
 }
 
 static inline int
-acpi_graph_get_remote_endpoint(struct fwnode_handle *fwnode,
+acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode,
 			       struct fwnode_handle **remote,
 			       struct fwnode_handle **port,
 			       struct fwnode_handle **endpoint)
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index c5dbc48..7b50ee4 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -55,30 +55,32 @@ 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,
+	bool (*device_is_available)(const struct fwnode_handle *fwnode);
+	bool (*property_present)(const struct fwnode_handle *fwnode,
 				 const char *propname);
-	int (*property_read_int_array)(struct fwnode_handle *fwnode,
+	int (*property_read_int_array)(const struct fwnode_handle *fwnode,
 				       const char *propname,
 				       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);
+	int
+	(*property_read_string_array)(const struct fwnode_handle *fwnode_handle,
+				      const char *propname, const char **val,
+				      size_t nval);
+	struct fwnode_handle *(*get_parent)(const struct fwnode_handle *fwnode);
 	struct fwnode_handle *
-	(*get_next_child_node)(struct fwnode_handle *fwnode,
+	(*get_next_child_node)(const struct fwnode_handle *fwnode,
 			       struct fwnode_handle *child);
 	struct fwnode_handle *
-	(*get_named_child_node)(struct fwnode_handle *fwnode, const char *name);
+	(*get_named_child_node)(const struct fwnode_handle *fwnode,
+				const char *name);
 	struct fwnode_handle *
-	(*graph_get_next_endpoint)(struct fwnode_handle *fwnode,
+	(*graph_get_next_endpoint)(const struct fwnode_handle *fwnode,
 				   struct fwnode_handle *prev);
 	struct fwnode_handle *
-	(*graph_get_remote_endpoint)(struct fwnode_handle *fwnode);
+	(*graph_get_remote_endpoint)(const struct fwnode_handle *fwnode);
 	struct fwnode_handle *
 	(*graph_get_port_parent)(struct fwnode_handle *fwnode);
-	int (*graph_parse_endpoint)(struct fwnode_handle *fwnode,
+	int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode,
 				    struct fwnode_endpoint *endpoint);
 };
 
diff --git a/include/linux/property.h b/include/linux/property.h
index 7e77039..edff3f8 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -51,46 +51,48 @@ 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,
+bool fwnode_device_is_available(const struct fwnode_handle *fwnode);
+bool fwnode_property_present(const struct fwnode_handle *fwnode,
+			     const char *propname);
+int fwnode_property_read_u8_array(const struct fwnode_handle *fwnode,
 				  const char *propname, u8 *val,
 				  size_t nval);
-int fwnode_property_read_u16_array(struct fwnode_handle *fwnode,
+int fwnode_property_read_u16_array(const struct fwnode_handle *fwnode,
 				   const char *propname, u16 *val,
 				   size_t nval);
-int fwnode_property_read_u32_array(struct fwnode_handle *fwnode,
+int fwnode_property_read_u32_array(const struct fwnode_handle *fwnode,
 				   const char *propname, u32 *val,
 				   size_t nval);
-int fwnode_property_read_u64_array(struct fwnode_handle *fwnode,
+int fwnode_property_read_u64_array(const struct fwnode_handle *fwnode,
 				   const char *propname, u64 *val,
 				   size_t nval);
-int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
+int fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
 				      const char *propname, const char **val,
 				      size_t nval);
-int fwnode_property_read_string(struct fwnode_handle *fwnode,
+int fwnode_property_read_string(const struct fwnode_handle *fwnode,
 				const char *propname, const char **val);
-int fwnode_property_match_string(struct fwnode_handle *fwnode,
+int fwnode_property_match_string(const struct fwnode_handle *fwnode,
 				 const char *propname, const char *string);
 
-struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode);
-struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode);
-struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *fwnode,
-						 struct fwnode_handle *child);
+struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
+struct fwnode_handle *fwnode_get_next_parent(
+	struct fwnode_handle *fwnode);
+struct fwnode_handle *fwnode_get_next_child_node(
+	const struct fwnode_handle *fwnode, struct fwnode_handle *child);
 
 #define fwnode_for_each_child_node(fwnode, child)			\
 	for (child = fwnode_get_next_child_node(fwnode, NULL); child;	\
 	     child = fwnode_get_next_child_node(fwnode, child))
 
-struct fwnode_handle *device_get_next_child_node(struct device *dev,
-						 struct fwnode_handle *child);
+struct fwnode_handle *device_get_next_child_node(
+	struct device *dev, struct fwnode_handle *child);
 
 #define device_for_each_child_node(dev, child)				\
 	for (child = device_get_next_child_node(dev, NULL); child;	\
 	     child = device_get_next_child_node(dev, child))
 
-struct fwnode_handle *fwnode_get_named_child_node(struct fwnode_handle *fwnode,
-						  const char *childname);
+struct fwnode_handle *fwnode_get_named_child_node(
+	const struct fwnode_handle *fwnode, const char *childname);
 struct fwnode_handle *device_get_named_child_node(struct device *dev,
 						  const char *childname);
 
@@ -129,31 +131,31 @@ static inline int device_property_read_u64(struct device *dev,
 	return device_property_read_u64_array(dev, propname, val, 1);
 }
 
-static inline bool fwnode_property_read_bool(struct fwnode_handle *fwnode,
+static inline bool fwnode_property_read_bool(const struct fwnode_handle *fwnode,
 					     const char *propname)
 {
 	return fwnode_property_present(fwnode, propname);
 }
 
-static inline int fwnode_property_read_u8(struct fwnode_handle *fwnode,
+static inline int fwnode_property_read_u8(const struct fwnode_handle *fwnode,
 					  const char *propname, u8 *val)
 {
 	return fwnode_property_read_u8_array(fwnode, propname, val, 1);
 }
 
-static inline int fwnode_property_read_u16(struct fwnode_handle *fwnode,
+static inline int fwnode_property_read_u16(const struct fwnode_handle *fwnode,
 					   const char *propname, u16 *val)
 {
 	return fwnode_property_read_u16_array(fwnode, propname, val, 1);
 }
 
-static inline int fwnode_property_read_u32(struct fwnode_handle *fwnode,
+static inline int fwnode_property_read_u32(const struct fwnode_handle *fwnode,
 					   const char *propname, u32 *val)
 {
 	return fwnode_property_read_u32_array(fwnode, propname, val, 1);
 }
 
-static inline int fwnode_property_read_u64(struct fwnode_handle *fwnode,
+static inline int fwnode_property_read_u64(const struct fwnode_handle *fwnode,
 					   const char *propname, u64 *val)
 {
 	return fwnode_property_read_u64_array(fwnode, propname, val, 1);
@@ -274,19 +276,20 @@ int device_get_phy_mode(struct device *dev);
 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);
+	const struct fwnode_handle *fwnode, struct fwnode_handle *prev);
 struct fwnode_handle *
-fwnode_graph_get_port_parent(struct fwnode_handle *fwnode);
+fwnode_graph_get_port_parent(const struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_graph_get_remote_port_parent(
-	struct fwnode_handle *fwnode);
+	const struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_graph_get_remote_port(
-	struct fwnode_handle *fwnode);
+	const struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_graph_get_remote_endpoint(
-	struct fwnode_handle *fwnode);
-struct fwnode_handle *fwnode_graph_get_remote_node(struct fwnode_handle *fwnode,
-						   u32 port, u32 endpoint);
+	const struct fwnode_handle *fwnode);
+struct fwnode_handle *
+fwnode_graph_get_remote_node(const struct fwnode_handle *fwnode, u32 port,
+			     u32 endpoint);
 
-int fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
+int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
 				struct fwnode_endpoint *endpoint);
 
 #endif /* _LINUX_PROPERTY_H_ */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v3 8/8] device property: Introduce fwnode_property_get_reference_args
  2017-07-21 11:39 [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments Sakari Ailus
                   ` (5 preceding siblings ...)
  2017-07-21 11:39 ` [PATCH v3 7/8] device property: Constify fwnode property API Sakari Ailus
@ 2017-07-21 11:39 ` Sakari Ailus
       [not found]   ` <1500637177-16095-9-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  2017-07-21 12:11   ` [PATCH v3.1 " Sakari Ailus
  6 siblings, 2 replies; 23+ messages in thread
From: Sakari Ailus @ 2017-07-21 11:39 UTC (permalink / raw)
  To: linux-acpi
  Cc: devicetree, sudeep.holla, lorenzo.pieralisi, mika.westerberg,
	rafael, mark.rutland, broonie, robh, ahs3, frowand.list,
	erik.veijola, andriy.shevchenko

The new fwnode_property_get_reference_args() interface amends the fwnode
property API with the functionality of both of_parse_phandle_with_args()
and __acpi_node_get_property_reference().

The semantics is slightly different: the cells property is ignored on ACPI
as the number of arguments can be explicitly obtained from the firmware
interface.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/acpi/property.c  | 27 +++++++++++++++++++++++++++
 drivers/base/property.c  | 28 ++++++++++++++++++++++++++++
 drivers/of/property.c    | 31 +++++++++++++++++++++++++++++++
 include/linux/fwnode.h   | 19 +++++++++++++++++++
 include/linux/property.h |  4 ++++
 5 files changed, 109 insertions(+)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index f8d6005..b39497c 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1195,6 +1195,32 @@ acpi_fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
 	return NULL;
 }
 
+static int
+acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
+			       const char *prop, const char *nargs_prop,
+			       unsigned int args_count, unsigned int index,
+			       struct fwnode_reference_args *args)
+{
+	struct acpi_reference_args acpi_args;
+	unsigned int i;
+	int ret;
+
+	ret = __acpi_node_get_property_reference(fwnode, prop, index,
+						 args_count, &acpi_args);
+	if (ret < 0)
+		return ret;
+	if (!args)
+		return 0;
+
+	args->nargs = acpi_args.nargs;
+	args->fwnode = acpi_fwnode_handle(acpi_args.adev);
+
+	for (i = 0; i < NR_OF_FWNODE_REFERENCE_ARGS; i++)
+		args->args[i] = i < acpi_args.nargs ? acpi_args.args[i] : 0;
+
+	return 0;
+}
+
 static struct fwnode_handle *
 acpi_fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
 				    struct fwnode_handle *prev)
@@ -1248,6 +1274,7 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
 		.get_parent = acpi_node_get_parent,			\
 		.get_next_child_node = acpi_get_next_subnode,		\
 		.get_named_child_node = acpi_fwnode_get_named_child_node, \
+		.get_reference_args = acpi_fwnode_get_reference_args,	\
 		.graph_get_next_endpoint =				\
 			acpi_fwnode_graph_get_next_endpoint,		\
 		.graph_get_remote_endpoint =				\
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 673e235..d0b65bb 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -665,6 +665,34 @@ int fwnode_property_match_string(const struct fwnode_handle *fwnode,
 }
 EXPORT_SYMBOL_GPL(fwnode_property_match_string);
 
+/**
+ * fwnode_property_get_reference_args() - Find a reference with arguments
+ * @fwnode:	Firmware node where to look for the reference
+ * @prop:	The name of the property
+ * @nargs_prop:	The name of the property telling the number of
+ *		arguments in the referred node. NULL if @nargs is known,
+ *		otherwise @nargs is ignored. Only relevant on OF.
+ * @nargs:	Number of arguments. Ignored if @nargs_prop is non-NULL.
+ * @index:	Index of the reference, from zero onwards.
+ * @args:	Result structure with reference and integer arguments.
+ *
+ * Obtain a reference based on a named property in an fwnode, with
+ * integer arguments.
+ *
+ * Caller is responsible to call fwnode_handle_put() on the returned
+ * args->fwnode pointer.
+ *
+ */
+int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
+				       const char *prop, const char *nargs_prop,
+				       unsigned int nargs, unsigned int index,
+				       struct fwnode_reference_args *args)
+{
+	return fwnode_call_int_op(fwnode, get_reference_args, prop, nargs_prop,
+				  nargs, index, args);
+}
+EXPORT_SYMBOL_GPL(fwnode_property_get_reference_args);
+
 static int property_copy_string_array(struct property_entry *dst,
 				      const struct property_entry *src)
 {
diff --git a/drivers/of/property.c b/drivers/of/property.c
index ae46a6f..2350103 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -891,6 +891,36 @@ of_fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
 	return NULL;
 }
 
+static int
+of_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
+			     const char *prop, const char *nargs_prop,
+			     unsigned int nargs, unsigned int index,
+			     struct fwnode_reference_args *args)
+{
+	struct of_phandle_args of_args;
+	unsigned int i;
+	int ret;
+
+	if (nargs_prop)
+		ret = of_parse_phandle_with_args(to_of_node(fwnode), prop,
+						 nargs_prop, index, &of_args);
+	else
+		ret = of_parse_phandle_with_fixed_args(to_of_node(fwnode), prop,
+						       nargs, index, &of_args);
+	if (ret < 0)
+		return ret;
+	if (!args)
+		return 0;
+
+	args->nargs = of_args.args_count;
+	args->fwnode = of_fwnode_handle(of_args.np);
+
+	for (i = 0; i < NR_OF_FWNODE_REFERENCE_ARGS; i++)
+		args->args[i] = i < of_args.args_count ? of_args.args[i] : 0;
+
+	return 0;
+}
+
 static struct fwnode_handle *
 of_fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
 				  struct fwnode_handle *prev)
@@ -949,6 +979,7 @@ const struct fwnode_operations of_fwnode_ops = {
 	.get_parent = of_fwnode_get_parent,
 	.get_next_child_node = of_fwnode_get_next_child_node,
 	.get_named_child_node = of_fwnode_get_named_child_node,
+	.get_reference_args = of_fwnode_get_reference_args,
 	.graph_get_next_endpoint = of_fwnode_graph_get_next_endpoint,
 	.graph_get_remote_endpoint = of_fwnode_graph_get_remote_endpoint,
 	.graph_get_port_parent = of_fwnode_graph_get_port_parent,
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 7b50ee4..218fe03 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -33,6 +33,20 @@ struct fwnode_endpoint {
 	const struct fwnode_handle *local_fwnode;
 };
 
+#define NR_OF_FWNODE_REFERENCE_ARGS	8
+
+/**
+ * struct fwnode_reference_args - Fwnode reference with additional arguments
+ * @fwnode:- A reference to the base fwnode
+ * @nargs: Number of elements in @args array
+ * @args: Integer arguments on the fwnode
+ */
+struct fwnode_reference_args {
+	struct fwnode_handle *fwnode;
+	unsigned int nargs;
+	unsigned int args[NR_OF_FWNODE_REFERENCE_ARGS];
+};
+
 /**
  * struct fwnode_operations - Operations for fwnode interface
  * @get: Get a reference to an fwnode.
@@ -46,6 +60,7 @@ 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.
+ * @get_reference_args: Return a reference pointed to by a property, with args
  * @graph_get_next_endpoint: Return an endpoint node in an iteration.
  * @graph_get_remote_endpoint: Return the remote endpoint node of a local
  *			       endpoint node.
@@ -73,6 +88,10 @@ struct fwnode_operations {
 	struct fwnode_handle *
 	(*get_named_child_node)(const struct fwnode_handle *fwnode,
 				const char *name);
+	int (*get_reference_args)(const struct fwnode_handle *fwnode,
+				  const char *prop, const char *nargs_prop,
+				  unsigned int nargs, unsigned int index,
+				  struct fwnode_reference_args *args);
 	struct fwnode_handle *
 	(*graph_get_next_endpoint)(const struct fwnode_handle *fwnode,
 				   struct fwnode_handle *prev);
diff --git a/include/linux/property.h b/include/linux/property.h
index edff3f8..6bebee1 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -73,6 +73,10 @@ int fwnode_property_read_string(const struct fwnode_handle *fwnode,
 				const char *propname, const char **val);
 int fwnode_property_match_string(const struct fwnode_handle *fwnode,
 				 const char *propname, const char *string);
+int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
+				       const char *prop, const char *nargs_prop,
+				       unsigned int nargs, unsigned int index,
+				       struct fwnode_reference_args *args);
 
 struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_get_next_parent(
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments
       [not found] ` <1500637177-16095-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  2017-07-21 11:39   ` [PATCH v3 1/8] ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in is_acpi_data_node Sakari Ailus
  2017-07-21 11:39   ` [PATCH v3 4/8] ACPI: Constify acpi_bus helper functions, switch to macros Sakari Ailus
@ 2017-07-21 11:52   ` Rafael J. Wysocki
  2017-07-21 12:33     ` Andy Shevchenko
  2 siblings, 1 reply; 23+ messages in thread
From: Rafael J. Wysocki @ 2017-07-21 11:52 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: ACPI Devel Maling List, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Sudeep Holla, Lorenzo Pieralisi, Mika Westerberg,
	Rafael J. Wysocki, Mark Rutland, Mark Brown, Rob Herring,
	Al Stone, Frank Rowand, erik.veijola-ral2JQCrhuEAvxtiuMwx3w,
	Andy Shevchenko

On Fri, Jul 21, 2017 at 1:39 PM, Sakari Ailus
<sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
> Hello everyone,
>
> This set removes the struct fwnode_handle type field and constifies the
> fwnode arguments in the fwnode property API more or less the way they are
> const in OF property API.
>
> Comments are welcome.
>
> All the dependent patches are now in linux-pm master branch.
>
> <URL:http://www.spinics.net/lists/linux-acpi/msg75957.html>
>
> v1 can be found here:
>
> <URL:http://www.spinics.net/lists/linux-acpi/msg74564.html>
>
> changes since v2:
>
> - Add 8th patch "device property: Introduce
>   fwnode_property_get_reference_args". This allows obtaining references
>   with integer arguments using the fwnode interface.
>
>   The functionality will be soon needed in adding support for nvmem
>   framework on ACPI as well as in referring to e.g. lens and flash devices
>   on V4L2.

OK, so if people have no objections, I'll queue this up for 4.14.

Thanks,
Rafael
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 1/8] ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in is_acpi_data_node
  2017-07-21 11:39   ` [PATCH v3 1/8] ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in is_acpi_data_node Sakari Ailus
@ 2017-07-21 11:59     ` Andy Shevchenko
  2017-07-21 12:12       ` Andy Shevchenko
  0 siblings, 1 reply; 23+ messages in thread
From: Andy Shevchenko @ 2017-07-21 11:59 UTC (permalink / raw)
  To: Sakari Ailus, linux-acpi
  Cc: devicetree, sudeep.holla, lorenzo.pieralisi, mika.westerberg,
	rafael, mark.rutland, broonie, robh, ahs3, frowand.list,
	erik.veijola

On Fri, 2017-07-21 at 14:39 +0300, Sakari Ailus wrote:
> The is_acpi_data_node() function takes a struct fwnode_handle pointer
> as
> its argument. The validity of the pointer is first checked. Extend the
> check to cover error values as is done by similar is_acpi_node() and
> is_acpi_device_node() functions.
> 

Patch is good.

It seems we will have three places with such code. Do we care to get rid
of them in favor of is_acpi_data_node()? (I didn't read whole series
yet, maybe it's already done)

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  include/acpi/acpi_bus.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> index 68bc6be..7569123 100644
> --- a/include/acpi/acpi_bus.h
> +++ b/include/acpi/acpi_bus.h
> @@ -414,7 +414,7 @@ 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 !IS_ERR_OR_NULL(fwnode) && fwnode->type ==
> FWNODE_ACPI_DATA;
>  }
>  
>  static inline struct acpi_data_node *to_acpi_data_node(struct
> fwnode_handle *fwnode)

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 8/8] device property: Introduce fwnode_property_get_reference_args
       [not found]   ` <1500637177-16095-9-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2017-07-21 12:06     ` Andy Shevchenko
  0 siblings, 0 replies; 23+ messages in thread
From: Andy Shevchenko @ 2017-07-21 12:06 UTC (permalink / raw)
  To: Sakari Ailus, linux-acpi-u79uwXL29TY76Z2rM5mHXA
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, sudeep.holla-5wv7dgnIgG8,
	lorenzo.pieralisi-5wv7dgnIgG8,
	mika.westerberg-VuQAYsv1563Yd54FQh9/CA,
	rafael-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, robh-DgEjT+Ai2ygdnm+yROfE0A,
	ahs3-H+wXaHxf7aLQT0dZR+AlfA, frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	erik.veijola-ral2JQCrhuEAvxtiuMwx3w

On Fri, 2017-07-21 at 14:39 +0300, Sakari Ailus wrote:
> The new fwnode_property_get_reference_args() interface amends the
> fwnode
> property API with the functionality of both
> of_parse_phandle_with_args()
> and __acpi_node_get_property_reference().
> 
> The semantics is slightly different: the cells property is ignored on
> ACPI
> as the number of arguments can be explicitly obtained from the
> firmware
> interface.
> 

 
> +#define NR_OF_FWNODE_REFERENCE_ARGS	8
> 

OF here is confusing. Can we just get rid of it?


-- 
Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Intel Finland Oy
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v3.1 8/8] device property: Introduce fwnode_property_get_reference_args
  2017-07-21 11:39 ` [PATCH v3 8/8] device property: Introduce fwnode_property_get_reference_args Sakari Ailus
       [not found]   ` <1500637177-16095-9-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2017-07-21 12:11   ` Sakari Ailus
  1 sibling, 0 replies; 23+ messages in thread
From: Sakari Ailus @ 2017-07-21 12:11 UTC (permalink / raw)
  To: linux-acpi
  Cc: devicetree, sudeep.holla, lorenzo.pieralisi, mika.westerberg,
	rafael, mark.rutland, broonie, robh, ahs3, frowand.list,
	erik.veijola, andriy.shevchenko

The new fwnode_property_get_reference_args() interface amends the fwnode
property API with the functionality of both of_parse_phandle_with_args()
and __acpi_node_get_property_reference().

The semantics is slightly different: the cells property is ignored on ACPI
as the number of arguments can be explicitly obtained from the firmware
interface.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/acpi/property.c  | 27 +++++++++++++++++++++++++++
 drivers/base/property.c  | 28 ++++++++++++++++++++++++++++
 drivers/of/property.c    | 31 +++++++++++++++++++++++++++++++
 include/linux/fwnode.h   | 19 +++++++++++++++++++
 include/linux/property.h |  4 ++++
 5 files changed, 109 insertions(+)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index f8d6005..681a843 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1195,6 +1195,32 @@ acpi_fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
 	return NULL;
 }
 
+static int
+acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
+			       const char *prop, const char *nargs_prop,
+			       unsigned int args_count, unsigned int index,
+			       struct fwnode_reference_args *args)
+{
+	struct acpi_reference_args acpi_args;
+	unsigned int i;
+	int ret;
+
+	ret = __acpi_node_get_property_reference(fwnode, prop, index,
+						 args_count, &acpi_args);
+	if (ret < 0)
+		return ret;
+	if (!args)
+		return 0;
+
+	args->nargs = acpi_args.nargs;
+	args->fwnode = acpi_fwnode_handle(acpi_args.adev);
+
+	for (i = 0; i < NR_FWNODE_REFERENCE_ARGS; i++)
+		args->args[i] = i < acpi_args.nargs ? acpi_args.args[i] : 0;
+
+	return 0;
+}
+
 static struct fwnode_handle *
 acpi_fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
 				    struct fwnode_handle *prev)
@@ -1248,6 +1274,7 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
 		.get_parent = acpi_node_get_parent,			\
 		.get_next_child_node = acpi_get_next_subnode,		\
 		.get_named_child_node = acpi_fwnode_get_named_child_node, \
+		.get_reference_args = acpi_fwnode_get_reference_args,	\
 		.graph_get_next_endpoint =				\
 			acpi_fwnode_graph_get_next_endpoint,		\
 		.graph_get_remote_endpoint =				\
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 673e235..d0b65bb 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -665,6 +665,34 @@ int fwnode_property_match_string(const struct fwnode_handle *fwnode,
 }
 EXPORT_SYMBOL_GPL(fwnode_property_match_string);
 
+/**
+ * fwnode_property_get_reference_args() - Find a reference with arguments
+ * @fwnode:	Firmware node where to look for the reference
+ * @prop:	The name of the property
+ * @nargs_prop:	The name of the property telling the number of
+ *		arguments in the referred node. NULL if @nargs is known,
+ *		otherwise @nargs is ignored. Only relevant on OF.
+ * @nargs:	Number of arguments. Ignored if @nargs_prop is non-NULL.
+ * @index:	Index of the reference, from zero onwards.
+ * @args:	Result structure with reference and integer arguments.
+ *
+ * Obtain a reference based on a named property in an fwnode, with
+ * integer arguments.
+ *
+ * Caller is responsible to call fwnode_handle_put() on the returned
+ * args->fwnode pointer.
+ *
+ */
+int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
+				       const char *prop, const char *nargs_prop,
+				       unsigned int nargs, unsigned int index,
+				       struct fwnode_reference_args *args)
+{
+	return fwnode_call_int_op(fwnode, get_reference_args, prop, nargs_prop,
+				  nargs, index, args);
+}
+EXPORT_SYMBOL_GPL(fwnode_property_get_reference_args);
+
 static int property_copy_string_array(struct property_entry *dst,
 				      const struct property_entry *src)
 {
diff --git a/drivers/of/property.c b/drivers/of/property.c
index ae46a6f..3868400 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -891,6 +891,36 @@ of_fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
 	return NULL;
 }
 
+static int
+of_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
+			     const char *prop, const char *nargs_prop,
+			     unsigned int nargs, unsigned int index,
+			     struct fwnode_reference_args *args)
+{
+	struct of_phandle_args of_args;
+	unsigned int i;
+	int ret;
+
+	if (nargs_prop)
+		ret = of_parse_phandle_with_args(to_of_node(fwnode), prop,
+						 nargs_prop, index, &of_args);
+	else
+		ret = of_parse_phandle_with_fixed_args(to_of_node(fwnode), prop,
+						       nargs, index, &of_args);
+	if (ret < 0)
+		return ret;
+	if (!args)
+		return 0;
+
+	args->nargs = of_args.args_count;
+	args->fwnode = of_fwnode_handle(of_args.np);
+
+	for (i = 0; i < NR_FWNODE_REFERENCE_ARGS; i++)
+		args->args[i] = i < of_args.args_count ? of_args.args[i] : 0;
+
+	return 0;
+}
+
 static struct fwnode_handle *
 of_fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
 				  struct fwnode_handle *prev)
@@ -949,6 +979,7 @@ const struct fwnode_operations of_fwnode_ops = {
 	.get_parent = of_fwnode_get_parent,
 	.get_next_child_node = of_fwnode_get_next_child_node,
 	.get_named_child_node = of_fwnode_get_named_child_node,
+	.get_reference_args = of_fwnode_get_reference_args,
 	.graph_get_next_endpoint = of_fwnode_graph_get_next_endpoint,
 	.graph_get_remote_endpoint = of_fwnode_graph_get_remote_endpoint,
 	.graph_get_port_parent = of_fwnode_graph_get_port_parent,
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 7b50ee4..0c35b6c 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -33,6 +33,20 @@ struct fwnode_endpoint {
 	const struct fwnode_handle *local_fwnode;
 };
 
+#define NR_FWNODE_REFERENCE_ARGS	8
+
+/**
+ * struct fwnode_reference_args - Fwnode reference with additional arguments
+ * @fwnode:- A reference to the base fwnode
+ * @nargs: Number of elements in @args array
+ * @args: Integer arguments on the fwnode
+ */
+struct fwnode_reference_args {
+	struct fwnode_handle *fwnode;
+	unsigned int nargs;
+	unsigned int args[NR_FWNODE_REFERENCE_ARGS];
+};
+
 /**
  * struct fwnode_operations - Operations for fwnode interface
  * @get: Get a reference to an fwnode.
@@ -46,6 +60,7 @@ 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.
+ * @get_reference_args: Return a reference pointed to by a property, with args
  * @graph_get_next_endpoint: Return an endpoint node in an iteration.
  * @graph_get_remote_endpoint: Return the remote endpoint node of a local
  *			       endpoint node.
@@ -73,6 +88,10 @@ struct fwnode_operations {
 	struct fwnode_handle *
 	(*get_named_child_node)(const struct fwnode_handle *fwnode,
 				const char *name);
+	int (*get_reference_args)(const struct fwnode_handle *fwnode,
+				  const char *prop, const char *nargs_prop,
+				  unsigned int nargs, unsigned int index,
+				  struct fwnode_reference_args *args);
 	struct fwnode_handle *
 	(*graph_get_next_endpoint)(const struct fwnode_handle *fwnode,
 				   struct fwnode_handle *prev);
diff --git a/include/linux/property.h b/include/linux/property.h
index edff3f8..6bebee1 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -73,6 +73,10 @@ int fwnode_property_read_string(const struct fwnode_handle *fwnode,
 				const char *propname, const char **val);
 int fwnode_property_match_string(const struct fwnode_handle *fwnode,
 				 const char *propname, const char *string);
+int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
+				       const char *prop, const char *nargs_prop,
+				       unsigned int nargs, unsigned int index,
+				       struct fwnode_reference_args *args);
 
 struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_get_next_parent(
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 1/8] ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in is_acpi_data_node
  2017-07-21 11:59     ` Andy Shevchenko
@ 2017-07-21 12:12       ` Andy Shevchenko
  0 siblings, 0 replies; 23+ messages in thread
From: Andy Shevchenko @ 2017-07-21 12:12 UTC (permalink / raw)
  To: Sakari Ailus, linux-acpi
  Cc: devicetree, sudeep.holla, lorenzo.pieralisi, mika.westerberg,
	rafael, mark.rutland, broonie, robh, ahs3, frowand.list,
	erik.veijola

On Fri, 2017-07-21 at 14:59 +0300, Andy Shevchenko wrote:
> On Fri, 2017-07-21 at 14:39 +0300, Sakari Ailus wrote:
> > The is_acpi_data_node() function takes a struct fwnode_handle
> > pointer
> > as
> > its argument. The validity of the pointer is first checked. Extend
> > the
> > check to cover error values as is done by similar is_acpi_node() and
> > is_acpi_device_node() functions.
> > 
> 
> 
> It seems we will have three places with such code. Do we care to get
> rid
> of them in favor of is_acpi_data_node()? (I didn't read whole series
> yet, maybe it's already done)

Please, ignore this comment, I messed up with FWNODE_ACPI type.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments
       [not found]       ` <1500640389.29303.177.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2017-07-21 12:29         ` Rafael J. Wysocki
  2017-07-24 20:28           ` Rafael J. Wysocki
  0 siblings, 1 reply; 23+ messages in thread
From: Rafael J. Wysocki @ 2017-07-21 12:29 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rafael J. Wysocki, Sakari Ailus, ACPI Devel Maling List,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Sudeep Holla,
	Lorenzo Pieralisi, Mika Westerberg, Mark Rutland, Mark Brown,
	Rob Herring, Al Stone, Frank Rowand,
	erik.veijola-ral2JQCrhuEAvxtiuMwx3w

On Friday, July 21, 2017 03:33:09 PM Andy Shevchenko wrote:
> On Fri, 2017-07-21 at 13:52 +0200, Rafael J. Wysocki wrote:
> > On Fri, Jul 21, 2017 at 1:39 PM, Sakari Ailus
> > <sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
> > > Hello everyone,
> > > 
> > > This set removes the struct fwnode_handle type field and constifies
> > > the
> > > fwnode arguments in the fwnode property API more or less the way
> > > they are
> > > const in OF property API.
> > > 
> > > Comments are welcome.
> > > 
> > > All the dependent patches are now in linux-pm master branch.
> > > 
> > > <URL:http://www.spinics.net/lists/linux-acpi/msg75957.html>;
> > > 
> > > v1 can be found here:
> > > 
> > > <URL:http://www.spinics.net/lists/linux-acpi/msg74564.html>;
> > > 
> > > changes since v2:
> > > 
> > > - Add 8th patch "device property: Introduce
> > >   fwnode_property_get_reference_args". This allows obtaining
> > > references
> > >   with integer arguments using the fwnode interface.
> > > 
> > >   The functionality will be soon needed in adding support for nvmem
> > >   framework on ACPI as well as in referring to e.g. lens and flash
> > > devices
> > >   on V4L2.
> > 
> > OK, so if people have no objections, I'll queue this up for 4.14.
> 
> I have no objections.
> 
> One comment Sakari already has addressed, another one
> (list_first_enatry_or_null() use) might be addressed later.

Cool, thanks!

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 3/8] ACPI: Prepare for constifying acpi_get_next_subnode() fwnode argument
  2017-07-21 11:39 ` [PATCH v3 3/8] ACPI: Prepare for constifying acpi_get_next_subnode() fwnode argument Sakari Ailus
@ 2017-07-21 12:30   ` Andy Shevchenko
  0 siblings, 0 replies; 23+ messages in thread
From: Andy Shevchenko @ 2017-07-21 12:30 UTC (permalink / raw)
  To: Sakari Ailus, linux-acpi
  Cc: devicetree, sudeep.holla, lorenzo.pieralisi, mika.westerberg,
	rafael, mark.rutland, broonie, robh, ahs3, frowand.list,
	erik.veijola

On Fri, 2017-07-21 at 14:39 +0300, Sakari Ailus wrote:
> Make local variables const (head) or add new variables; adev was used
> for
> two purposes: to refer the root device node and its children. The two
> purposes are separated by this patch.
> 
> This is preparation for making fwnode arguments const for fwnode ops.
> Don't constify the argument itself quite yet as this is used as a
> callback
> function.

>  		if (child) {
> -			adev = to_acpi_device_node(child);
> -			next = adev->node.next;
> +			child_adev = to_acpi_device_node(child);
> +			next = child_adev->node.next;
>  			if (next == head) {
>  				child = NULL;
>  				goto nondev;
>  			}
> -			adev = list_entry(next, struct acpi_device,
> node);
> +			child_adev = list_entry(next, struct
> acpi_device, node);


Isn't it 

list_first_entry_or_null() ?


-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments
  2017-07-21 11:52   ` [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments Rafael J. Wysocki
@ 2017-07-21 12:33     ` Andy Shevchenko
       [not found]       ` <1500640389.29303.177.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Andy Shevchenko @ 2017-07-21 12:33 UTC (permalink / raw)
  To: Rafael J. Wysocki, Sakari Ailus
  Cc: ACPI Devel Maling List, devicetree, Sudeep Holla,
	Lorenzo Pieralisi, Mika Westerberg, Mark Rutland, Mark Brown,
	Rob Herring, Al Stone, Frank Rowand, erik.veijola

On Fri, 2017-07-21 at 13:52 +0200, Rafael J. Wysocki wrote:
> On Fri, Jul 21, 2017 at 1:39 PM, Sakari Ailus
> <sakari.ailus@linux.intel.com> wrote:
> > Hello everyone,
> > 
> > This set removes the struct fwnode_handle type field and constifies
> > the
> > fwnode arguments in the fwnode property API more or less the way
> > they are
> > const in OF property API.
> > 
> > Comments are welcome.
> > 
> > All the dependent patches are now in linux-pm master branch.
> > 
> > <URL:http://www.spinics.net/lists/linux-acpi/msg75957.html>;
> > 
> > v1 can be found here:
> > 
> > <URL:http://www.spinics.net/lists/linux-acpi/msg74564.html>;
> > 
> > changes since v2:
> > 
> > - Add 8th patch "device property: Introduce
> >   fwnode_property_get_reference_args". This allows obtaining
> > references
> >   with integer arguments using the fwnode interface.
> > 
> >   The functionality will be soon needed in adding support for nvmem
> >   framework on ACPI as well as in referring to e.g. lens and flash
> > devices
> >   on V4L2.
> 
> OK, so if people have no objections, I'll queue this up for 4.14.

I have no objections.

One comment Sakari already has addressed, another one
(list_first_enatry_or_null() use) might be addressed later.


-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments
  2017-07-21 12:29         ` Rafael J. Wysocki
@ 2017-07-24 20:28           ` Rafael J. Wysocki
  2017-08-08  9:32             ` Sakari Ailus
  0 siblings, 1 reply; 23+ messages in thread
From: Rafael J. Wysocki @ 2017-07-24 20:28 UTC (permalink / raw)
  To: Andy Shevchenko, Sakari Ailus
  Cc: Rafael J. Wysocki, ACPI Devel Maling List, devicetree,
	Sudeep Holla, Lorenzo Pieralisi, Mika Westerberg, Mark Rutland,
	Mark Brown, Rob Herring, Al Stone, Frank Rowand, erik.veijola

On Friday, July 21, 2017 02:29:06 PM Rafael J. Wysocki wrote:
> On Friday, July 21, 2017 03:33:09 PM Andy Shevchenko wrote:
> > On Fri, 2017-07-21 at 13:52 +0200, Rafael J. Wysocki wrote:
> > > On Fri, Jul 21, 2017 at 1:39 PM, Sakari Ailus
> > > <sakari.ailus@linux.intel.com> wrote:
> > > > Hello everyone,
> > > > 
> > > > This set removes the struct fwnode_handle type field and constifies
> > > > the
> > > > fwnode arguments in the fwnode property API more or less the way
> > > > they are
> > > > const in OF property API.
> > > > 
> > > > Comments are welcome.
> > > > 
> > > > All the dependent patches are now in linux-pm master branch.
> > > > 
> > > > <URL:http://www.spinics.net/lists/linux-acpi/msg75957.html>;
> > > > 
> > > > v1 can be found here:
> > > > 
> > > > <URL:http://www.spinics.net/lists/linux-acpi/msg74564.html>;
> > > > 
> > > > changes since v2:
> > > > 
> > > > - Add 8th patch "device property: Introduce
> > > >   fwnode_property_get_reference_args". This allows obtaining
> > > > references
> > > >   with integer arguments using the fwnode interface.
> > > > 
> > > >   The functionality will be soon needed in adding support for nvmem
> > > >   framework on ACPI as well as in referring to e.g. lens and flash
> > > > devices
> > > >   on V4L2.
> > > 
> > > OK, so if people have no objections, I'll queue this up for 4.14.
> > 
> > I have no objections.
> > 
> > One comment Sakari already has addressed, another one
> > (list_first_enatry_or_null() use) might be addressed later.
> 
> Cool, thanks!

So the series have been applied.

Thanks,
Rafael


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments
  2017-07-24 20:28           ` Rafael J. Wysocki
@ 2017-08-08  9:32             ` Sakari Ailus
  2017-08-09  0:53               ` Rafael J. Wysocki
  0 siblings, 1 reply; 23+ messages in thread
From: Sakari Ailus @ 2017-08-08  9:32 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Andy Shevchenko, Sakari Ailus, Rafael J. Wysocki,
	ACPI Devel Maling List, devicetree, Sudeep Holla,
	Lorenzo Pieralisi, Mika Westerberg, Mark Rutland, Mark Brown,
	Rob Herring, Al Stone, Frank Rowand, erik.veijola

On Mon, Jul 24, 2017 at 10:28:12PM +0200, Rafael J. Wysocki wrote:
> On Friday, July 21, 2017 02:29:06 PM Rafael J. Wysocki wrote:
> > On Friday, July 21, 2017 03:33:09 PM Andy Shevchenko wrote:
> > > On Fri, 2017-07-21 at 13:52 +0200, Rafael J. Wysocki wrote:
> > > > On Fri, Jul 21, 2017 at 1:39 PM, Sakari Ailus
> > > > <sakari.ailus@linux.intel.com> wrote:
> > > > > Hello everyone,
> > > > > 
> > > > > This set removes the struct fwnode_handle type field and constifies
> > > > > the
> > > > > fwnode arguments in the fwnode property API more or less the way
> > > > > they are
> > > > > const in OF property API.
> > > > > 
> > > > > Comments are welcome.
> > > > > 
> > > > > All the dependent patches are now in linux-pm master branch.
> > > > > 
> > > > > <URL:http://www.spinics.net/lists/linux-acpi/msg75957.html>;
> > > > > 
> > > > > v1 can be found here:
> > > > > 
> > > > > <URL:http://www.spinics.net/lists/linux-acpi/msg74564.html>;
> > > > > 
> > > > > changes since v2:
> > > > > 
> > > > > - Add 8th patch "device property: Introduce
> > > > >   fwnode_property_get_reference_args". This allows obtaining
> > > > > references
> > > > >   with integer arguments using the fwnode interface.
> > > > > 
> > > > >   The functionality will be soon needed in adding support for nvmem
> > > > >   framework on ACPI as well as in referring to e.g. lens and flash
> > > > > devices
> > > > >   on V4L2.
> > > > 
> > > > OK, so if people have no objections, I'll queue this up for 4.14.
> > > 
> > > I have no objections.
> > > 
> > > One comment Sakari already has addressed, another one
> > > (list_first_enatry_or_null() use) might be addressed later.
> > 
> > Cool, thanks!
> 
> So the series have been applied.

Thanks a lot!

I see this is in the linux-next branch now; the device-properties branch
seems to be in its former state still. Is there a chance that you have
merged it locally but not pushed the new device-properties branch?

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments
  2017-08-08  9:32             ` Sakari Ailus
@ 2017-08-09  0:53               ` Rafael J. Wysocki
  2017-08-09  8:47                 ` Sakari Ailus
  0 siblings, 1 reply; 23+ messages in thread
From: Rafael J. Wysocki @ 2017-08-09  0:53 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Andy Shevchenko, Sakari Ailus, Rafael J. Wysocki,
	ACPI Devel Maling List, devicetree, Sudeep Holla,
	Lorenzo Pieralisi, Mika Westerberg, Mark Rutland, Mark Brown,
	Rob Herring, Al Stone, Frank Rowand, erik.veijola

On Tuesday, August 8, 2017 11:32:16 AM CEST Sakari Ailus wrote:
> On Mon, Jul 24, 2017 at 10:28:12PM +0200, Rafael J. Wysocki wrote:
> > On Friday, July 21, 2017 02:29:06 PM Rafael J. Wysocki wrote:
> > > On Friday, July 21, 2017 03:33:09 PM Andy Shevchenko wrote:
> > > > On Fri, 2017-07-21 at 13:52 +0200, Rafael J. Wysocki wrote:
> > > > > On Fri, Jul 21, 2017 at 1:39 PM, Sakari Ailus
> > > > > <sakari.ailus@linux.intel.com> wrote:
> > > > > > Hello everyone,
> > > > > > 
> > > > > > This set removes the struct fwnode_handle type field and constifies
> > > > > > the
> > > > > > fwnode arguments in the fwnode property API more or less the way
> > > > > > they are
> > > > > > const in OF property API.
> > > > > > 
> > > > > > Comments are welcome.
> > > > > > 
> > > > > > All the dependent patches are now in linux-pm master branch.
> > > > > > 
> > > > > > <URL:http://www.spinics.net/lists/linux-acpi/msg75957.html>;
> > > > > > 
> > > > > > v1 can be found here:
> > > > > > 
> > > > > > <URL:http://www.spinics.net/lists/linux-acpi/msg74564.html>;
> > > > > > 
> > > > > > changes since v2:
> > > > > > 
> > > > > > - Add 8th patch "device property: Introduce
> > > > > >   fwnode_property_get_reference_args". This allows obtaining
> > > > > > references
> > > > > >   with integer arguments using the fwnode interface.
> > > > > > 
> > > > > >   The functionality will be soon needed in adding support for nvmem
> > > > > >   framework on ACPI as well as in referring to e.g. lens and flash
> > > > > > devices
> > > > > >   on V4L2.
> > > > > 
> > > > > OK, so if people have no objections, I'll queue this up for 4.14.
> > > > 
> > > > I have no objections.
> > > > 
> > > > One comment Sakari already has addressed, another one
> > > > (list_first_enatry_or_null() use) might be addressed later.
> > > 
> > > Cool, thanks!
> > 
> > So the series have been applied.
> 
> Thanks a lot!
> 
> I see this is in the linux-next branch now; the device-properties branch
> seems to be in its former state still. Is there a chance that you have
> merged it locally but not pushed the new device-properties branch?

The branch is only local for the time being, but I can push it out if
that helps.

Thanks,
Rafael


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments
  2017-08-09  0:53               ` Rafael J. Wysocki
@ 2017-08-09  8:47                 ` Sakari Ailus
  2017-08-09  8:50                   ` Sakari Ailus
  0 siblings, 1 reply; 23+ messages in thread
From: Sakari Ailus @ 2017-08-09  8:47 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Andy Shevchenko, Sakari Ailus, Rafael J. Wysocki,
	ACPI Devel Maling List, devicetree, Sudeep Holla,
	Lorenzo Pieralisi, Mika Westerberg, Mark Rutland, Mark Brown,
	Rob Herring, Al Stone, Frank Rowand, erik.veijola

On Wed, Aug 09, 2017 at 02:53:25AM +0200, Rafael J. Wysocki wrote:
> On Tuesday, August 8, 2017 11:32:16 AM CEST Sakari Ailus wrote:
> > On Mon, Jul 24, 2017 at 10:28:12PM +0200, Rafael J. Wysocki wrote:
> > > On Friday, July 21, 2017 02:29:06 PM Rafael J. Wysocki wrote:
> > > > On Friday, July 21, 2017 03:33:09 PM Andy Shevchenko wrote:
> > > > > On Fri, 2017-07-21 at 13:52 +0200, Rafael J. Wysocki wrote:
> > > > > > On Fri, Jul 21, 2017 at 1:39 PM, Sakari Ailus
> > > > > > <sakari.ailus@linux.intel.com> wrote:
> > > > > > > Hello everyone,
> > > > > > > 
> > > > > > > This set removes the struct fwnode_handle type field and constifies
> > > > > > > the
> > > > > > > fwnode arguments in the fwnode property API more or less the way
> > > > > > > they are
> > > > > > > const in OF property API.
> > > > > > > 
> > > > > > > Comments are welcome.
> > > > > > > 
> > > > > > > All the dependent patches are now in linux-pm master branch.
> > > > > > > 
> > > > > > > <URL:http://www.spinics.net/lists/linux-acpi/msg75957.html>;
> > > > > > > 
> > > > > > > v1 can be found here:
> > > > > > > 
> > > > > > > <URL:http://www.spinics.net/lists/linux-acpi/msg74564.html>;
> > > > > > > 
> > > > > > > changes since v2:
> > > > > > > 
> > > > > > > - Add 8th patch "device property: Introduce
> > > > > > >   fwnode_property_get_reference_args". This allows obtaining
> > > > > > > references
> > > > > > >   with integer arguments using the fwnode interface.
> > > > > > > 
> > > > > > >   The functionality will be soon needed in adding support for nvmem
> > > > > > >   framework on ACPI as well as in referring to e.g. lens and flash
> > > > > > > devices
> > > > > > >   on V4L2.
> > > > > > 
> > > > > > OK, so if people have no objections, I'll queue this up for 4.14.
> > > > > 
> > > > > I have no objections.
> > > > > 
> > > > > One comment Sakari already has addressed, another one
> > > > > (list_first_enatry_or_null() use) might be addressed later.
> > > > 
> > > > Cool, thanks!
> > > 
> > > So the series have been applied.
> > 
> > Thanks a lot!
> > 
> > I see this is in the linux-next branch now; the device-properties branch
> > seems to be in its former state still. Is there a chance that you have
> > merged it locally but not pushed the new device-properties branch?
> 
> The branch is only local for the time being, but I can push it out if
> that helps.

I have V4L2 patches that depend on these --- I'd like to attempt to get
them in through the mediatree during this merge window.

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments
  2017-08-09  8:47                 ` Sakari Ailus
@ 2017-08-09  8:50                   ` Sakari Ailus
  2017-08-09 23:27                     ` Rafael J. Wysocki
  0 siblings, 1 reply; 23+ messages in thread
From: Sakari Ailus @ 2017-08-09  8:50 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Andy Shevchenko, Sakari Ailus, Rafael J. Wysocki,
	ACPI Devel Maling List, devicetree, Sudeep Holla,
	Lorenzo Pieralisi, Mika Westerberg, Mark Rutland, Mark Brown,
	Rob Herring, Al Stone, Frank Rowand, erik.veijola

On Wed, Aug 09, 2017 at 11:47:55AM +0300, Sakari Ailus wrote:
> On Wed, Aug 09, 2017 at 02:53:25AM +0200, Rafael J. Wysocki wrote:
> > On Tuesday, August 8, 2017 11:32:16 AM CEST Sakari Ailus wrote:
> > > On Mon, Jul 24, 2017 at 10:28:12PM +0200, Rafael J. Wysocki wrote:
> > > > On Friday, July 21, 2017 02:29:06 PM Rafael J. Wysocki wrote:
> > > > > On Friday, July 21, 2017 03:33:09 PM Andy Shevchenko wrote:
> > > > > > On Fri, 2017-07-21 at 13:52 +0200, Rafael J. Wysocki wrote:
> > > > > > > On Fri, Jul 21, 2017 at 1:39 PM, Sakari Ailus
> > > > > > > <sakari.ailus@linux.intel.com> wrote:
> > > > > > > > Hello everyone,
> > > > > > > > 
> > > > > > > > This set removes the struct fwnode_handle type field and constifies
> > > > > > > > the
> > > > > > > > fwnode arguments in the fwnode property API more or less the way
> > > > > > > > they are
> > > > > > > > const in OF property API.
> > > > > > > > 
> > > > > > > > Comments are welcome.
> > > > > > > > 
> > > > > > > > All the dependent patches are now in linux-pm master branch.
> > > > > > > > 
> > > > > > > > <URL:http://www.spinics.net/lists/linux-acpi/msg75957.html>;
> > > > > > > > 
> > > > > > > > v1 can be found here:
> > > > > > > > 
> > > > > > > > <URL:http://www.spinics.net/lists/linux-acpi/msg74564.html>;
> > > > > > > > 
> > > > > > > > changes since v2:
> > > > > > > > 
> > > > > > > > - Add 8th patch "device property: Introduce
> > > > > > > >   fwnode_property_get_reference_args". This allows obtaining
> > > > > > > > references
> > > > > > > >   with integer arguments using the fwnode interface.
> > > > > > > > 
> > > > > > > >   The functionality will be soon needed in adding support for nvmem
> > > > > > > >   framework on ACPI as well as in referring to e.g. lens and flash
> > > > > > > > devices
> > > > > > > >   on V4L2.
> > > > > > > 
> > > > > > > OK, so if people have no objections, I'll queue this up for 4.14.
> > > > > > 
> > > > > > I have no objections.
> > > > > > 
> > > > > > One comment Sakari already has addressed, another one
> > > > > > (list_first_enatry_or_null() use) might be addressed later.
> > > > > 
> > > > > Cool, thanks!
> > > > 
> > > > So the series have been applied.
> > > 
> > > Thanks a lot!
> > > 
> > > I see this is in the linux-next branch now; the device-properties branch
> > > seems to be in its former state still. Is there a chance that you have
> > > merged it locally but not pushed the new device-properties branch?
> > 
> > The branch is only local for the time being, but I can push it out if
> > that helps.
> 
> I have V4L2 patches that depend on these --- I'd like to attempt to get
> them in through the mediatree during this merge window.

Or rather to the mediatree before the next merge window opens.

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments
  2017-08-09  8:50                   ` Sakari Ailus
@ 2017-08-09 23:27                     ` Rafael J. Wysocki
  0 siblings, 0 replies; 23+ messages in thread
From: Rafael J. Wysocki @ 2017-08-09 23:27 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Andy Shevchenko, Sakari Ailus, Rafael J. Wysocki,
	ACPI Devel Maling List, devicetree, Sudeep Holla,
	Lorenzo Pieralisi, Mika Westerberg, Mark Rutland, Mark Brown,
	Rob Herring, Al Stone, Frank Rowand, erik.veijola

On Wednesday, August 9, 2017 10:50:29 AM CEST Sakari Ailus wrote:
> On Wed, Aug 09, 2017 at 11:47:55AM +0300, Sakari Ailus wrote:
> > On Wed, Aug 09, 2017 at 02:53:25AM +0200, Rafael J. Wysocki wrote:
> > > On Tuesday, August 8, 2017 11:32:16 AM CEST Sakari Ailus wrote:
> > > > On Mon, Jul 24, 2017 at 10:28:12PM +0200, Rafael J. Wysocki wrote:
> > > > > On Friday, July 21, 2017 02:29:06 PM Rafael J. Wysocki wrote:
> > > > > > On Friday, July 21, 2017 03:33:09 PM Andy Shevchenko wrote:
> > > > > > > On Fri, 2017-07-21 at 13:52 +0200, Rafael J. Wysocki wrote:
> > > > > > > > On Fri, Jul 21, 2017 at 1:39 PM, Sakari Ailus
> > > > > > > > <sakari.ailus@linux.intel.com> wrote:
> > > > > > > > > Hello everyone,
> > > > > > > > > 
> > > > > > > > > This set removes the struct fwnode_handle type field and constifies
> > > > > > > > > the
> > > > > > > > > fwnode arguments in the fwnode property API more or less the way
> > > > > > > > > they are
> > > > > > > > > const in OF property API.
> > > > > > > > > 
> > > > > > > > > Comments are welcome.
> > > > > > > > > 
> > > > > > > > > All the dependent patches are now in linux-pm master branch.
> > > > > > > > > 
> > > > > > > > > <URL:http://www.spinics.net/lists/linux-acpi/msg75957.html>;
> > > > > > > > > 
> > > > > > > > > v1 can be found here:
> > > > > > > > > 
> > > > > > > > > <URL:http://www.spinics.net/lists/linux-acpi/msg74564.html>;
> > > > > > > > > 
> > > > > > > > > changes since v2:
> > > > > > > > > 
> > > > > > > > > - Add 8th patch "device property: Introduce
> > > > > > > > >   fwnode_property_get_reference_args". This allows obtaining
> > > > > > > > > references
> > > > > > > > >   with integer arguments using the fwnode interface.
> > > > > > > > > 
> > > > > > > > >   The functionality will be soon needed in adding support for nvmem
> > > > > > > > >   framework on ACPI as well as in referring to e.g. lens and flash
> > > > > > > > > devices
> > > > > > > > >   on V4L2.
> > > > > > > > 
> > > > > > > > OK, so if people have no objections, I'll queue this up for 4.14.
> > > > > > > 
> > > > > > > I have no objections.
> > > > > > > 
> > > > > > > One comment Sakari already has addressed, another one
> > > > > > > (list_first_enatry_or_null() use) might be addressed later.
> > > > > > 
> > > > > > Cool, thanks!
> > > > > 
> > > > > So the series have been applied.
> > > > 
> > > > Thanks a lot!
> > > > 
> > > > I see this is in the linux-next branch now; the device-properties branch
> > > > seems to be in its former state still. Is there a chance that you have
> > > > merged it locally but not pushed the new device-properties branch?
> > > 
> > > The branch is only local for the time being, but I can push it out if
> > > that helps.
> > 
> > I have V4L2 patches that depend on these --- I'd like to attempt to get
> > them in through the mediatree during this merge window.
> 
> Or rather to the mediatree before the next merge window opens.
> 

OK, pushed out now, thanks!



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2017-08-09 23:35 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-21 11:39 [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments Sakari Ailus
2017-07-21 11:39 ` [PATCH v3 2/8] device property: Get rid of struct fwnode_handle type field Sakari Ailus
2017-07-21 11:39 ` [PATCH v3 3/8] ACPI: Prepare for constifying acpi_get_next_subnode() fwnode argument Sakari Ailus
2017-07-21 12:30   ` Andy Shevchenko
     [not found] ` <1500637177-16095-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-07-21 11:39   ` [PATCH v3 1/8] ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in is_acpi_data_node Sakari Ailus
2017-07-21 11:59     ` Andy Shevchenko
2017-07-21 12:12       ` Andy Shevchenko
2017-07-21 11:39   ` [PATCH v3 4/8] ACPI: Constify acpi_bus helper functions, switch to macros Sakari Ailus
2017-07-21 11:52   ` [PATCH v3 0/8] Remove fwnode type field, constify property fwnode arguments Rafael J. Wysocki
2017-07-21 12:33     ` Andy Shevchenko
     [not found]       ` <1500640389.29303.177.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-07-21 12:29         ` Rafael J. Wysocki
2017-07-24 20:28           ` Rafael J. Wysocki
2017-08-08  9:32             ` Sakari Ailus
2017-08-09  0:53               ` Rafael J. Wysocki
2017-08-09  8:47                 ` Sakari Ailus
2017-08-09  8:50                   ` Sakari Ailus
2017-08-09 23:27                     ` Rafael J. Wysocki
2017-07-21 11:39 ` [PATCH v3 5/8] ACPI: Constify internal " Sakari Ailus
2017-07-21 11:39 ` [PATCH v3 6/8] device property: Constify argument to pset fwnode backend Sakari Ailus
2017-07-21 11:39 ` [PATCH v3 7/8] device property: Constify fwnode property API Sakari Ailus
2017-07-21 11:39 ` [PATCH v3 8/8] device property: Introduce fwnode_property_get_reference_args Sakari Ailus
     [not found]   ` <1500637177-16095-9-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-07-21 12:06     ` Andy Shevchenko
2017-07-21 12:11   ` [PATCH v3.1 " Sakari Ailus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.