Linux’s second-in-command Greg Kroah-Hartman is proposing “Faux Bus” as a new “fake” bus solution for simple devices.
Faux Bus is a proposal for simple solutions to allow devices to be created and automatically to it in cases where the device isn’t a “real” physical device or creating a platform device driver is considered overkill.
Greg KH explained in today’s request for comments on this Faux Bus patch series:
“For years/decades now, I’ve been complaining when I see people use platform devices for things that are obviously NOT platform devices. To finally fix this up, here is a “faux bus” that should be used instead of a platform device for these tiny and “fake” devices that people create all over the place.
The api is even simpler than the normal platform device api, just two functions, one to create a device and one to remove it. When a device is created, a driver is also created and automatically bound to it, which allows for the probe/release callbacks to work like expected. When finished with the device, just destroy it and all should be good.
This simple api should also hopefully provide for a simple rust binding to it given the simple rules and lifecycle of the pointer passed back from the creation function (i.e. it is alive and valid for as long as you have not called destroy on it.)
I’ve also converted two different examples of platform device abuse, the dummy regulator driver, and the USB phy code, to use this api. In both cases, the logic either was identical, or became simpler, than before, a good sign (side note, a bug was fixed in the usb phy code that no one ever noticed before).”
Transitioning the dummy regulator driver away from a real platform device driver to using the faux bus also ended up saving a few lines of code.
The Faux Bus code is now out for discussion as kernel developers consider landing this in a future version of the Linux kernel.