Skip to contentSkip to conversation

Device property improvements, add %pfw format specifier

PATCH Superseded Sakari Ailus 5 participants 25 messages Mar 22, 2019 – Mar 28, 2019

Subsystems (8)

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Sakari Ailus

author reviewer
#0 lore raw

cover Device property improvements, add %pfw format specifier

Hi all,

This set adds functionality into the device property API (counting a node's parents as well as obtaining its name) in order to support printing fwnode names using a new conversion specifier "%pfw". The names that are produced are equivalent to its OF counterpart "%pOF" on OF systems for the two supported modifiers ("f" and "P").

Printing a node's name is something that's been available on OF for a long time and if something is converted to device property API (such as the V4L2 fwnode framework) it always got removed of a nice feature that was sometimes essential in debugging. With this set, that no longer is the case.

This set depends on a cleanup set fully releasing the now-deprecated %pf for other use:

<URL:https://lore.kernel.org/lkml/[email protected]/T/#t>

I was a bit hesitant on how much of this should be covered by the fwnode ops and how much would be just better to reside in lib/vsprintf.c, but opted for putting it to the fwnode interface. This keeps it clean and still rather lean on the fwnode ops side while making it possible to add other firmware types (although that is unlikely I guess).

Sakari Ailus (5):
device property: Add functions for accessing node's parents device property: Add fwnode_get_name for returning the name of a node device property: Add a function to obtain a node's prefix lib/vsprintf: Make use of fwnode API to obtain node names and
separators
lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

 Documentation/core-api/printk-formats.rst | 24 +++++++++
 drivers/acpi/property.c                   | 46 ++++++++++++++++
 drivers/base/property.c                   | 86 ++++++++++++++++++++++++++---
 drivers/of/property.c                     | 16 ++++++
 include/linux/fwnode.h                    |  4 ++
 include/linux/property.h                  |  5 ++
 lib/vsprintf.c                            | 89 +++++++++++++++++++++++--------
 scripts/checkpatch.pl                     |  2 +-
 8 files changed, 242 insertions(+), 30 deletions(-)
Signature · 1 line
2.11.0
author reviewer
#1 lore raw

PATCH 1/5 device property: Add functions for accessing node's parents

Add two convenience functions for accessing node's parents:

fwnode_count_parents() returns the number of parent nodes a given node has. fwnode_get_nth_parent() returns node's parent at a given distance from the node itself.

Also reorder fwnode_get_parent() in property.c according to the same order as in property.h.

---
 drivers/base/property.c  | 61 ++++++++++++++++++++++++++++++++++++++++++------
 include/linux/property.h |  3 +++
 2 files changed, 57 insertions(+), 7 deletions(-)
drivers/base/property.c +54 -7
index 8b91ab380d14..3f5ff6b23ae4 100644
@@ -533,6 +533,19 @@ int device_add_properties(struct device *dev,
 EXPORT_SYMBOL_GPL(device_add_properties);
 
 /**
+ * fwnode_get_parent - Return parent firwmare node
+ * @fwnode: Firmware whose parent is retrieved
+ *
+ * Return parent firmware node of the given node if possible or %NULL if no
+ * parent was available.
+ */
+struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode)
+{
+	return fwnode_call_ptr_op(fwnode, get_parent);
+}
+EXPORT_SYMBOL_GPL(fwnode_get_parent);
+
+/**
  * fwnode_get_next_parent - Iterate to the node's parent
  * @fwnode: Firmware whose parent is retrieved
  *
@@ -554,17 +567,51 @@ struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode)
 EXPORT_SYMBOL_GPL(fwnode_get_next_parent);
 
 /**
- * fwnode_get_parent - Return parent firwmare node
- * @fwnode: Firmware whose parent is retrieved
+ * fwnode_count_parents - Return the number of parents a node has
  *
- * Return parent firmware node of the given node if possible or %NULL if no
- * parent was available.
+ * @fwnode: The node the parents of which are to be counted
+ *
+ * Returns the number of parents a node has.
  */
-struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode)
+unsigned int fwnode_count_parents(struct fwnode_handle *fwnode)
 {
-	return fwnode_call_ptr_op(fwnode, get_parent);
+	unsigned int count;
+
+	fwnode_handle_get(fwnode);
+
+	for (count = 0; fwnode; count++)
+		fwnode = fwnode_get_next_parent(fwnode);
+
+	return count - 1;
 }
