Deprecate the 'devclass' argument from *DRIVER_MODULE() macros.

This argument is useless for the vast majority of drivers.  For now,
use __VA_ARGS__ wrapper macros so that that the *DRIVER_MODULE()
macros accept both the old version (with a devclass) and the new
version (which omits the argument and stores NULL in the
driver_module_data structure).  This provides an API compatiblity
shim that can be merged to older stable branches.

Once all drivers relevant to 14.0 (both in and out of tree) have been
updated, the API compat shims can be dropped.

Reviewed by:	imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D34963
This commit is contained in:
John Baldwin 2022-04-19 10:43:06 -07:00
parent 5bdea8826b
commit 2a99dd30df
3 changed files with 64 additions and 22 deletions

View File

@ -42,10 +42,10 @@
.In sys/kernel.h
.In sys/bus.h
.In sys/module.h
.Fn DRIVER_MODULE name busname "driver_t driver" "devclass_t devclass" "modeventhand_t evh" "void *arg"
.Fn DRIVER_MODULE_ORDERED name busname "driver_t driver" "devclass_t devclass" "modeventhand_t evh" "void *arg" "int order"
.Fn EARLY_DRIVER_MODULE name busname "driver_t driver" "devclass_t devclass" "modeventhand_t evh" "void *arg" "int pass"
.Fn EARLY_DRIVER_MODULE_ORDERED name busname "driver_t driver" "devclass_t devclass" "modeventhand_t evh" "void *arg" "enum sysinit_elem_order order" "int pass"
.Fn DRIVER_MODULE name busname "driver_t driver" "modeventhand_t evh" "void *arg"
.Fn DRIVER_MODULE_ORDERED name busname "driver_t driver" "modeventhand_t evh" "void *arg" "int order"
.Fn EARLY_DRIVER_MODULE name busname "driver_t driver" "modeventhand_t evh" "void *arg" "int pass"
.Fn EARLY_DRIVER_MODULE_ORDERED name busname "driver_t driver" "modeventhand_t evh" "void *arg" "enum sysinit_elem_order order" "int pass"
.Sh DESCRIPTION
The
.Fn DRIVER_MODULE
@ -74,9 +74,9 @@ which is a pretty clean way of making front ends for different cards
using the same driver on the same or different buses.
For example, the following is allowed:
.Pp
.Fn DRIVER_MODULE foo isa foo_driver foo_devclass NULL NULL ;
.Fn DRIVER_MODULE foo isa foo_driver NULL NULL ;
.Pp
.Fn DRIVER_MODULE foo pci foo_driver foo_devclass NULL NULL ;
.Fn DRIVER_MODULE foo pci foo_driver NULL NULL ;
.Pp
.Fa driver
is the driver of type
@ -86,11 +86,6 @@ two most important parts of the call to
.Fn DRIVER_MODULE .
.Pp
The
.Fa devclass
argument contains the kernel-internal information about the device,
which will be used within the kernel driver module.
.Pp
The
.Fa evh
argument is the event handler which is called when the driver (or module)
is loaded or unloaded (see
@ -146,6 +141,13 @@ for a specific pass level.
.Xr module 9 ,
.Xr MODULE_PNP_INFO 9 ,
.Xr SYSINIT 9
.Sh HISTORY
Prior to
.Fx 14.0 ,
these macros accepted an additional
.Vt devclass_t
argument after
.Fa driver .
.Sh AUTHORS
This manual page was written by
.An Alexander Langer Aq Mt alex@FreeBSD.org .

View File

@ -67,9 +67,7 @@ static driver_t foo_driver = {
sizeof(struct foo_softc)
};
static devclass_t foo_devclass;
DRIVER_MODULE(foo, bogo, foo_driver, foo_devclass, NULL, NULL);
DRIVER_MODULE(foo, bogo, foo_driver, NULL, NULL);
.Ed
.Sh DESCRIPTION
Each driver in the kernel is described by a

View File

@ -800,14 +800,17 @@ struct driver_module_data {
int dmd_pass;
};
#define EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \
#define _DRIVER_MODULE_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, NAME, ...) \
NAME
#define _EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \
evh, arg, order, pass) \
\
static struct driver_module_data name##_##busname##_driver_mod = { \
evh, arg, \
#busname, \
(kobj_class_t) &driver, \
&devclass, \
devclass, \
pass \
}; \
\
@ -819,19 +822,58 @@ static moduledata_t name##_##busname##_mod = { \
DECLARE_MODULE(name##_##busname, name##_##busname##_mod, \
SI_SUB_DRIVERS, order)
#define EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, pass) \
EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \
#define EARLY_DRIVER_MODULE_ORDERED7(name, busname, driver, evh, arg, \
order, pass) \
_EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, NULL, evh, \
arg, order, pass)
#define EARLY_DRIVER_MODULE_ORDERED8(name, busname, driver, devclass, \
evh, arg, order, pass) \
_EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, &devclass, \
evh, arg, order, pass)
#define EARLY_DRIVER_MODULE_ORDERED(...) \
_DRIVER_MODULE_MACRO(__VA_ARGS__, EARLY_DRIVER_MODULE_ORDERED8, \
EARLY_DRIVER_MODULE_ORDERED7)(__VA_ARGS__)
#define EARLY_DRIVER_MODULE7(name, busname, driver, devclass, evh, arg, pass) \
EARLY_DRIVER_MODULE_ORDERED8(name, busname, driver, devclass, \
evh, arg, SI_ORDER_MIDDLE, pass)
#define DRIVER_MODULE_ORDERED(name, busname, driver, devclass, evh, arg,\
#define EARLY_DRIVER_MODULE6(name, busname, driver, evh, arg, pass) \
EARLY_DRIVER_MODULE_ORDERED7(name, busname, driver, evh, arg, \
SI_ORDER_MIDDLE, pass)
#define EARLY_DRIVER_MODULE(...) \
_DRIVER_MODULE_MACRO(__VA_ARGS__, INVALID, \
EARLY_DRIVER_MODULE7, EARLY_DRIVER_MODULE6)(__VA_ARGS__)
#define DRIVER_MODULE_ORDERED7(name, busname, driver, devclass, evh, arg,\
order) \
EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \
EARLY_DRIVER_MODULE_ORDERED8(name, busname, driver, devclass, \
evh, arg, order, BUS_PASS_DEFAULT)
#define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \
EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, \
#define DRIVER_MODULE_ORDERED6(name, busname, driver, devclass, evh, arg,\
order) \
EARLY_DRIVER_MODULE_ORDERED7(name, busname, driver, evh, arg, \
order, BUS_PASS_DEFAULT)
#define DRIVER_MODULE_ORDERED(...) \
_DRIVER_MODULE_MACRO(__VA_ARGS__, INVALID, \
DRIVER_MODULE_ORDERED7, DRIVER_MODULE_ORDERED6)(__VA_ARGS__)
#define DRIVER_MODULE6(name, busname, driver, devclass, evh, arg) \
EARLY_DRIVER_MODULE7(name, busname, driver, devclass, evh, arg, \
BUS_PASS_DEFAULT)
#define DRIVER_MODULE5(name, busname, driver, evh, arg) \
EARLY_DRIVER_MODULE6(name, busname, driver, evh, arg, \
BUS_PASS_DEFAULT)
#define DRIVER_MODULE(...) \
_DRIVER_MODULE_MACRO(__VA_ARGS__, INVALID, INVALID, \
DRIVER_MODULE6, DRIVER_MODULE5)(__VA_ARGS__)
/**
* Generic ivar accessor generation macros for bus drivers
*/