Skip to contentSkip to conversation

software node: Free resources explicitly when swnode_register() fails

PATCH In review Andy Shevchenko 4 participants 17 messages Mar 29, 2021 – Apr 8, 2021

Subsystems (5)
lore
Share & tools
lore
author reviewer
#4 lore raw

PATCH v2 4/6 software node: Imply kobj_to_swnode() to be no-op

In reply to Andy Shevchenko

Since we don't use structure field layout randomization the manual shuffling can affect some macros, in particular kobj_to_swnode(), which becomes a no-op when kobj member is the first one in the struct swnode.

Bloat-o-meter statistics for swnode.o:

add/remove: 0/0 grow/shrink: 2/10 up/down: 9/-100 (-91)
Total: Before=7217, After=7126, chg -1.26%

---
v2: added the object file name against which bloat-o-meter was run (Greg)

 drivers/base/swnode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/swnode.c +1 -1
index db982859171e..e83028e11f50 100644
@@ -12,10 +12,10 @@
 #include <linux/slab.h>
 
 struct swnode {
-	int id;
 	struct kobject kobj;
 	struct fwnode_handle fwnode;
 	const struct software_node *node;
+	int id;
 
 	/* hierarchy */
 	struct ida child_ids;
Signature · 1 line
2.30.2

Andy Shevchenko

author reviewer
#0 lore raw

PATCH v2 1/6 software node: Free resources explicitly when swnode_register() fails

Currently we have a slightly twisted logic in swnode_register(). It frees resources that it doesn't allocate on error path and in once case it relies on the ->release() implementation.

Untwist the logic by freeing resources explicitly when swnode_register() fails. Currently it happens only in fwnode_create_software_node().

---
v2: no changes

 drivers/base/swnode.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/base/swnode.c +17 -12
index fa3719ef80e4..456f5fe58b58 100644
@@ -767,22 +767,19 @@ swnode_register(const struct software_node *node, struct swnode *parent,
 	int ret;
 
 	swnode = kzalloc(sizeof(*swnode), GFP_KERNEL);
-	if (!swnode) {
-		ret = -ENOMEM;
-		goto out_err;
-	}
+	if (!swnode)
+		return ERR_PTR(-ENOMEM);
 
 	ret = ida_simple_get(parent ? &parent->child_ids : &swnode_root_ids,
 			     0, 0, GFP_KERNEL);
 	if (ret < 0) {
 		kfree(swnode);
-		goto out_err;
+		return ERR_PTR(ret);
 	}
 
 	swnode->id = ret;
 	swnode->node = node;
 	swnode->parent = parent;
-	swnode->allocated = allocated;
 	swnode->kobj.kset = swnode_kset;
 	fwnode_init(&swnode->fwnode, &software_node_ops);
 
@@ -803,16 +800,17 @@ swnode_register(const struct software_node *node, struct swnode *parent,
 		return ERR_PTR(ret);
 	}
 
+	/*
+	 * Assign the flag only in the successful case, so
+	 * the above kobject_put() won't mess up with properties.
+	 */
+	swnode->allocated = allocated;
+
 	if (parent)
 		list_add_tail(&swnode->entry, &parent->children);
 
 	kobject_uevent(&swnode->kobj, KOBJ_ADD);
 	return &swnode->fwnode;
-
-out_err:
-	if (allocated)
-		property_entries_free(node->properties);
-	return ERR_PTR(ret);
 }
 
 /**
@@ -963,6 +961,7 @@ struct fwnode_handle *
 fwnode_create_software_node(const struct property_entry *properties,
 			    const struct fwnode_handle *parent)
 {
+	struct fwnode_handle *fwnode;
 	struct software_node *node;
 	struct swnode *p = NULL;
 	int ret;
@@ -987,7 +986,13 @@ fwnode_create_software_node(const struct property_entry *properties,
 
 	node->parent = p ? p->node : NULL;
 
-	return swnode_register(node, p, 1);
+	fwnode = swnode_register(node, p, 1);
+	if (IS_ERR(fwnode)) {
+		property_entries_free(node->properties);
+		kfree(node);
+	}
+
+	return fwnode;
 }
 EXPORT_SYMBOL_GPL(fwnode_create_software_node);
 
Signature · 1 line
2.30.2
author reviewer
#1 lore raw

PATCH v2 2/6 software node: Introduce software_node_alloc()/software_node_free()

Introduce software_node_alloc() and software_node_free() helpers. This will help with code readability and maintenance.

---
v2: no changes

 drivers/base/swnode.c | 47 ++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 23 deletions(-)
drivers/base/swnode.c +24 -23
index 456f5fe58b58..19aa44bc2628 100644
@@ -720,19 +720,30 @@ software_node_find_by_name(const struct software_node *parent, const char *name)
 }
 EXPORT_SYMBOL_GPL(software_node_find_by_name);
 
-static int
-software_node_register_properties(struct software_node *node,
-				  const struct property_entry *properties)
+static struct software_node *software_node_alloc(const struct property_entry *properties)
 {
 	struct property_entry *props;
+	struct software_node *node;
 
 	props = property_entries_dup(properties);
 	if (IS_ERR(props))
-		return PTR_ERR(props);
+		return ERR_CAST(props);
+
+	node = kzalloc(sizeof(*node), GFP_KERNEL);
+	if (!node) {
+		property_entries_free(props);
+		return ERR_PTR(-ENOMEM);
+	}
 
 	node->properties = props;
 
-	return 0;
+	return node;
+}
+
+static void software_node_free(const struct software_node *node)
+{
+	property_entries_free(node->properties);
+	kfree(node);
 }
 
 static void software_node_release(struct kobject *kobj)
@@ -746,10 +757,9 @@ static void software_node_release(struct kobject *kobj)
 		ida_simple_remove(&swnode_root_ids, swnode->id);
 	}
 
-	if (swnode->allocated) {
-		property_entries_free(swnode->node->properties);
-		kfree(swnode->node);
-	}
+	if (swnode->allocated)
+		software_node_free(swnode->node);
+
 	ida_destroy(&swnode->child_ids);
 	kfree(swnode);
 }
@@ -964,7 +974,6 @@ fwnode_create_software_node(const struct property_entry *properties,
 	struct fwnode_handle *fwnode;
 	struct software_node *node;
 	struct swnode *p = NULL;
-	int ret;
 
 	if (parent) {
 		if (IS_ERR(parent))
@@ -974,23 +983,15 @@ fwnode_create_software_node(const struct property_entry *properties,
 		p = to_swnode(parent);
 	}
 
-	node = kzalloc(sizeof(*node), GFP_KERNEL);
-	if (!node)
-		return ERR_PTR(-ENOMEM);
-
-	ret = software_node_register_properties(node, properties);
-	if (ret) {
-		kfree(node);
-		return ERR_PTR(ret);
-	}
+	node = software_node_alloc(properties);
+	if (IS_ERR(node))
+		return ERR_CAST(node);
 
 	node->parent = p ? p->node : NULL;
 
 	fwnode = swnode_register(node, p, 1);
-	if (IS_ERR(fwnode)) {
-		property_entries_free(node->properties);
-		kfree(node);
-	}
+	if (IS_ERR(fwnode))
+		software_node_free(node);
 
 	return fwnode;
 }
Signature · 1 line
2.30.2
author reviewer
#5 lore raw

PATCH v2 5/6 software node: Introduce SOFTWARE_NODE_REFERENCE() helper macro

In reply to Andy Shevchenko

This is useful to assign software node reference with arguments in a common way. Moreover, we have already couple of users that may be converted. And by the fact, one of them is moved right here to use the helper.

---
v2: no changes

 drivers/base/test/property-entry-test.c | 11 ++---------
 include/linux/property.h                | 13 ++++++++-----
 2 files changed, 10 insertions(+), 14 deletions(-)
drivers/base/test/property-entry-test.c +2 -9
index abe03315180f..c2e455d46ffd 100644
@@ -370,15 +370,8 @@ static void pe_test_reference(struct kunit *test)
 	};
 
 	static const struct software_node_ref_args refs[] = {
-		{
-			.node = &nodes[0],
-			.nargs = 0,
-		},
-		{
-			.node = &nodes[1],
-			.nargs = 2,
-			.args = { 3, 4 },
-		},
+		SOFTWARE_NODE_REFERENCE(&nodes[0]),
+		SOFTWARE_NODE_REFERENCE(&nodes[1], 3, 4),
 	};
 
 	const struct property_entry entries[] = {
include/linux/property.h +8 -5
index dd4687b56239..0d876316e61d 100644
@@ -254,6 +254,13 @@ struct software_node_ref_args {
 	u64 args[NR_FWNODE_REFERENCE_ARGS];
 };
 
+#define SOFTWARE_NODE_REFERENCE(_ref_, ...)			\
+(const struct software_node_ref_args) {				\
+	.node = _ref_,						\
+	.nargs = ARRAY_SIZE(((u64[]){ 0, ##__VA_ARGS__ })) - 1,	\
+	.args = { __VA_ARGS__ },				\
+}
+
 /**
  * struct property_entry - "Built-in" device property representation.
  * @name: Name of the property.
@@ -362,11 +369,7 @@ struct property_entry {
 	.name = _name_,							\
 	.length = sizeof(struct software_node_ref_args),		\
 	.type = DEV_PROP_REF,						\
-	{ .pointer = &(const struct software_node_ref_args) {		\
-		.node = _ref_,						\
-		.nargs = ARRAY_SIZE(((u64[]){ 0, ##__VA_ARGS__ })) - 1,	\
-		.args = { __VA_ARGS__ },				\
-	} },								\
+	{ .pointer = &SOFTWARE_NODE_REFERENCE(_ref_, ##__VA_ARGS__), },	\
 }
 
 struct property_entry *
Signature · 1 line
2.30.2
author reviewer
#9 lore raw

PATCH v2 6/6 media: ipu3-cio2: Switch to use SOFTWARE_NODE_REFERENCE()

In reply to Andy Shevchenko

This is useful to assign software node reference with arguments in a common way. Switch to use SOFTWARE_NODE_REFERENCE() here.

---
v2: no changes

 drivers/media/pci/intel/ipu3/cio2-bridge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +2 -2
index c2199042d3db..e8511787c1e4 100644
@@ -79,8 +79,8 @@ static void cio2_bridge_create_fwnode_properties(
 {
 	sensor->prop_names = prop_names;
 
-	sensor->local_ref[0].node = &sensor->swnodes[SWNODE_CIO2_ENDPOINT];
-	sensor->remote_ref[0].node = &sensor->swnodes[SWNODE_SENSOR_ENDPOINT];
+	sensor->local_ref[0] = SOFTWARE_NODE_REFERENCE(&sensor->swnodes[SWNODE_CIO2_ENDPOINT]);
+	sensor->remote_ref[0] = SOFTWARE_NODE_REFERENCE(&sensor->swnodes[SWNODE_SENSOR_ENDPOINT]);
 
 	sensor->dev_properties[0] = PROPERTY_ENTRY_U32(
 					sensor->prop_names.clock_frequency,
Signature · 1 line
2.30.2
author reviewer
#2 lore raw

PATCH v2 3/6 software node: Deduplicate code in fwnode_create_software_node()

In reply to Andy Shevchenko

Deduplicate conditional and assignment in fwnode_create_software_node(), i.e. parent is checked in two out of three cases and parent software node is assigned by to_swnode() call.

---
v2: no changes

 drivers/base/swnode.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/base/swnode.c +8 -9
index 19aa44bc2628..db982859171e 100644
@@ -973,15 +973,14 @@ fwnode_create_software_node(const struct property_entry *properties,
 {
 	struct fwnode_handle *fwnode;
 	struct software_node *node;
-	struct swnode *p = NULL;
-
-	if (parent) {
-		if (IS_ERR(parent))
-			return ERR_CAST(parent);
-		if (!is_software_node(parent))
-			return ERR_PTR(-EINVAL);
-		p = to_swnode(parent);
-	}
+	struct swnode *p;
+
+	if (IS_ERR(parent))
+		return ERR_CAST(parent);
+
+	p = to_swnode(parent);
+	if (parent && !p)
+		return ERR_PTR(-EINVAL);
 
 	node = software_node_alloc(properties);
 	if (IS_ERR(node))
Signature · 1 line
2.30.2
reviewer Reviewed-by on v2 3/6
#3 lore raw

Re: [PATCH v2 3/6] software node: Deduplicate code in fwnode_create_software_node()

Hi Andy

Quoted 5 lines · Andy Shevchenko

Deduplicate conditional and assignment in fwnode_create_software_node(), i.e. parent is checked in two out of three cases and parent software node is assigned by to_swnode() call.

Quoted 33 lines

---
v2: no changes

 drivers/base/swnode.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/base/swnode.c +8 -9
index 19aa44bc2628..db982859171e 100644
@@ -973,15 +973,14 @@ fwnode_create_software_node(const struct property_entry *properties,
 {
 	struct fwnode_handle *fwnode;
 	struct software_node *node;
-	struct swnode *p = NULL;
-
-	if (parent) {
-		if (IS_ERR(parent))
-			return ERR_CAST(parent);
-		if (!is_software_node(parent))
-			return ERR_PTR(-EINVAL);
-		p = to_swnode(parent);
-	}
+	struct swnode *p;
+
+	if (IS_ERR(parent))
+		return ERR_CAST(parent);
+
+	p = to_swnode(parent);
+	if (parent && !p)
+		return ERR_PTR(-EINVAL);
 
 	node = software_node_alloc(properties);
 	if (IS_ERR(node))
reviewer
#6 lore raw

Re: [PATCH v2 5/6] software node: Introduce SOFTWARE_NODE_REFERENCE() helper macro

In reply to Andy Shevchenko

Hi Andy

Quoted 53 lines · Andy Shevchenko

This is useful to assign software node reference with arguments in a common way. Moreover, we have already couple of users that may be converted. And by the fact, one of them is moved right here to use the helper.

---
v2: no changes

 drivers/base/test/property-entry-test.c | 11 ++---------
 include/linux/property.h                | 13 ++++++++-----
 2 files changed, 10 insertions(+), 14 deletions(-)
drivers/base/test/property-entry-test.c +2 -9
index abe03315180f..c2e455d46ffd 100644
@@ -370,15 +370,8 @@ static void pe_test_reference(struct kunit *test)
 	};
 
 	static const struct software_node_ref_args refs[] = {
-		{
-			.node = &nodes[0],
-			.nargs = 0,
-		},
-		{
-			.node = &nodes[1],
-			.nargs = 2,
-			.args = { 3, 4 },
-		},
+		SOFTWARE_NODE_REFERENCE(&nodes[0]),
+		SOFTWARE_NODE_REFERENCE(&nodes[1], 3, 4),
 	};
 
 	const struct property_entry entries[] = {
include/linux/property.h +7 -0
index dd4687b56239..0d876316e61d 100644
@@ -254,6 +254,13 @@ struct software_node_ref_args {
 	u64 args[NR_FWNODE_REFERENCE_ARGS];
 };
 
+#define SOFTWARE_NODE_REFERENCE(_ref_, ...)			\
+(const struct software_node_ref_args) {				\
+	.node = _ref_,						\
+	.nargs = ARRAY_SIZE(((u64[]){ 0, ##__VA_ARGS__ })) - 1,	\
+	.args = { __VA_ARGS__ },				\
+}
+
 /**
  * struct property_entry - "Built-in" device property representation.
  * @name: Name of the property.

include/linux/property.h struct property_entry { · line 373

Quoted 10 lines
include/linux/property.h +1 -5
@@ -362,11 +369,7 @@ struct property_entry {
 	.name = _name_,							\
 	.length = sizeof(struct software_node_ref_args),		\
 	.type = DEV_PROP_REF,						\
-	{ .pointer = &(const struct software_node_ref_args) {		\
-		.node = _ref_,						\
-		.nargs = ARRAY_SIZE(((u64[]){ 0, ##__VA_ARGS__ })) - 1,	\
-		.args = { __VA_ARGS__ },				\
-	} },								\
+	{ .pointer = &SOFTWARE_NODE_REFERENCE(_ref_, ##__VA_ARGS__), },	\
 }

What are the .args intended to be used for? I actually had it in mind to replace this with a simple pointer to a struct software_node, because I can't see any users of them and the fact that it's actually storing a pointer to a new variable is something that confused me for a good long time when I wrote the cio2-bridge (though that's mostly due to my relative inexperience of course, but still)

Quoted 2 lines
include/linux/property.h +0 -0
 struct property_entry *
reviewer Reviewed-by Tested-by on v2 1/6
#10 lore raw
In reply to Andy Shevchenko

Hi Andy

Quoted 8 lines · Andy Shevchenko

Currently we have a slightly twisted logic in swnode_register(). It frees resources that it doesn't allocate on error path and in once case it relies on the ->release() implementation.

Untwist the logic by freeing resources explicitly when swnode_register() fails. Currently it happens only in fwnode_create_software_node().

and

Quoted 81 lines

---
v2: no changes

 drivers/base/swnode.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/base/swnode.c +17 -12
index fa3719ef80e4..456f5fe58b58 100644
@@ -767,22 +767,19 @@ swnode_register(const struct software_node *node, struct swnode *parent,
 	int ret;
 
 	swnode = kzalloc(sizeof(*swnode), GFP_KERNEL);
-	if (!swnode) {
-		ret = -ENOMEM;
-		goto out_err;
-	}
+	if (!swnode)
+		return ERR_PTR(-ENOMEM);
 
 	ret = ida_simple_get(parent ? &parent->child_ids : &swnode_root_ids,
 			     0, 0, GFP_KERNEL);
 	if (ret < 0) {
 		kfree(swnode);
-		goto out_err;
+		return ERR_PTR(ret);
 	}
 
 	swnode->id = ret;
 	swnode->node = node;
 	swnode->parent = parent;
-	swnode->allocated = allocated;
 	swnode->kobj.kset = swnode_kset;
 	fwnode_init(&swnode->fwnode, &software_node_ops);
 
@@ -803,16 +800,17 @@ swnode_register(const struct software_node *node, struct swnode *parent,
 		return ERR_PTR(ret);
 	}
 
+	/*
+	 * Assign the flag only in the successful case, so
+	 * the above kobject_put() won't mess up with properties.
+	 */
+	swnode->allocated = allocated;
+
 	if (parent)
 		list_add_tail(&swnode->entry, &parent->children);
 
 	kobject_uevent(&swnode->kobj, KOBJ_ADD);
 	return &swnode->fwnode;
-
-out_err:
-	if (allocated)
-		property_entries_free(node->properties);
-	return ERR_PTR(ret);
 }
 
 /**
@@ -963,6 +961,7 @@ struct fwnode_handle *
 fwnode_create_software_node(const struct property_entry *properties,
 			    const struct fwnode_handle *parent)
 {
+	struct fwnode_handle *fwnode;
 	struct software_node *node;
 	struct swnode *p = NULL;
 	int ret;
@@ -987,7 +986,13 @@ fwnode_create_software_node(const struct property_entry *properties,
 
 	node->parent = p ? p->node : NULL;
 
-	return swnode_register(node, p, 1);
+	fwnode = swnode_register(node, p, 1);
+	if (IS_ERR(fwnode)) {
+		property_entries_free(node->properties);
+		kfree(node);
+	}
+
+	return fwnode;
 }
 EXPORT_SYMBOL_GPL(fwnode_create_software_node);
 
author reviewer
#7 lore raw

Re: [PATCH v2 5/6] software node: Introduce SOFTWARE_NODE_REFERENCE() helper macro

In reply to Daniel Scally
Quoted 5 lines · Daniel Scally
Quoted 4 lines · Andy Shevchenko

This is useful to assign software node reference with arguments in a common way. Moreover, we have already couple of users that may be converted. And by the fact, one of them is moved right here to use the helper.

...

Quoted 2 lines
Quoted 2 lines
drivers/base/test/property-entry-test.c +2 -0
+		SOFTWARE_NODE_REFERENCE(&nodes[0]),
+		SOFTWARE_NODE_REFERENCE(&nodes[1], 3, 4),

...

Quoted 6 lines
Quoted 6 lines
include/linux/property.h +6 -0
+#define SOFTWARE_NODE_REFERENCE(_ref_, ...)			\
+(const struct software_node_ref_args) {				\
+	.node = _ref_,						\
+	.nargs = ARRAY_SIZE(((u64[]){ 0, ##__VA_ARGS__ })) - 1,	\
+	.args = { __VA_ARGS__ },				\
+}

...

Quoted 8 lines

include/linux/property.h struct property_entry { · line 372

Quoted 1 line
include/linux/property.h +1 -0
+	{ .pointer = &SOFTWARE_NODE_REFERENCE(_ref_, ##__VA_ARGS__), },	\

What are the .args intended to be used for? I actually had it in mind to replace this with a simple pointer to a struct software_node, because I can't see any users of them and the fact that it's actually storing a pointer to a new variable is something that confused me for a good long time when I wrote the cio2-bridge (though that's mostly due to my relative inexperience of course, but still)

It's to be in align with DT phandle references that can take arguments. While for now, indeed, we have no users of this, it might be changed in the future (I hadn't checked DesignWare DMA where I would like to transform the code to
use device properties eventually and there it might be the case).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
reviewer Reviewed-by on v2 1/6
#11 lore raw
In reply to Andy Shevchenko
Quoted 8 lines · Andy Shevchenko

Currently we have a slightly twisted logic in swnode_register(). It frees resources that it doesn't allocate on error path and in once case it relies on the ->release() implementation.

Untwist the logic by freeing resources explicitly when swnode_register() fails. Currently it happens only in fwnode_create_software_node().

It all looks OK to me. FWIW, for the whole series:

Quoted 83 lines

---
v2: no changes

 drivers/base/swnode.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/base/swnode.c +17 -12
index fa3719ef80e4..456f5fe58b58 100644
@@ -767,22 +767,19 @@ swnode_register(const struct software_node *node, struct swnode *parent,
 	int ret;
 
 	swnode = kzalloc(sizeof(*swnode), GFP_KERNEL);
-	if (!swnode) {
-		ret = -ENOMEM;
-		goto out_err;
-	}
+	if (!swnode)
+		return ERR_PTR(-ENOMEM);
 
 	ret = ida_simple_get(parent ? &parent->child_ids : &swnode_root_ids,
 			     0, 0, GFP_KERNEL);
 	if (ret < 0) {
 		kfree(swnode);
-		goto out_err;
+		return ERR_PTR(ret);
 	}
 
 	swnode->id = ret;
 	swnode->node = node;
 	swnode->parent = parent;
-	swnode->allocated = allocated;
 	swnode->kobj.kset = swnode_kset;
 	fwnode_init(&swnode->fwnode, &software_node_ops);
 
@@ -803,16 +800,17 @@ swnode_register(const struct software_node *node, struct swnode *parent,
 		return ERR_PTR(ret);
 	}
 
+	/*
+	 * Assign the flag only in the successful case, so
+	 * the above kobject_put() won't mess up with properties.
+	 */
+	swnode->allocated = allocated;
+
 	if (parent)
 		list_add_tail(&swnode->entry, &parent->children);
 
 	kobject_uevent(&swnode->kobj, KOBJ_ADD);
 	return &swnode->fwnode;
