Re: [RFC 1/5] misc: introduce notify-device driver

From: Greg Kroah-Hartman
Date: Wed Oct 26 2022 - 10:38:07 EST


On Wed, Oct 26, 2022 at 03:15:30PM +0200, Matthias Schiffer wrote:
> A notify-device is a synchronization facility that allows to query
> "readiness" across drivers, without creating a direct dependency between
> the driver modules. The notify-device can also be used to trigger deferred
> probes.
>
> Signed-off-by: Matthias Schiffer <matthias.schiffer@xxxxxxxxxxxxxxx>
> ---
> drivers/misc/Kconfig | 4 ++
> drivers/misc/Makefile | 1 +
> drivers/misc/notify-device.c | 109 ++++++++++++++++++++++++++++++++++
> include/linux/notify-device.h | 33 ++++++++++
> 4 files changed, 147 insertions(+)
> create mode 100644 drivers/misc/notify-device.c
> create mode 100644 include/linux/notify-device.h
>
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index 358ad56f6524..63559e9f854c 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -496,6 +496,10 @@ config VCPU_STALL_DETECTOR
>
> If you do not intend to run this kernel as a guest, say N.
>
> +config NOTIFY_DEVICE
> + tristate "Notify device"
> + depends on OF
> +
> source "drivers/misc/c2port/Kconfig"
> source "drivers/misc/eeprom/Kconfig"
> source "drivers/misc/cb710/Kconfig"
> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> index ac9b3e757ba1..1e8012112b43 100644
> --- a/drivers/misc/Makefile
> +++ b/drivers/misc/Makefile
> @@ -62,3 +62,4 @@ obj-$(CONFIG_HI6421V600_IRQ) += hi6421v600-irq.o
> obj-$(CONFIG_OPEN_DICE) += open-dice.o
> obj-$(CONFIG_GP_PCI1XXXX) += mchp_pci1xxxx/
> obj-$(CONFIG_VCPU_STALL_DETECTOR) += vcpu_stall_detector.o
> +obj-$(CONFIG_NOTIFY_DEVICE) += notify-device.o
> diff --git a/drivers/misc/notify-device.c b/drivers/misc/notify-device.c
> new file mode 100644
> index 000000000000..42e0980394ea
> --- /dev/null
> +++ b/drivers/misc/notify-device.c
> @@ -0,0 +1,109 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +
> +#include <linux/device/class.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/notify-device.h>
> +#include <linux/platform_device.h>
> +#include <linux/slab.h>
> +
> +static void notify_device_release(struct device *dev)
> +{
> + of_node_put(dev->of_node);
> + kfree(dev);
> +}
> +
> +static struct class notify_device_class = {
> + .name = "notify-device",
> + .owner = THIS_MODULE,
> + .dev_release = notify_device_release,
> +};
> +
> +static struct platform_driver notify_device_driver = {

Ick, wait, this is NOT a platform device, nor driver, so it shouldn't be
either here. Worst case, it's a virtual device on the virtual bus.

But why is this a class at all? Classes are a representation of a type
of device that userspace can see, how is this anything that userspace
cares about?

Doesn't the device link stuff handle all of this type of "when this
device is done being probed, now I can" problems? Why is a whole new
thing needed?

thanks,

greg k-h