All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <brgl@kernel.org>
Cc: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
	Daniel Scally <djrscally@gmail.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	linux-acpi@vger.kernel.org, driver-core@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] software node: provide wrappers around kobject_get/put()
Date: Fri, 24 Apr 2026 18:32:33 +0300	[thread overview]
Message-ID: <aeuNEYymSicUcMyZ@ashevche-desk.local> (raw)
In-Reply-To: <CAMRc=Mem3m8JZXafL9xrUvWZWuFaCofkNEdVYLNMgC+3N0i21g@mail.gmail.com>

On Fri, Apr 24, 2026 at 03:43:39PM +0200, Bartosz Golaszewski wrote:
> On Fri, Apr 24, 2026 at 3:33 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Fri, Apr 24, 2026 at 02:42:50PM +0200, Bartosz Golaszewski wrote:

...

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

I showed below the example (it's now cut from the context).

...

> > >       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;
> > >               }
> > >       }

The same piece of code uses kobj and child either way of this conversion happen
or not. To be fully consistent we need something like swnode_match_name() or
alike instead of that strcmp().

...

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

                     kobject_get(k);

should also work. And here I referred to the fact that we already have a kobject
instance available. Yes, my counter example is just to reveal inconsistency,
I kinda agree that using swnode specific API might be clearer approach.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-04-24 15:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24 12:42 [PATCH] software node: provide wrappers around kobject_get/put() Bartosz Golaszewski
2026-04-24 13:33 ` Andy Shevchenko
2026-04-24 13:43   ` Bartosz Golaszewski
2026-04-24 15:32     ` Andy Shevchenko [this message]
2026-04-27  8:15       ` Bartosz Golaszewski
2026-04-27  8:34         ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aeuNEYymSicUcMyZ@ashevche-desk.local \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=dakr@kernel.org \
    --cc=djrscally@gmail.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.