[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025021209-ultimate-dazzler-0e81@gregkh>
Date: Wed, 12 Feb 2025 08:39:12 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Kurt Borja <kuurtb@...il.com>
Cc: Zijun Hu <zijun_hu@...oud.com>, linux-kernel@...r.kernel.org,
Lyude Paul <lyude@...hat.com>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Danilo Krummrich <dakr@...nel.org>,
Alexander Lobakin <aleksander.lobakin@...el.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Liam Girdwood <lgirdwood@...il.com>, Lukas Wunner <lukas@...ner.de>,
Mark Brown <broonie@...nel.org>,
Maíra Canal <mairacanal@...eup.net>,
Robin Murphy <robin.murphy@....com>,
Simona Vetter <simona.vetter@...ll.ch>,
Zijun Hu <quic_zijuhu@...cinc.com>, linux-usb@...r.kernel.org,
rust-for-linux@...r.kernel.org,
Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Subject: Re: [PATCH v4 1/9] driver core: add a faux bus for use when a simple
device/bus is needed
On Tue, Feb 11, 2025 at 10:49:34AM -0500, Kurt Borja wrote:
> On Tue Feb 11, 2025 at 10:29 AM -05, Zijun Hu wrote:
> > On 2025/2/10 22:29, Kurt Borja wrote:
> >>> +
> >>> + ret = device_add(dev);
> >>> + if (ret) {
> >>> + pr_err("%s: device_add for faux device '%s' failed with %d\n",
> >>> + __func__, name, ret);
> >>> + put_device(dev);
> >>> + return NULL;
> >>> + }
> >> Now that the probe is synchronous, what do you think about returning
> >> -ENODEV if the device failed to bind to the driver?
> >>
> >
> > Result of device registering @ret is not, should not be, effected by
> > "device binding driver (probe result)"
> >
> > if device binging driver failed, you may return -ENODEV in
> > faux_ops->probe(). not here.
>
> After thinking about this discussion, I understand why this might be the
> expected behavior. I'm thinking about very simple modules that would
> remain loaded even if the probe fails. But of course this may cause
> problems to other modules.
>
> In the end, this is just my opinion so it would be up to Greg to decide.
> However, there is still an issue with the groups added to the device,
> which a user might expect they are tied to an "attached" device
> lifetime and this currently not the case.
I agree with you here, this could be confusing and cause problems, and
we should be creating apis that "work properly and simply". Having a
probe callback is good to add device data like you mention, so that you
can properly add the information before the sysfs files are accessed,
removing that race condition.
> >> This would be useful for modules that may want to unload if the probe
> >> fails.
> >
> > may need to root cause if probe failure happens.
> >
> > how to unload module automatically if probe() failure ?
>
> If we check for !dev->driver, a module might propagate an error to the
> module_init, thus making it fail to load.
Agreed. Thanks so much for your review comments, they are greatly
appreciated. When I get time next week I'll make these changes and send
out some patches.
thanks,
greg k-h
Powered by blists - more mailing lists