LinuxKPI: move MODULE_DEVICE_TABLE from pci.h to module.h

Move the MODULE_DEVICE_TABLE macro to module.h where it belongs
in preparation for different bus (e.g., USB, SDIO) support.
The various struct <bus>_device_id, if not elsewhere, should be
defined in mod_devicetable.h.

This is the next step after 2f5666c172.

No functional changes.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste, dumbbell
Differential Revision: https://reviews.freebsd.org/D54900
This commit is contained in:
Bjoern A. Zeeb committed 2026-02-09 21:49:44 +00:00
1 parent 1f19fc2632
commit 1f4fbcf342
2 files changed
+18 -18

No files matched your search

@@ -53,6 +53,24 @@
#define MODULE_SUPPORTED_DEVICE(name)
#define MODULE_IMPORT_NS(_name)
/* 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 \
}; \
\
DRIVER_MODULE(lkpi_ ## _table, _bus, _ ## _bus ## _ ## _table ## _driver,\
0, 0); \
\
MODULE_DEVICE_TABLE_BUS_ ## _bus(_bus, _table)
/*
* THIS_MODULE is used to differentiate modules on Linux. We currently
* completely stub out any Linux struct module usage, but THIS_MODULE is still
@@ -76,24 +76,6 @@ struct pci_device_id {
MODULE_PNP_INFO("U32:vendor;U32:device;V32:subvendor;V32:subdevice", \
_bus, lkpi_ ## _table, _table, nitems(_table) - 1)
/* 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 \
}; \
\
DRIVER_MODULE(lkpi_ ## _table, _bus, _ ## _bus ## _ ## _table ## _driver,\
0, 0); \
\
MODULE_DEVICE_TABLE_BUS_ ## _bus(_bus, _table)
#define PCI_ANY_ID -1U
#define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))