On Thu, Mar 25, 2021 at 9:48 AM Jason Gunthorpe <jgg@xxxxxxxxxx> wrote: > > On Wed, Mar 24, 2021 at 01:00:04PM -0700, Dan Williams wrote: > > On Wed, Mar 24, 2021 at 12:58 PM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote: > > > > > > On Wed, Mar 24, 2021 at 10:01:42AM -0700, Dan Williams wrote: > > > > On Wed, Mar 24, 2021 at 9:52 AM Jason Gunthorpe <jgg@xxxxxxxxxx> wrote: > > > > > > > > > > On Wed, Mar 24, 2021 at 09:13:35AM -0700, Dan Williams wrote: > > > > > > > > > > > Which is just: > > > > > > > > > > > > device_initialize() > > > > > > dev_set_name() > > > > > > > > > > > > ...then the name is set as early as the device is ready to filled in > > > > > > with other details. Just checking for dev_set_name() failures does not > > > > > > move the api forward in my opinion. > > > > > > > > > > This doesn't work either as the release function must be set after > > > > > initialize but before dev_set_name(), otherwise we both can't and must > > > > > call put_device() after something like this fails. > > > > > > > > Ugh, true. > > > > > > > > > > > > > > I can't see an option other than bite the bullet and fix things. > > > > > > > > > > A static tool to look for these special lifetime rules around the > > > > > driver core would be nice. > > > > > > > > It would... it would also trip over the fact the core itself fails to > > > > check for dev_set_name() failures and also relies on !dev_name() as a > > > check after-the-fact. > > > > > > Where can I find the !dev_name() check? > > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/base/core.c#n3153 > > I would just add error checking here, it seems baffling not to have it > > Why didn't we use this simple device enumeration stuff for aux bus? Good question... ...but aux-bus may need to contend with namespace collisions across users, so that's why the modname prefix is forced in device names. Also how would aux-drivers differentiate what they attach to with a single bus provided name?