-
-out_err:
-	if (allocated)
-		property_entries_free(node->properties);
-	return ERR_PTR(ret);
 }
 
 /**
@@ -963,6 +961,7 @@ struct fwnode_handle *
 fwnode_create_software_node(const struct property_entry *properties,
 			    const struct fwnode_handle *parent)
 {
+	struct fwnode_handle *fwnode;
 	struct software_node *node;
 	struct swnode *p = NULL;
 	int ret;
@@ -987,7 +986,13 @@ fwnode_create_software_node(const struct property_entry *properties,
 
 	node->parent = p ? p->node : NULL;
 
-	return swnode_register(node, p, 1);
+	fwnode = swnode_register(node, p, 1);
+	if (IS_ERR(fwnode)) {
+		property_entries_free(node->properties);
+		kfree(node);
+	}
+
+	return fwnode;
 }
 EXPORT_SYMBOL_GPL(fwnode_create_software_node);
 
Signature · 1 line
2.30.2

thanks,

Signature · 1 line
heikki
reviewer Reviewed-by Tested-by
#8 lore raw

Re: [PATCH v2 5/6] software node: Introduce SOFTWARE_NODE_REFERENCE() helper macro

In reply to Andy Shevchenko

Hi Andy

Quoted 11 lines · Andy Shevchenko
Quoted 7 lines

include/linux/property.h struct property_entry { · line 372

Quoted 1 line
include/linux/property.h +1 -0
+	{ .pointer = &SOFTWARE_NODE_REFERENCE(_ref_, ##__VA_ARGS__), },	\

What are the .args intended to be used for? I actually had it in mind to replace this with a simple pointer to a struct software_node, because I can't see any users of them and the fact that it's actually storing a pointer to a new variable is something that confused me for a good long time when I wrote the cio2-bridge (though that's mostly due to my relative inexperience of course, but still)

It's to be in align with DT phandle references that can take arguments. While for now, indeed, we have no users of this, it might be changed in the future (I hadn't checked DesignWare DMA where I would like to transform the code to
use device properties eventually and there it might be the case).

Ah yeah I see - haven't come across phandles before but having looked them up now I see what this is meant to emulate. Consistency is good; in that case, for this and 6/6:

and

Quoted 1 line
#12 lore raw
In reply to Heikki Krogerus
Quoted 6 lines · Heikki Krogerus
Quoted 4 lines · Andy Shevchenko

Currently we have a slightly twisted logic in swnode_register(). It frees resources that it doesn't allocate on error path and in once case it relies on the ->release() implementation.

Quoted 8 lines
Quoted 4 lines

Untwist the logic by freeing resources explicitly when swnode_register() fails. Currently it happens only in fwnode_create_software_node().

It all looks OK to me. FWIW, for the whole series:

Whole series applied (with some minor changelog edits) as 5.13 material, thanks!

author reviewer
#13 lore raw
Quoted 11 lines · Rafael J. Wysocki
Quoted 9 lines · Heikki Krogerus
Quoted 7 lines · Andy Shevchenko

Currently we have a slightly twisted logic in swnode_register(). It frees resources that it doesn't allocate on error path and in once case it relies on the ->release() implementation.

Untwist the logic by freeing resources explicitly when swnode_register() fails. Currently it happens only in fwnode_create_software_node().

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

It all looks OK to me. FWIW, for the whole series:

Whole series applied (with some minor changelog edits) as 5.13 material, thanks!

It seems Greg applied it already. Was it dropped there?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#14 lore raw
Quoted 15 lines · Andy Shevchenko
Quoted 13 lines · Rafael J. Wysocki
Quoted 11 lines · Heikki Krogerus
Quoted 8 lines · Andy Shevchenko

Currently we have a slightly twisted logic in swnode_register(). It frees resources that it doesn't allocate on error path and in once case it relies on the ->release() implementation.

Untwist the logic by freeing resources explicitly when swnode_register() fails. Currently it happens only in fwnode_create_software_node().

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

It all looks OK to me. FWIW, for the whole series:

Whole series applied (with some minor changelog edits) as 5.13 material, thanks!

It seems Greg applied it already. Was it dropped there?

Did he?

OK, so please let me know if it's still there in the Greg's tree.

author reviewer
#15 lore raw
Quoted 20 lines · Rafael J. Wysocki
Quoted 18 lines · Andy Shevchenko
Quoted 17 lines · Rafael J. Wysocki
Quoted 14 lines · Heikki Krogerus
Quoted 8 lines · Andy Shevchenko

Currently we have a slightly twisted logic in swnode_register(). It frees resources that it doesn't allocate on error path and in once case it relies on the ->release() implementation.

Untwist the logic by freeing resources explicitly when swnode_register() fails. Currently it happens only in fwnode_create_software_node().

It all looks OK to me. FWIW, for the whole series:

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Whole series applied (with some minor changelog edits) as 5.13 material, thanks!

It seems Greg applied it already. Was it dropped there?

Did he?

OK, so please let me know if it's still there in the Greg's tree.

Here [1] what I see. Seems still there.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=6e11b376fd74356e32d842be588e12dc9bf6e197

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#16 lore raw
Quoted 26 lines · Andy Shevchenko
Quoted 24 lines · Rafael J. Wysocki
Quoted 21 lines · Andy Shevchenko
Quoted 11 lines · Rafael J. Wysocki
Quoted 9 lines · Heikki Krogerus
Quoted 7 lines · Andy Shevchenko

Currently we have a slightly twisted logic in swnode_register(). It frees resources that it doesn't allocate on error path and in once case it relies on the ->release() implementation.

Untwist the logic by freeing resources explicitly when swnode_register() fails. Currently it happens only in fwnode_create_software_node().

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

It all looks OK to me. FWIW, for the whole series:

Whole series applied (with some minor changelog edits) as 5.13 material, thanks!

It seems Greg applied it already. Was it dropped there?

Quoted 7 lines
Quoted 3 lines

Did he?

OK, so please let me know if it's still there in the Greg's tree.

Here [1] what I see. Seems still there.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=6e11b376fd74356e32d842be588e12dc9bf6e197

I will not be applying it then, sorry for the confusion.