Re: [PATCH] software node: provide wrappers around kobject_get/put()

From: Bartosz Golaszewski

Date: Fri Apr 24 2026 - 09:46:40 EST


On Fri, Apr 24, 2026 at 3:33 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> 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)?
>

Typically yeah but nobody here would use it right now. I can change it
if you prefer it.

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

What do you mean?

> > 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'?
>

I'm not following either, please rephrase.

Bart