Re: [PATCH] mfd: Add Simple PCI MFD driver

From: Lee Jones
Date: Mon Jan 23 2023 - 10:33:06 EST


On Mon, 23 Jan 2023, Vincent Whitchurch wrote:

> Add a PCI driver which registers all child nodes specified in the
> devicetree. It will allow platform devices to be used on virtual
> systems which already support PCI and devicetree, such as UML with
> virt-pci.
>
> The driver has no id_table by default; user space needs to provide one
> using the new_id mechanism in sysfs.

This feels wrong for several reasons.

Firstly, I think Greg (Cc:ed) will have something to say about this.

Secondly, this driver does literally nothing. Why can't you use of of
the other, pre-existing "also register my children" compatibles?

See: drivers/bus/simple-pm-bus.c
drivers/of/platform.c

> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@xxxxxxxx>
> ---
> drivers/mfd/Kconfig | 11 +++++++++++
> drivers/mfd/Makefile | 1 +
> drivers/mfd/simple-mfd-pci.c | 21 +++++++++++++++++++++
> 3 files changed, 33 insertions(+)
>
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 30db49f31866..1e325334e9ae 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -1277,6 +1277,17 @@ config MFD_SIMPLE_MFD_I2C
> sub-devices represented by child nodes in Device Tree will be
> subsequently registered.
>
> +config MFD_SIMPLE_MFD_PCI
> + tristate "Simple Multi-Functional Device support (PCI)"
> + depends on PCI
> + depends on OF || COMPILE_TEST
> + help
> + This enables support for a PCI driver for which any sub-devices
> + represented by child nodes in the devicetree will be registered.
> +
> + The driver does not bind to any devices by default; that should
> + be done via sysfs using new_id.
> +
> config MFD_SL28CPLD
> tristate "Kontron sl28cpld Board Management Controller"
> depends on I2C
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 457471478a93..7ae329039a13 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -268,6 +268,7 @@ obj-$(CONFIG_MFD_QCOM_PM8008) += qcom-pm8008.o
>
> obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o
> obj-$(CONFIG_MFD_SIMPLE_MFD_I2C) += simple-mfd-i2c.o
> +obj-$(CONFIG_MFD_SIMPLE_MFD_PCI) += simple-mfd-pci.o
> obj-$(CONFIG_MFD_SMPRO) += smpro-core.o
> obj-$(CONFIG_MFD_INTEL_M10_BMC) += intel-m10-bmc.o
>
> diff --git a/drivers/mfd/simple-mfd-pci.c b/drivers/mfd/simple-mfd-pci.c
> new file mode 100644
> index 000000000000..c5b2540e924a
> --- /dev/null
> +++ b/drivers/mfd/simple-mfd-pci.c
> @@ -0,0 +1,21 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include <linux/module.h>
> +#include <linux/of_platform.h>
> +#include <linux/pci.h>
> +
> +static int simple_mfd_pci_probe(struct pci_dev *pdev,
> + const struct pci_device_id *id)
> +{
> + return devm_of_platform_populate(&pdev->dev);
> +}
> +
> +static struct pci_driver simple_mfd_pci_driver = {
> + /* No id_table, use new_id in sysfs */
> + .name = "simple-mfd-pci",
> + .probe = simple_mfd_pci_probe,
> +};
> +
> +module_pci_driver(simple_mfd_pci_driver);
> +
> +MODULE_LICENSE("GPL");
>
> ---
> base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
> change-id: 20230120-simple-mfd-pci-54f0d9b90dfc
>
> Best regards,
> --
> Vincent Whitchurch <vincent.whitchurch@xxxxxxxx>

--
Lee Jones [李琼斯]