Re: [PATCH] software node: provide wrappers around kobject_get/put()
From: Andy Shevchenko
Date: Fri Apr 24 2026 - 09:33:21 EST
On Fri, Apr 24, 2026 at 02:42:50PM +0200, Bartosz Golaszewski wrote:
> Make the code more readable by avoid constant dereferencing of the
> swnode's kobject when managing references. Provide wrappers that take
> struct swnode * as argument and make them hide that logic.
...
> +static void swnode_get(struct swnode *swnode)
> +{
> + kobject_get(&swnode->kobj);
> +}
Isn't a pattern to return the object itself so the code can bump the reference
in a single statement (if appropriate)?
...
> static struct fwnode_handle *software_node_get(struct fwnode_handle *fwnode)
> {
> struct swnode *swnode = to_swnode(fwnode);
>
> - kobject_get(&swnode->kobj);
> + swnode_get(swnode);
Like
struct swnode *swnode = swnode_get(to_swnode(fwnode));
> return &swnode->fwnode;
> }
...
> list_for_each_entry(child, &swnode->children, entry) {
> if (!strcmp(childname, kobject_name(&child->kobj))) {
> - kobject_get(&child->kobj);
> + swnode_get(child);
Becomes inconsistent with kobject_name()...
> return &child->fwnode;
> }
> }
...
> swnode = kobj_to_swnode(k);
> if (parent == swnode->node->parent && swnode->node->name &&
> !strcmp(name, swnode->node->name)) {
> - kobject_get(&swnode->kobj);
> + swnode_get(swnode);
Also not sure. Maybe use 'k'?
> break;
> }
...
Otherwise LGTM and makes sense.
--
With Best Regards,
Andy Shevchenko