[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <18007239-f555-4225-b184-46baed8b89ee@lunn.ch>
Date: Thu, 21 Mar 2024 16:35:20 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
Russell King <linux@...linux.org.uk>,
Gregory Clement <gregory.clement@...tlin.com>,
netdev@...r.kernel.org
Subject: Re: [PATCH RFC 2/7] net: Add helpers for netdev LEDs
On Thu, Mar 21, 2024 at 08:01:55AM -0700, Jakub Kicinski wrote:
> On Sun, 17 Mar 2024 16:45:15 -0500 Andrew Lunn wrote:
> > + struct device *dev = &ndev->dev;
> > + struct netdev_led *netdev_led;
> > + struct led_classdev *cdev;
> > + u32 index;
> > + int err;
> > +
> > + netdev_led = devm_kzalloc(dev, sizeof(*netdev_led), GFP_KERNEL);
> > + if (!netdev_led)
> > + return -ENOMEM;
>
> Are we guaranteed to have a real bus device under ndev->dev ?
> I'm not aware of any use of devres in netdev core today.
devm_ does not require a real bus device. It just needs a struct
device. It does not care if it is physical or virtual. All it needs is
that something destroys the struct device using the usual device model
methods.
The struct device is actually part of struct net_device. It is not a
pointer to a bus device. We have register_netdevice() ->
netdev_register_kobject() -> device_initialize(). So the struct device
in struct net_device to registered to the driver core.
unregister_netdevice_many_notify() -> netdev_unregister_kobject() ->
device_del() -> devres_release_all().
So it also gets deleted from the driver core, at which point the
driver core will release all the resources.
So i don't see a reason why this should not work.
Andrew
Powered by blists - more mailing lists