netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andrew Lunn <andrew@lunn.ch>, Pavel Machek <pavel@ucw.cz>,
	"linux-leds@vger.kernel.org" <linux-leds@vger.kernel.org>,
	netdev@vger.kernel.org,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: are device names part of sysfs ABI? (was Re: devicename part of LEDs under ethernet MAC / PHY)
Date: Mon, 4 Oct 2021 09:25:24 +0200	[thread overview]
Message-ID: <20211004092524.023df950@thinkpad> (raw)
In-Reply-To: <YVqo64vS4ox9P9hk@kroah.com>

On Mon, 4 Oct 2021 09:10:35 +0200
Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:

> On Mon, Oct 04, 2021 at 09:04:38AM +0200, Marek Behún wrote:
> > Hi Greg,
> > 
> > On Mon, 4 Oct 2021 08:37:37 +0200
> > Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> >   
> > > On Sun, Oct 03, 2021 at 10:53:38PM +0200, Marek Behún wrote:  
> > > > Hello Greg,
> > > > 
> > > > could you give your opinion on this discussion?    
> > > 
> > > What discussion?  Top posting ruins that :(  
> > 
> > Sorry, the discussion is here
> > https://lore.kernel.org/linux-leds/20211001144053.3952474a@thinkpad/T/
> > But the basic question is below, so you don't need to read the
> > discussion.
> >   
> > > > Are device names (as returned by dev_name() function) also part of
> > > > sysfs ABI? Should these names be stable across reboots / kernel
> > > > upgrades?    
> > > 
> > > Stable in what exact way?  
> > 
> > Example:
> > - Board has an ethernet PHYs that is described in DT, and therefore
> >   has stable sysfs path (derived from DT path), something like
> >     /sys/devices/.../mdio_bus/f1072004.mdio-mii/f1072004.mdio-mii:01  
> 
> None of the numbers there are "stable", right?
> 
> > - The PHY has a subnode describing a LED.
> >   The LED subsystem has a different naming scheme (it uses DT node name
> >   as a last resort). When everything is okay, the dev_name() of the LED
> >   will be something like
> >     ethphy42:green:link  
> 
> Wonderful, but the "42" means nothing.
> 
> > - Now suppose that the PHY driver is unloaded and loaded again. The PHY
> >   sysfs path is unchanged, but the LED will now be named
> >     ethphy43:green:link
> > 
> > Is this OK?  
> 
> Yup!
> 
> The "link" should point to the device it is associated with, right?  You
> need to have some way to refer to the device.
> 
> > > Numbering of devices (where a dynamic value is part of a name, like the
> > > "42" in "usb42"), is never guaranteed to be stable, but the non-number
> > > part of the name (like "usb" is in "usb42") is stable, as that is what
> > > you have properly documented in the Documentation/ABI/ files defining
> > > the bus and class devices, right?  
> > 
> > It does make sense for removable devices like USB. What I am asking
> > is whether it is also OK for devices that have stable DT nodes.  
> 
> Any device can be "removed" from the system and added back thanks to the
> joy of the driver model :)
> 
> Also, what prevents your DT from renumbering things in an update to it
> in the future?  The kernel doesn't care, and userspace should be able to
> handle it.
> 
> Again, any numbering scheme is NEVER stable, just because it feels like
> it is at the moment for your device, you should NEVER rely on that, but
> instead rely on the attributes of the device to determine what it is and
> where it is in the device hierarchy (serial number, position location,
> partition name, etc.) in order to know what it associated with.
> 
> And again, this is 1/2 of the whole reason _why_ we created the unified
> driver model in the kernel.  Don't try to go back to the nightmare that
> we had in the 2.4 and earlier kernel days please.

OK, thanks Greg. This simplifies things. I shall send another version
of LEDs under ethernet PHYs soon :)

Marek

  reply	other threads:[~2021-10-04  7:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 11:30 devicename part of LEDs under ethernet MAC / PHY Marek Behún
2021-10-01 12:29 ` Andrew Lunn
2021-10-01 12:40   ` Marek Behún
2021-10-03 20:53     ` are device names part of sysfs ABI? (was Re: devicename part of LEDs under ethernet MAC / PHY) Marek Behún
2021-10-04  6:37       ` Greg Kroah-Hartman
2021-10-04  7:04         ` Marek Behún
2021-10-04  7:10           ` Greg Kroah-Hartman
2021-10-04  7:25             ` Marek Behún [this message]
2021-10-04  7:38             ` Pavel Machek
2021-10-04  8:30               ` Greg Kroah-Hartman
2021-10-04 12:14                 ` Andrew Lunn

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=20211004092524.023df950@thinkpad \
    --to=kabel@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=gregkh@linuxfoundation.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).