Re: [PATCH 1/3] driver core: add a faux bus for use when a simple device/bus is needed
From: Jonathan Cameron
Date: Tue Feb 04 2025 - 04:25:57 EST
On Mon, 3 Feb 2025 15:25:17 +0100
Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> Many drivers abuse the platform driver/bus system as it provides a
> simple way to create and bind a device to a driver-specific set of
> probe/release functions. Instead of doing that, and wasting all of the
> memory associated with a platform device, here is a "faux" bus that
> can be used instead.
>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Nice. One trivial thing inline.
> diff --git a/drivers/base/faux.c b/drivers/base/faux.c
> new file mode 100644
> index 000000000000..0eba89a5cd57
> --- /dev/null
> +++ b/drivers/base/faux.c
> @@ -0,0 +1,189 @@
> +int __init faux_bus_init(void)
> +{
> + int error;
> +
> + error = device_register(&faux_bus_root);
> + if (error) {
> + put_device(&faux_bus_root);
> + return error;
> + }
> +
> + error = bus_register(&faux_bus_type);
Odd bonus space after =
> + if (error)
> + device_unregister(&faux_bus_root);
> +
> + return error;
> +}