git: 5493c6277a26 - main - LinuxKPI: pci.h MODULE_DEVICE_TABLE to MODULE_PNP_INFO
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 04 Mar 2022 00:39:53 UTC
The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=5493c6277a264e91ea4bdc7e2d4ee69fe4210918 commit 5493c6277a264e91ea4bdc7e2d4ee69fe4210918 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2022-03-04 00:06:34 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2022-03-04 00:12:45 +0000 LinuxKPI: pci.h MODULE_DEVICE_TABLE to MODULE_PNP_INFO Implement MODULE_PNP_INFO() support in LinuxKPI for the Linux MODULE_DEVICE_TABLE. This will allow us to auto-load LinuxKPI PCI drivers (drm-kmod do not currently as they attach to vgapci0 which in turn grabs the PCI to my understanding) and make any loading from loader or kld_list in rc.conf unnecessary; see devmatch(8) for more information. We need to ensure there is a DRIVER_MODULE() (or probably just a DECLARE_MODULE but that makes not much difference) before the MODULE_PNP_INFO (which we otherwise would not need). Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: imp, hselasky, manu Differential Revision: https://reviews.freebsd.org/D26651 --- sys/compat/linuxkpi/common/include/linux/pci.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 995a073c2b40..7bf785fb209a 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -41,6 +41,7 @@ #include <sys/param.h> #include <sys/bus.h> +#include <sys/module.h> #include <sys/nv.h> #include <sys/pciio.h> #include <sys/rman.h> @@ -69,7 +70,26 @@ struct pci_device_id { uintptr_t driver_data; }; -#define MODULE_DEVICE_TABLE(bus, table) +/* Linux has an empty element at the end of the ID table -> nitems() - 1. */ +#define MODULE_DEVICE_TABLE(_bus, _table) \ + \ +static device_method_t _ ## _bus ## _ ## _table ## _methods[] = { \ + DEVMETHOD_END \ +}; \ + \ +static driver_t _ ## _bus ## _ ## _table ## _driver = { \ + "lkpi_" #_bus #_table, \ + _ ## _bus ## _ ## _table ## _methods, \ + 0 \ +}; \ + \ +static devclass_t _ ## _bus ## _ ## _table ## _devclass; \ + \ +DRIVER_MODULE(lkpi_ ## _table, pci, _ ## _bus ## _ ## _table ## _driver,\ + _ ## _bus ## _ ## _table ## _devclass, 0, 0); \ + \ +MODULE_PNP_INFO("U32:vendor;U32:device;V32:subvendor;V32:subdevice", \ + _bus, lkpi_ ## _table, _table, nitems(_table) - 1) #define PCI_ANY_ID -1U