-EXPORT_SYMBOL_GPL(fwnode_get_parent);
+EXPORT_SYMBOL_GPL(fwnode_count_parents);
+
+/**
+ * fwnode_get_nth_parent - Return an nth parent of a node
+ *
+ * @fwnode: The node the parent of which is requested
+ * @depth: Distance of the parent from the node
+ *
+ * Returns the nth parent of a node. If @depth is 0, the functionality is
+ * equivalent to fwnode_handle_get(). For @depth == 1, it is fwnode_get_parent()
+ * and so on.
+ *
+ * The caller is responsible for calling fwnode_handle_put() for the returned
+ * node.
+ */
+struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwnode,
+					    unsigned int depth)
+{
+	unsigned int i;
+
+	fwnode_handle_get(fwnode);
+
+	for (i = 0; i < depth && fwnode; i++)
+		fwnode = fwnode_get_next_parent(fwnode);
+
+	return fwnode;
+}
+EXPORT_SYMBOL_GPL(fwnode_get_nth_parent);
 
 /**
  * fwnode_get_next_child_node - Return the next child node handle for a node
include/linux/property.h +3 -0
index 65d3420dd5d1..1164ac974ee8 100644
@@ -81,6 +81,9 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
 struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_get_next_parent(
 	struct fwnode_handle *fwnode);
+unsigned int fwnode_count_parents(struct fwnode_handle *fwn);
+struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwn,
+					    unsigned int depth);
 struct fwnode_handle *fwnode_get_next_child_node(
 	const struct fwnode_handle *fwnode, struct fwnode_handle *child);
 struct fwnode_handle *fwnode_get_next_available_child_node(
Signature · 1 line
2.11.0
author reviewer
#2 lore raw

PATCH 2/5 device property: Add fwnode_get_name for returning the name of a node

In reply to Sakari Ailus

The fwnode framework did not have means to obtain the name of a node. Add that now, in form of the fwnode_get_name() function and a corresponding get_name fwnode op. OF and ACPI support is included.

---
 drivers/acpi/property.c  | 24 ++++++++++++++++++++++++
 drivers/base/property.c  | 12 ++++++++++++
 drivers/of/property.c    |  6 ++++++
 include/linux/fwnode.h   |  2 ++
 include/linux/property.h |  1 +
 5 files changed, 45 insertions(+)
drivers/acpi/property.c +24 -0
index 77abe0ec4043..8c9a4c02cde2 100644
@@ -1291,6 +1291,29 @@ acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
 						  args_count, args);
 }
 
+static const char *acpi_fwnode_get_name(const struct fwnode_handle *fwnode)
+{
+	const struct acpi_device *adev;
+	struct fwnode_handle *parent;
+
+	parent = fwnode_get_parent(fwnode);
+	/* Is this the root node? */
+	if (!parent)
+		return "\\";
+
+	fwnode_handle_put(parent);
+
+	if (is_acpi_data_node(fwnode)) {
+		const struct acpi_data_node *dn = to_acpi_data_node(fwnode);
+
+		return dn->name;
+	}
+
+	adev = to_acpi_device_node(fwnode);
+
+	return adev ? acpi_device_bid(adev) : NULL;
+}
+
 static struct fwnode_handle *
 acpi_fwnode_get_parent(struct fwnode_handle *fwnode)
 {
@@ -1331,6 +1354,7 @@ acpi_fwnode_device_get_match_data(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_name = acpi_fwnode_get_name,			\
 		.get_reference_args = acpi_fwnode_get_reference_args,	\
 		.graph_get_next_endpoint =				\
 			acpi_graph_get_next_endpoint,			\
drivers/base/property.c +12 -0
index 3f5ff6b23ae4..7ee3786bcde3 100644
@@ -533,6 +533,18 @@ int device_add_properties(struct device *dev,
 EXPORT_SYMBOL_GPL(device_add_properties);
 
 /**
+ * fwnode_get_name - Return the name of a node
+ *
+ * @fwnode - The firmware node
+ *
+ * Returns a pointer to the node name.
+ */
+const char *fwnode_get_name(const struct fwnode_handle *fwnode)
+{
+	return fwnode_call_ptr_op(fwnode, get_name);
+}
+
+/**
  * fwnode_get_parent - Return parent firwmare node
  * @fwnode: Firmware whose parent is retrieved
  *
drivers/of/property.c +6 -0
index 8631efa1daa1..f0a7b78f2d9f 100644
@@ -872,6 +872,11 @@ of_fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
 		of_property_count_strings(node, propname);
 }
 
+static const char *of_fwnode_get_name(const struct fwnode_handle *fwnode)
+{
+	return kbasename(to_of_node(fwnode)->full_name);
+}
+
 static struct fwnode_handle *
 of_fwnode_get_parent(const struct fwnode_handle *fwnode)
 {
@@ -993,6 +998,7 @@ const struct fwnode_operations of_fwnode_ops = {
 	.property_present = of_fwnode_property_present,
 	.property_read_int_array = of_fwnode_property_read_int_array,
 	.property_read_string_array = of_fwnode_property_read_string_array,
+	.get_name = of_fwnode_get_name,
 	.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,
include/linux/fwnode.h +2 -0
index faebf0ca0686..85b7fa4dc727 100644
@@ -59,6 +59,7 @@ struct fwnode_reference_args {
  *				 otherwise.
  * @property_read_string_array: Read an array of string properties. Return zero
  *				on success, a negative error code otherwise.
+ * @get_name: Return the name of an fwnode.
  * @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.
@@ -85,6 +86,7 @@ struct fwnode_operations {
 	(*property_read_string_array)(const struct fwnode_handle *fwnode_handle,
 				      const char *propname, const char **val,
 				      size_t nval);
+	const char *(*get_name)(const struct fwnode_handle *fwnode);
 	struct fwnode_handle *(*get_parent)(const struct fwnode_handle *fwnode);
 	struct fwnode_handle *
 	(*get_next_child_node)(const struct fwnode_handle *fwnode,
include/linux/property.h +1 -0
index 1164ac974ee8..2f5df900e310 100644
@@ -78,6 +78,7 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
 				       unsigned int nargs, unsigned int index,
 				       struct fwnode_reference_args *args);
 
+const char *fwnode_get_name(const struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_get_next_parent(
 	struct fwnode_handle *fwnode);
Signature · 1 line
2.11.0
reviewer
#3 lore raw

Re: [PATCH 2/5] device property: Add fwnode_get_name for returning the name of a node

Hi,

drivers/base/property.c int device_add_properties(struct device *dev, · line 538

Quoted 11 lines · Sakari Ailus
drivers/base/property.c +3 -0
index 3f5ff6b23ae4..7ee3786bcde3 100644
@@ -533,6 +533,18 @@ int device_add_properties(struct device *dev,
 EXPORT_SYMBOL_GPL(device_add_properties);
 
 /**
+ * fwnode_get_name - Return the name of a node
+ *
+ * @fwnode - The firmware node

s/-/:/

Quoted 12 lines
drivers/base/property.c +9 -0
+ *
+ * Returns a pointer to the node name.
+ */
+const char *fwnode_get_name(const struct fwnode_handle *fwnode)
+{
+	return fwnode_call_ptr_op(fwnode, get_name);
+}
+
+/**
  * fwnode_get_parent - Return parent firwmare node
  * @fwnode: Firmware whose parent is retrieved
  *
Signature · 1 line
~Randy
author reviewer
#4 lore raw

Re: [PATCH 2/5] device property: Add fwnode_get_name for returning the name of a node

Hi Randy,

Quoted 3 lines · Randy Dunlap
Quoted 1 line

+ * @fwnode - The firmware node

s/-/:/

Yes, indeed.

Thanks!

Signature · 2 lines
Sakari Ailus
[email protected]
author reviewer
#5 lore raw

PATCH 3/5 device property: Add a function to obtain a node's prefix

In reply to Sakari Ailus

The prefix is used for printing purpose before a node, and it also works as a separator between two nodes.

---
 drivers/acpi/property.c  | 22 ++++++++++++++++++++++
 drivers/base/property.c  | 13 +++++++++++++
 drivers/of/property.c    | 10 ++++++++++
 include/linux/fwnode.h   |  2 ++
 include/linux/property.h |  1 +
 5 files changed, 48 insertions(+)
drivers/acpi/property.c +22 -0
index 8c9a4c02cde2..c167fd748f86 100644
@@ -1314,6 +1314,27 @@ static const char *acpi_fwnode_get_name(const struct fwnode_handle *fwnode)
 	return adev ? acpi_device_bid(adev) : NULL;
 }
 
+static const char *
+acpi_fwnode_get_name_prefix(const struct fwnode_handle *fwnode)
+{
+	struct fwnode_handle *parent;
+
+	parent = fwnode_get_parent(fwnode);
+	/* Root node. */
+	if (!parent)
+		return "";
+
+	parent = fwnode_get_next_parent(parent);
+	/* Second node from the root; no prefix here either. */
+	if (!parent)
+		return "";
+
+	fwnode_handle_put(parent);
+
+	/* ACPI device or data node. */
+	return ".";
+}
+
 static struct fwnode_handle *
 acpi_fwnode_get_parent(struct fwnode_handle *fwnode)
 {
@@ -1355,6 +1376,7 @@ acpi_fwnode_device_get_match_data(const struct fwnode_handle *fwnode,
 		.get_next_child_node = acpi_get_next_subnode,		\
 		.get_named_child_node = acpi_fwnode_get_named_child_node, \
 		.get_name = acpi_fwnode_get_name,			\
+		.get_name_prefix = acpi_fwnode_get_name_prefix,		\
 		.get_reference_args = acpi_fwnode_get_reference_args,	\
 		.graph_get_next_endpoint =				\
 			acpi_graph_get_next_endpoint,			\
drivers/base/property.c +13 -0
index 7ee3786bcde3..68b74e53864b 100644
@@ -545,6 +545,19 @@ const char *fwnode_get_name(const struct fwnode_handle *fwnode)
 }
 
 /**
+ * fwnode_get_name_prefix - Return the prefix of node for printing purposes
+ *
+ * @fwnode: The firmware node
+ *
+ * Returns the prefix of a node, intended to be printed right before the node.
+ * The prefix works also as a separator between the nodes.
+ */
+const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode)
+{
+	return fwnode_call_ptr_op(fwnode, get_name_prefix);
+}
+
+/**
  * fwnode_get_parent - Return parent firwmare node
  * @fwnode: Firmware whose parent is retrieved
  *
drivers/of/property.c +10 -0
index f0a7b78f2d9f..8fed3b142b41 100644
@@ -877,6 +877,15 @@ static const char *of_fwnode_get_name(const struct fwnode_handle *fwnode)
 	return kbasename(to_of_node(fwnode)->full_name);
 }
 
+static const char *of_fwnode_get_name_prefix(const struct fwnode_handle *fwnode)
+{
+	/* Root needs no prefix here (its name is "/"). */
+	if (!to_of_node(fwnode)->parent)
+		return "";
+
+	return "/";
+}
+
 static struct fwnode_handle *
 of_fwnode_get_parent(const struct fwnode_handle *fwnode)
 {
@@ -999,6 +1008,7 @@ const struct fwnode_operations of_fwnode_ops = {
 	.property_read_int_array = of_fwnode_property_read_int_array,
 	.property_read_string_array = of_fwnode_property_read_string_array,
 	.get_name = of_fwnode_get_name,
+	.get_name_prefix = of_fwnode_get_name_prefix,
 	.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,
include/linux/fwnode.h +2 -0
index 85b7fa4dc727..592ac6936e14 100644
@@ -60,6 +60,7 @@ struct fwnode_reference_args {
  * @property_read_string_array: Read an array of string properties. Return zero
  *				on success, a negative error code otherwise.
  * @get_name: Return the name of an fwnode.
+ * @get_name_prefix: Get a prefix for a node (for printing purposes).
  * @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.
@@ -87,6 +88,7 @@ struct fwnode_operations {
 				      const char *propname, const char **val,
 				      size_t nval);
 	const char *(*get_name)(const struct fwnode_handle *fwnode);
+	const char *(*get_name_prefix)(const struct fwnode_handle *fwnode);
 	struct fwnode_handle *(*get_parent)(const struct fwnode_handle *fwnode);
 	struct fwnode_handle *
 	(*get_next_child_node)(const struct fwnode_handle *fwnode,
include/linux/property.h +1 -0
index 2f5df900e310..0ea466ee8c3d 100644
@@ -79,6 +79,7 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
 				       struct fwnode_reference_args *args);
 
 const char *fwnode_get_name(const struct fwnode_handle *fwnode);
+const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_get_next_parent(
 	struct fwnode_handle *fwnode);
Signature · 1 line
2.11.0
author reviewer
#6 lore raw

PATCH 4/5 lib/vsprintf: Make use of fwnode API to obtain node names and separators

In reply to Sakari Ailus

Instead of implementing our own means of discovering parent nodes, node names or counting how many parents a node has, use the newly added functions in the fwnode API to obtain that information.

---
 lib/vsprintf.c | 37 +++++++++++++++----------------------
 1 file changed, 15 insertions(+), 22 deletions(-)
lib/vsprintf.c +15 -22
index 5f60b8d41277..91f2a3e4892e 100644
@@ -37,6 +37,7 @@
 #include <net/addrconf.h>
 #include <linux/siphash.h>
 #include <linux/compiler.h>
+#include <linux/property.h>
 #ifdef CONFIG_BLOCK
 #include <linux/blkdev.h>
 #endif
@@ -1720,32 +1721,23 @@ char *flags_string(char *buf, char *end, void *flags_ptr, const char *fmt)
 	return format_flags(buf, end, flags, names);
 }
 
-static const char *device_node_name_for_depth(const struct device_node *np, int depth)
-{
-	for ( ; np && depth; depth--)
-		np = np->parent;
-
-	return kbasename(np->full_name);
-}
-
 static noinline_for_stack
-char *device_node_gen_full_name(const struct device_node *np, char *buf, char *end)
+char *fwnode_gen_full_name(struct fwnode_handle *fwnode, char *buf, char *end)
 {
 	int depth;
-	const struct device_node *parent = np->parent;
 
-	/* special case for root node */
-	if (!parent)
-		return string(buf, end, "/", default_str_spec);
+	for (depth = fwnode_count_parents(fwnode); depth >= 0; depth--) {
+		struct fwnode_handle *__fwnode =
+			fwnode_get_nth_parent(fwnode, depth);
 
-	for (depth = 0; parent->parent; depth++)
-		parent = parent->parent;
-
-	for ( ; depth >= 0; depth--) {
-		buf = string(buf, end, "/", default_str_spec);
-		buf = string(buf, end, device_node_name_for_depth(np, depth),
+		buf = string(buf, end, fwnode_get_name_prefix(__fwnode),
+			     default_str_spec);
+		buf = string(buf, end, fwnode_get_name(__fwnode),
 			     default_str_spec);
+
+		fwnode_handle_put(__fwnode);
 	}
+
 	return buf;
 }
 
@@ -1790,10 +1782,11 @@ char *device_node_string(char *buf, char *end, struct device_node *dn,
 
 		switch (*fmt) {
 		case 'f':	/* full_name */
-			buf = device_node_gen_full_name(dn, buf, end);
+			buf = fwnode_gen_full_name(of_fwnode_handle(dn), buf,
+						   end);
 			break;
 		case 'n':	/* name */
-			p = kbasename(of_node_full_name(dn));
+			p = fwnode_get_name(of_fwnode_handle(dn));
 			precision = str_spec.precision;
 			str_spec.precision = strchrnul(p, '@') - p;
 			buf = string(buf, end, p, str_spec);
@@ -1803,7 +1796,7 @@ char *device_node_string(char *buf, char *end, struct device_node *dn,
 			buf = number(buf, end, (unsigned int)dn->phandle, num_spec);
 			break;
 		case 'P':	/* path-spec */
-			p = kbasename(of_node_full_name(dn));
+			p = fwnode_get_name(of_fwnode_handle(dn));
 			if (!p[1])
 				p = "/";
 			buf = string(buf, end, p, str_spec);
Signature · 1 line
2.11.0
maintainer
#7 lore raw

Re: [PATCH 4/5] lib/vsprintf: Make use of fwnode API to obtain node names and separators

Quoted 26 lines · Sakari Ailus

Instead of implementing our own means of discovering parent nodes, node names or counting how many parents a node has, use the newly added functions in the fwnode API to obtain that information.

---
 lib/vsprintf.c | 37 +++++++++++++++----------------------
 1 file changed, 15 insertions(+), 22 deletions(-)
lib/vsprintf.c +1 -1
index 5f60b8d41277..91f2a3e4892e 100644
@@ -37,6 +37,7 @@
 #include <net/addrconf.h>
 #include <linux/siphash.h>
 #include <linux/compiler.h>
+#include <linux/property.h>
 #ifdef CONFIG_BLOCK
 #include <linux/blkdev.h>
 #endif
@@ -1720,32 +1721,23 @@ char *flags_string(char *buf, char *end, void *flags_ptr, const char *fmt)
 	return format_flags(buf, end, flags, names);
 }
 
-static const char *device_node_name_for_depth(const struct device_node *np, int depth)

lib/vsprintf.c char *flags_string(char *buf, char *end, void *flags_ptr, const char *fmt) · line 1725

Quoted 10 lines
lib/vsprintf.c +1 -8
-{
-	for ( ; np && depth; depth--)
-		np = np->parent;
-
-	return kbasename(np->full_name);
-}
-
 static noinline_for_stack
-char *device_node_gen_full_name(const struct device_node *np, char *buf, char *end)
+char *fwnode_gen_full_name(struct fwnode_handle *fwnode, char *buf, char *end)

I first read this as fwnode_get_full_name(), see "get" vs. "gen". I guess that it was because there is used also fwnode_get_name().

Please, rename it to fwnode_full_name_string() or so ;-)

Best Regards,
Petr

author reviewer
#8 lore raw

Re: [PATCH 4/5] lib/vsprintf: Make use of fwnode API to obtain node names and separators

Hi Petr,

Thank you for reviewing these patches.

Quoted 41 lines · Petr Mladek
Quoted 26 lines · Sakari Ailus

Instead of implementing our own means of discovering parent nodes, node names or counting how many parents a node has, use the newly added functions in the fwnode API to obtain that information.

---
 lib/vsprintf.c | 37 +++++++++++++++----------------------
 1 file changed, 15 insertions(+), 22 deletions(-)
lib/vsprintf.c +1 -1
index 5f60b8d41277..91f2a3e4892e 100644
@@ -37,6 +37,7 @@
 #include <net/addrconf.h>
 #include <linux/siphash.h>
 #include <linux/compiler.h>
+#include <linux/property.h>
 #ifdef CONFIG_BLOCK
 #include <linux/blkdev.h>
 #endif
@@ -1720,32 +1721,23 @@ char *flags_string(char *buf, char *end, void *flags_ptr, const char *fmt)
 	return format_flags(buf, end, flags, names);
 }
 
-static const char *device_node_name_for_depth(const struct device_node *np, int depth)

lib/vsprintf.c char *flags_string(char *buf, char *end, void *flags_ptr, const char *fmt) · line 1725

Quoted 10 lines
lib/vsprintf.c +1 -8
-{
-	for ( ; np && depth; depth--)
-		np = np->parent;
-
-	return kbasename(np->full_name);
-}
-
 static noinline_for_stack
-char *device_node_gen_full_name(const struct device_node *np, char *buf, char *end)
+char *fwnode_gen_full_name(struct fwnode_handle *fwnode, char *buf, char *end)

I first read this as fwnode_get_full_name(), see "get" vs. "gen". I guess that it was because there is used also fwnode_get_name().

Quoted 1 line

Please, rename it to fwnode_full_name_string() or so ;-)

Works for me.

Signature · 4 lines
Regards,

Sakari Ailus
[email protected]
author reviewer
#9 lore raw

PATCH 5/5 lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

In reply to Sakari Ailus

Add support for %pfw conversion specifier (with "f" and "P" modifiers) to support printing full path of the node, including its name ("f") and only the node's name ("P") in the printk family of functions. The two flags have equivalent functionality to existing %pOF with the same two modifiers ("f" and "P") on OF based systems. The ability to do the same on ACPI based systems is added by this patch.

On ACPI based systems the resulting strings look like

	\[email protected]@0

where the nodes are separated by a dot (".") and the first three are ACPI device nodes and the latter two ACPI data nodes.

Depends-on: ("vsprintf: Remove support for %pF and %pf in favour of %pS and %ps")

---
 Documentation/core-api/printk-formats.rst | 24 ++++++++++++++
 lib/vsprintf.c                            | 52 +++++++++++++++++++++++++++++++
 scripts/checkpatch.pl                     |  2 +-
 3 files changed, 77 insertions(+), 1 deletion(-)
Documentation/core-api/printk-formats.rst +24 -0
index c90826a1ff17..209625e0c61d 100644
@@ -410,6 +410,30 @@ Examples::
 
 Passed by reference.
 
+Fwnode handles
+--------------
+
+::
+
+	%pfw[fP]
+
+For printing information on fwnode handles. The default is to print the full
+node name, including the path. The modifiers are functionally equivalent to
+%pOF above.
+
+	- f - full name of the node, including the path
+	- P - the name of the node including an address (if there is one)
+
+Examples (ACPI):
+
+	%pfwf	\[email protected]@0	- Full node name
+	%pfwP	endpoint@0				- Node name
+
+Examples (OF):
+
+	%pfwf	/ocp@68000000/i2c@48072000/camera@10/port/endpoint - Full name
+	%pfwP	endpoint				- Node name
+
 Time and date (struct rtc_time)
 -------------------------------
 
lib/vsprintf.c +52 -0

70 lines not on this page · raw message

scripts/checkpatch.pl +1 -1
index b4e456b48fd7..10db4354d61b 100755
@@ -5977,7 +5977,7 @@ sub process {
 				while ($fmt =~ /(\%[\*\d\.]*p(\w))/g) {
 					$specifier = $1;
 					$extension = $2;
-					if ($extension !~ /[SsBKRraEhMmIiUDdgVCbGNOx]/) {
+					if ($extension !~ /[SsBKRraEhMmIiUDdgVCbGNOxf]/) {
 						$bad_specifier = $specifier;
 						last;
 					}
Signature · 1 line
2.11.0
#10 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

Quoted 6 lines · Sakari Ailus

Add support for %pfw conversion specifier (with "f" and "P" modifiers) to support printing full path of the node, including its name ("f") and only the node's name ("P") in the printk family of functions. The two flags have equivalent functionality to existing %pOF with the same two modifiers ("f" and "P") on OF based systems. The ability to do the same on ACPI based systems is added by this patch.

Do we encourage people to use it instead of %pOF cases where it is suitable?

Quoted 6 lines

On ACPI based systems the resulting strings look like

	\[email protected]@0

where the nodes are separated by a dot (".") and the first three are ACPI device nodes and the latter two ACPI data nodes.

Do we support swnode here?

Quoted 4 lines
lib/vsprintf.c +4 -0
+static noinline_for_stack
+char *fwnode_string(char *buf, char *end, struct fwnode_handle *fwnode,
+		    struct printf_spec spec, const char *fmt)
+{

lib/vsprintf.c char *device_node_string(char *buf, char *end, struct device_node *dn, · line 1849

Quoted 10 lines
lib/vsprintf.c +9 -0
+	const char * const modifiers = "fP";
+	struct printf_spec str_spec = spec;
+	char *buf_start = buf;
+	bool pass;
+
+	str_spec.field_width = -1;
+
 
+	if ((unsigned long)fwnode < PAGE_SIZE)
+		return string(buf, end, "(null)", spec);

Just put there a NULL pointer, we would not like to maintain duplicated strings over the kernel.

I remember Petr has a patch series related to address space check, though I don't remember the status of affairs.

lib/vsprintf.c char *device_node_string(char *buf, char *end, struct device_node *dn, · line 1856

Quoted 7 lines
lib/vsprintf.c +7 -0
+
+	/* simple case without anything any more format specifiers */
+	fmt++;
+	if (fmt[0] == '\0' || strcspn(fmt, modifiers) > 0)
+		fmt = "f";
+
+	for (pass = false; strspn(fmt, modifiers); fmt++, pass = true) {

I don't see test cases.

What would we get out of %pfwfffPPPfff?

Hint: I'm expecting above to be equivalent to %pfwf

Quoted 21 lines
lib/vsprintf.c +21 -0
+		if (pass) {
+			if (buf < end)
+				*buf = ':';
+			buf++;
+		}
+
+		switch (*fmt) {
+		case 'f':	/* full_name */
+			buf = fwnode_gen_full_name(fwnode, buf, end);
+			break;
+		case 'P':	/* name */
+			buf = string(buf, end, fwnode_get_name(fwnode),
+				     str_spec);
+			break;
+		default:
+			break;
+		}
+	}
+
+	return widen_string(buf, buf - buf_start, end, spec);
+}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author reviewer
#11 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

Hi Andy,

Thanks for the comments.

Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Sakari Ailus

Add support for %pfw conversion specifier (with "f" and "P" modifiers) to support printing full path of the node, including its name ("f") and only the node's name ("P") in the printk family of functions. The two flags have equivalent functionality to existing %pOF with the same two modifiers ("f" and "P") on OF based systems. The ability to do the same on ACPI based systems is added by this patch.

Do we encourage people to use it instead of %pOF cases where it is suitable?

For code that is used on both OF and ACPI based systems, I think so. But if you have something that is only used on OF, %pOF is better --- it has more functionality that seems quite OF specific. In general I think the ability to print a node's full name is way more important on OF. On ACPI you don't need it so often --- which is probably the reason it hasn't been supported.

Quoted 9 lines
Quoted 7 lines

On ACPI based systems the resulting strings look like

	\[email protected]@0

where the nodes are separated by a dot (".") and the first three are ACPI device nodes and the latter two ACPI data nodes.

Do we support swnode here?

Good question. The swnodes have no hierarchy at the moment (they're only created for a struct device as a parent) and they do not have human-readable names. So I'd say it's not relevant right now. Should these two change, support for swnode could (and should) be added later on.

Quoted 13 lines
Quoted 12 lines
lib/vsprintf.c +11 -0
+static noinline_for_stack
+char *fwnode_string(char *buf, char *end, struct fwnode_handle *fwnode,
+		    struct printf_spec spec, const char *fmt)
+{
+	const char * const modifiers = "fP";
+	struct printf_spec str_spec = spec;
+	char *buf_start = buf;
+	bool pass;
+
+	str_spec.field_width = -1;
+
Quoted 8 lines

lib/vsprintf.c char *device_node_string(char *buf, char *end, struct device_node *dn, · line 1849

Quoted 2 lines
lib/vsprintf.c +2 -0
+	if ((unsigned long)fwnode < PAGE_SIZE)
+		return string(buf, end, "(null)", spec);

Just put there a NULL pointer, we would not like to maintain duplicated strings over the kernel.

I remember Petr has a patch series related to address space check, though I don't remember the status of affairs.

This bit has been actually adopted from the OF counterpart. If there are improvements in this area, then I'd just change both at the same time.

Quoted 11 lines

lib/vsprintf.c char *device_node_string(char *buf, char *end, struct device_node *dn, · line 1856

Quoted 8 lines
lib/vsprintf.c +7 -0
+
+	/* simple case without anything any more format specifiers */
+	fmt++;
+	if (fmt[0] == '\0' || strcspn(fmt, modifiers) > 0)
+		fmt = "f";
+
+	for (pass = false; strspn(fmt, modifiers); fmt++, pass = true) {

I don't see test cases.

Quoted 3 lines

What would we get out of %pfwfffPPPfff?

Hint: I'm expecting above to be equivalent to %pfwf

I guess it's a matter of expectations. :-) Again this works the same way than the OF counterpart. Right now there's little to print (just the name and the full name), but if support is added for more, then this mechanism is fully relevant again.

The alternative would be to remove that now and add it back if it's needed again. I have a slight preference towards keeping it extensible (i.e. as it's now).

Quoted 23 lines
Quoted 22 lines
lib/vsprintf.c +21 -0
+		if (pass) {
+			if (buf < end)
+				*buf = ':';
+			buf++;
+		}
+
+		switch (*fmt) {
+		case 'f':	/* full_name */
+			buf = fwnode_gen_full_name(fwnode, buf, end);
+			break;
+		case 'P':	/* name */
+			buf = string(buf, end, fwnode_get_name(fwnode),
+				     str_spec);
+			break;
+		default:
+			break;
+		}
+	}
+
+	return widen_string(buf, buf - buf_start, end, spec);
+}
Signature · 4 lines
Kind regards,

Sakari Ailus
[email protected]
#12 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

Quoted 9 lines · Sakari Ailus
Quoted 8 lines · Andy Shevchenko
Quoted 6 lines · Sakari Ailus

Add support for %pfw conversion specifier (with "f" and "P" modifiers) to support printing full path of the node, including its name ("f") and only the node's name ("P") in the printk family of functions. The two flags have equivalent functionality to existing %pOF with the same two modifiers ("f" and "P") on OF based systems. The ability to do the same on ACPI based systems is added by this patch.

Quoted 7 lines
Quoted 1 line

Do we encourage people to use it instead of %pOF cases where it is suitable?

For code that is used on both OF and ACPI based systems, I think so. But if you have something that is only used on OF, %pOF is better --- it has more functionality that seems quite OF specific. In general I think the ability to print a node's full name is way more important on OF. On ACPI you don't need it so often --- which is probably the reason it hasn't been supported.

But if code is going to support ACPI and DT and at the same time use %pOF extensions that are not covered by %pfw it would be inconsistent somehow.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

On ACPI based systems the resulting strings look like

	\[email protected]@0

where the nodes are separated by a dot (".") and the first three are ACPI device nodes and the latter two ACPI data nodes.

Quoted 6 lines
Quoted 1 line

Do we support swnode here?

Good question. The swnodes have no hierarchy at the moment (they're only created for a struct device as a parent) and they do not have human-readable names. So I'd say it's not relevant right now. Should these two change, support for swnode could (and should) be added later on.

Heikki, what do you think about this?

Quoted 11 lines
Quoted 8 lines

lib/vsprintf.c char *device_node_string(char *buf, char *end, struct device_node *dn, · line 1849

Quoted 2 lines
lib/vsprintf.c +2 -0
+	if ((unsigned long)fwnode < PAGE_SIZE)
+		return string(buf, end, "(null)", spec);

Just put there a NULL pointer, we would not like to maintain duplicated strings over the kernel.

I remember Petr has a patch series related to address space check, though I don't remember the status of affairs.

This bit has been actually adopted from the OF counterpart. If there are improvements in this area, then I'd just change both at the same time.

The patch series by Petr I mentioned takes care about OF case. But it doesn't have covered yours by obvious reasons.

Quoted 9 lines
Quoted 7 lines

lib/vsprintf.c char *device_node_string(char *buf, char *end, struct device_node *dn, · line 1856

Quoted 1 line
lib/vsprintf.c +1 -0
+	for (pass = false; strspn(fmt, modifiers); fmt++, pass = true) {

I don't see test cases.

What would we get out of %pfwfffPPPfff?

Hint: I'm expecting above to be equivalent to %pfwf

I guess it's a matter of expectations. :-)

Common sense and basic expectations from all of %p extensions.

Quoted 2 lines

Again this works the same way
than the OF counterpart.

OF lacks of testing apparently.

Quoted 7 lines

Right now there's little to print (just the name
and the full name), but if support is added for more, then this mechanism is fully relevant again.

The alternative would be to remove that now and add it back if it's needed again. I have a slight preference towards keeping it extensible (i.e. as it's now).

See how other helpers do parse this.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author reviewer
#13 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

Hi Andy,

Quoted 12 lines · Andy Shevchenko
Quoted 11 lines · Sakari Ailus
Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Sakari Ailus

Add support for %pfw conversion specifier (with "f" and "P" modifiers) to support printing full path of the node, including its name ("f") and only the node's name ("P") in the printk family of functions. The two flags have equivalent functionality to existing %pOF with the same two modifiers ("f" and "P") on OF based systems. The ability to do the same on ACPI based systems is added by this patch.

Do we encourage people to use it instead of %pOF cases where it is suitable?

Quoted 8 lines
Quoted 5 lines

For code that is used on both OF and ACPI based systems, I think so. But if you have something that is only used on OF, %pOF is better --- it has more functionality that seems quite OF specific. In general I think the ability to print a node's full name is way more important on OF. On ACPI you don't need it so often --- which is probably the reason it hasn't been supported.

But if code is going to support ACPI and DT and at the same time use %pOF extensions that are not covered by %pfw it would be inconsistent somehow.

What you mostly need are the full name and the name of a given node. I wasn't sure whether adding more would have been relevant, and at least it is likely to have few if any users, so I didn't add that yet. Do not that it can be implemented later on if it's needed --- that's also why the modifiers are aligned with %pOF.

Quoted 23 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

On ACPI based systems the resulting strings look like

	\[email protected]@0

where the nodes are separated by a dot (".") and the first three are ACPI device nodes and the latter two ACPI data nodes.

Quoted 6 lines
Quoted 1 line

Do we support swnode here?

Good question. The swnodes have no hierarchy at the moment (they're only created for a struct device as a parent) and they do not have human-readable names. So I'd say it's not relevant right now. Should these two change, support for swnode could (and should) be added later on.

Heikki, what do you think about this?

Quoted 6 lines
Quoted 6 lines

lib/vsprintf.c char *device_node_string(char *buf, char *end, struct device_node *dn, · line 1849

Quoted 2 lines
lib/vsprintf.c +2 -0
+	if ((unsigned long)fwnode < PAGE_SIZE)
+		return string(buf, end, "(null)", spec);

Just put there a NULL pointer, we would not like to maintain duplicated strings over the kernel.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I remember Petr has a patch series related to address space check, though I don't remember the status of affairs.

This bit has been actually adopted from the OF counterpart. If there are improvements in this area, then I'd just change both at the same time.

The patch series by Petr I mentioned takes care about OF case. But it doesn't have covered yours by obvious reasons.

Do you happen to have a pointer to it?

Quoted 22 lines
Quoted 10 lines
Quoted 8 lines

lib/vsprintf.c char *device_node_string(char *buf, char *end, struct device_node *dn, · line 1856

Quoted 2 lines
lib/vsprintf.c +1 -0
+	for (pass = false; strspn(fmt, modifiers); fmt++, pass = true) {

I don't see test cases.

What would we get out of %pfwfffPPPfff?

Hint: I'm expecting above to be equivalent to %pfwf

I guess it's a matter of expectations. :-)

Common sense and basic expectations from all of %p extensions.

Quoted 2 lines

Again this works the same way
than the OF counterpart.

OF lacks of testing apparently.

Quoted 4 lines

Right now there's little to print (just the name
and the full name), but if support is added for more, then this mechanism is fully relevant again.

Quoted 5 lines
Quoted 3 lines

The alternative would be to remove that now and add it back if it's needed again. I have a slight preference towards keeping it extensible (i.e. as it's now).

See how other helpers do parse this.

The behaviour on others is different indeed, you're generally printing a single item at a time. The question rather is, whether we want to be compatible with %pOF going forward or not. I'd prefer that, so using the fwnode API would be easier.

Signature · 4 lines
Regards,

Sakari Ailus
[email protected]
#14 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

Quoted 7 lines · Sakari Ailus
Quoted 4 lines · Andy Shevchenko

On Sun, Mar 24, 2019 at 08:17:46PM +0200, Sakari Ailus wrote:

The patch series by Petr I mentioned takes care about OF case. But it doesn't have covered yours by obvious reasons.

Do you happen to have a pointer to it?

Petr, can you share what is the state of affairs with that series?

Quoted 4 lines

The behaviour on others is different indeed, you're generally printing a single item at a time. The question rather is, whether we want to be compatible with %pOF going forward or not. I'd prefer that, so using the fwnode API would be easier.

I would prefer to mimic %pOF and actually to deprecate it in favour of %pfw. But it's just mine opinion. I'm skeptical about getting support on it.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author reviewer
#15 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

Hi Andy,

Quoted 11 lines · Andy Shevchenko
Quoted 7 lines · Sakari Ailus
Quoted 4 lines · Andy Shevchenko

On Sun, Mar 24, 2019 at 08:17:46PM +0200, Sakari Ailus wrote:

The patch series by Petr I mentioned takes care about OF case. But it doesn't have covered yours by obvious reasons.

Do you happen to have a pointer to it?

Petr, can you share what is the state of affairs with that series?

Quoted 7 lines
Quoted 4 lines

The behaviour on others is different indeed, you're generally printing a single item at a time. The question rather is, whether we want to be compatible with %pOF going forward or not. I'd prefer that, so using the fwnode API would be easier.

I would prefer to mimic %pOF and actually to deprecate it in favour of %pfw. But it's just mine opinion. I'm skeptical about getting support on it.

IMHO code that only deals with OF specifically is better to continue to use %pOF. You'd have of_fwnode_handle() in places where you just had the name of the node previously.

What could be done though is to unify the implementations; that's something which the set does a little of already.

Cc Rob, too.

Signature · 4 lines
Kind regards,

Sakari Ailus
[email protected]
maintainer
#16 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

In reply to Andy Shevchenko
Quoted 10 lines · Andy Shevchenko
Quoted 7 lines · Sakari Ailus
Quoted 4 lines · Andy Shevchenko

On Sun, Mar 24, 2019 at 08:17:46PM +0200, Sakari Ailus wrote:

The patch series by Petr I mentioned takes care about OF case. But it doesn't have covered yours by obvious reasons.

Do you happen to have a pointer to it?

Petr, can you share what is the state of affairs with that series?

I might send a new version this week but I do not promise it. It is regularly pushed aside by more urgent work.

But we could work on both changes independently. Both can be updated easily depending on which one gets accepted earlier.

Best Regards,
Petr

#17 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

In reply to Andy Shevchenko

Hi,

Quoted 7 lines · Andy Shevchenko
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

On ACPI based systems the resulting strings look like

	\[email protected]@0

where the nodes are separated by a dot (".") and the first three are ACPI device nodes and the latter two ACPI data nodes.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Do we support swnode here?

Good question. The swnodes have no hierarchy at the moment (they're only created for a struct device as a parent) and they do not have human-readable names. So I'd say it's not relevant right now. Should these two change, support for swnode could (and should) be added later on.

Heikki, what do you think about this?

Well, the swnodes do have hierarchy. That was kind of the whole point of introducing them. They now can also be named using "name" property. See commit 344798206f171c5abea7ab1f9762fa526d7f539d.

thanks,

Signature · 1 line
heikki
author reviewer
#18 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

Moi,

Quoted 17 lines · Heikki Krogerus

Hi,

Quoted 14 lines · Andy Shevchenko
Quoted 13 lines
Quoted 8 lines
Quoted 6 lines

On ACPI based systems the resulting strings look like

	\[email protected]@0

where the nodes are separated by a dot (".") and the first three are ACPI device nodes and the latter two ACPI data nodes.

Do we support swnode here?

Good question. The swnodes have no hierarchy at the moment (they're only created for a struct device as a parent) and they do not have human-readable names. So I'd say it's not relevant right now. Should these two change, support for swnode could (and should) be added later on.

Quoted 5 lines
Quoted 1 line

Heikki, what do you think about this?

Well, the swnodes do have hierarchy. That was kind of the whole point of introducing them. They now can also be named using "name" property. See commit 344798206f171c5abea7ab1f9762fa526d7f539d.

Right; I saw the function after initially replying to Andy but I missed where the node name came from. :-) Now I know...

I can add support for swnode, too, if you like.

Signature · 4 lines
Terveisin,

Sakari Ailus
[email protected]
#19 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

Quoted 12 lines · Sakari Ailus
Quoted 11 lines · Heikki Krogerus
Quoted 8 lines · Andy Shevchenko
Quoted 6 lines
Quoted 1 line

Do we support swnode here?

Good question. The swnodes have no hierarchy at the moment (they're only created for a struct device as a parent) and they do not have human-readable names. So I'd say it's not relevant right now. Should these two change, support for swnode could (and should) be added later on.

Heikki, what do you think about this?

Quoted 8 lines
Quoted 3 lines

Well, the swnodes do have hierarchy. That was kind of the whole point of introducing them. They now can also be named using "name" property. See commit 344798206f171c5abea7ab1f9762fa526d7f539d.

Right; I saw the function after initially replying to Andy but I missed where the node name came from. :-) Now I know...

I can add support for swnode, too, if you like.

Definitely!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#20 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

Quoted 17 lines · Andy Shevchenko
Quoted 16 lines · Sakari Ailus
Quoted 14 lines · Heikki Krogerus
Quoted 8 lines · Andy Shevchenko
Quoted 6 lines
Quoted 1 line

Do we support swnode here?

Good question. The swnodes have no hierarchy at the moment (they're only created for a struct device as a parent) and they do not have human-readable names. So I'd say it's not relevant right now. Should these two change, support for swnode could (and should) be added later on.

Heikki, what do you think about this?

Well, the swnodes do have hierarchy. That was kind of the whole point of introducing them. They now can also be named using "name" property. See commit 344798206f171c5abea7ab1f9762fa526d7f539d.

Quoted 6 lines
Quoted 4 lines

Right; I saw the function after initially replying to Andy but I missed where the node name came from. :-) Now I know...

I can add support for swnode, too, if you like.

Definitely!

It might really make sense to obsolete %pOF and handle all three (OF, ACPI, Software) nodes using the same %pfw modifiers.

If I get it correctly, we could distinguish them by fwnode->ops, see is_of_node(), is_acpi_static_node(), is_software_node().

Best Regards,
Petr

#21 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

In reply to Sakari Ailus
Quoted 22 lines · Sakari Ailus

Moi,

Quoted 19 lines · Heikki Krogerus

Hi,

Quoted 15 lines · Andy Shevchenko
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

On ACPI based systems the resulting strings look like

	\[email protected]@0

where the nodes are separated by a dot (".") and the first three are ACPI device nodes and the latter two ACPI data nodes.

Quoted 6 lines
Quoted 1 line

Do we support swnode here?

Good question. The swnodes have no hierarchy at the moment (they're only created for a struct device as a parent) and they do not have human-readable names. So I'd say it's not relevant right now. Should these two change, support for swnode could (and should) be added later on.

Heikki, what do you think about this?

Quoted 8 lines
Quoted 3 lines

Well, the swnodes do have hierarchy. That was kind of the whole point of introducing them. They now can also be named using "name" property. See commit 344798206f171c5abea7ab1f9762fa526d7f539d.

Right; I saw the function after initially replying to Andy but I missed where the node name came from. :-) Now I know...

I can add support for swnode, too, if you like.

It's up to you.

thanks,

Signature · 1 line
heikki
maintainer
#22 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

In reply to Sakari Ailus
Quoted 7 lines · Sakari Ailus

Add support for %pfw conversion specifier (with "f" and "P" modifiers) to support printing full path of the node, including its name ("f") and only the node's name ("P") in the printk family of functions. The two flags have equivalent functionality to existing %pOF with the same two modifiers ("f" and "P") on OF based systems. The ability to do the same on ACPI based systems is added by this patch.

Quoted 8 lines

On ACPI based systems the resulting strings look like

	\[email protected]@0

where the nodes are separated by a dot (".") and the first three are ACPI device nodes and the latter two ACPI data nodes.

Depends-on: ("vsprintf: Remove support for %pF and %pf in favour of %pS and %ps")

Reusing obsolete modifiers is dangerous from many reasons:

+ people might miss the change of the meaning
+ backporting mistakes
+ 3rd party modules

It might be acceptable if the long term gain is bigger than a short time difficulties. But it would be better to it a safe way when possible.

Fortunately, we could keep the backward compatibility for "%pf" and handle only "%pfw*" with the fwnode api.

Best Regards,
Petr

author reviewer
#23 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

Hi Petr,

Quoted 23 lines · Petr Mladek
Quoted 7 lines · Sakari Ailus

Add support for %pfw conversion specifier (with "f" and "P" modifiers) to support printing full path of the node, including its name ("f") and only the node's name ("P") in the printk family of functions. The two flags have equivalent functionality to existing %pOF with the same two modifiers ("f" and "P") on OF based systems. The ability to do the same on ACPI based systems is added by this patch.

Quoted 8 lines

On ACPI based systems the resulting strings look like

	\[email protected]@0

where the nodes are separated by a dot (".") and the first three are ACPI device nodes and the latter two ACPI data nodes.

Depends-on: ("vsprintf: Remove support for %pF and %pf in favour of %pS and %ps")

Reusing obsolete modifiers is dangerous from many reasons:

+ people might miss the change of the meaning
+ backporting mistakes
+ 3rd party modules

Quoted 6 lines

It might be acceptable if the long term gain is bigger than a short time difficulties. But it would be better to it a safe way when possible.

Fortunately, we could keep the backward compatibility for "%pf" and handle only "%pfw*" with the fwnode api.

The v2 of this patch produces a warning (using WARN_ONCE()) for "%pf" not immediately followed by "w". "%pfw" was not a valid conversion specifier before this set, so we're actually not re-using the exactly same conversion specifiers.

Signature · 4 lines
Regards,

Sakari Ailus
[email protected]
maintainer
#24 lore raw

Re: [PATCH 5/5] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names

Quoted 30 lines · Sakari Ailus

Hi Petr,

Quoted 27 lines · Petr Mladek
Quoted 7 lines · Sakari Ailus

Add support for %pfw conversion specifier (with "f" and "P" modifiers) to support printing full path of the node, including its name ("f") and only the node's name ("P") in the printk family of functions. The two flags have equivalent functionality to existing %pOF with the same two modifiers ("f" and "P") on OF based systems. The ability to do the same on ACPI based systems is added by this patch.

Quoted 8 lines

On ACPI based systems the resulting strings look like

	\[email protected]@0

where the nodes are separated by a dot (".") and the first three are ACPI device nodes and the latter two ACPI data nodes.

Depends-on: ("vsprintf: Remove support for %pF and %pf in favour of %pS and %ps")

Reusing obsolete modifiers is dangerous from many reasons:

+ people might miss the change of the meaning
+ backporting mistakes
+ 3rd party modules

It might be acceptable if the long term gain is bigger than a short time difficulties. But it would be better to it a safe way when possible.

Quoted 7 lines
Quoted 2 lines

Fortunately, we could keep the backward compatibility for "%pf" and handle only "%pfw*" with the fwnode api.

The v2 of this patch produces a warning (using WARN_ONCE()) for "%pf" not immediately followed by "w". "%pfw" was not a valid conversion specifier before this set, so we're actually not re-using the exactly same conversion specifiers.

I see. I would keep the two patchsets separate. I mean that this patchset should expect that the original handling of %pf is still there.

The way how to remove or obsolete "%pf" should be handled in the patchset removing all %pf users or it can be done in a completely separate patch.

The conflict can get handled when merging the two patchsets.

Best Regards,
Petr