On Wed, Aug 14, 2024 at 06:10:03PM +0800, Chen-Yu Tsai wrote: > On Tue, Aug 13, 2024 at 7:46 PM Andy Shevchenko > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote: > > On Thu, Aug 08, 2024 at 05:59:28PM +0800, Chen-Yu Tsai wrote: ... > > > +static void chromeos_of_hw_prober_driver_exit(void) > > > +{ > > > + if (!chromeos_of_hw_prober_pdev) > > > + return; > > > > First of all, this is dup for the next call, second, when may this conditional > > be true? > > When the module is loaded on a machine that doesn't match any entry, > neither the driver nor the device are registered. Hence the check. > > Or maybe the proper way to handle it is to return -ENODEV or something? > I'll work towards that. The rule of thumb is the _exit() is called when your _init() finished with success. This conditional seems confusing and likely reveals the logic issue in _init(). Yes, _init() needs to return an error when there is no devices are registered or expected to be registered. If there are devices that may appear later on, this should be split to pure device driver and board file that instantiate device for the known cases. > > > + platform_device_unregister(chromeos_of_hw_prober_pdev); > > > + platform_driver_unregister(&chromeos_of_hw_prober_driver); > > > +} -- With Best Regards, Andy Shevchenko