The branch stable/13 has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a94b233d5d718258e2e57e114aab00714441a79f

commit a94b233d5d718258e2e57e114aab00714441a79f
Author:     Bjoern A. Zeeb <[email protected]>
AuthorDate: 2022-03-04 00:06:34 +0000
Commit:     Bjoern A. Zeeb <[email protected]>
CommitDate: 2022-03-27 18:08:08 +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
    Reviewed by:    imp, hselasky, manu
    Differential Revision:  https://reviews.freebsd.org/D26651
    
    (cherry picked from commit 5493c6277a264e91ea4bdc7e2d4ee69fe4210918)
---
 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 df18c98a6278..361600a55397 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
 

Reply via email to