git: 5bdea8826bdd - main - devclass_add_driver: Permit NULL to be passed in dcp.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 19 Apr 2022 17:45:43 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=5bdea8826bdd48e2221f1b436ce86021ede412f2 commit 5bdea8826bdd48e2221f1b436ce86021ede412f2 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2022-04-19 17:42:38 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2022-04-19 17:43:50 +0000 devclass_add_driver: Permit NULL to be passed in dcp. This permits a driver module structure that doesn't want to store a pointer to the new driver's devclass. Reviewed by: imp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D34962 --- sys/kern/subr_bus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 416353566306..3be468fd7c43 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -1140,6 +1140,7 @@ int devclass_add_driver(devclass_t dc, driver_t *driver, int pass, devclass_t *dcp) { driverlink_t dl; + devclass_t child_dc; const char *parentname; PDEBUG(("%s", DRIVERNAME(driver))); @@ -1171,7 +1172,9 @@ devclass_add_driver(devclass_t dc, driver_t *driver, int pass, devclass_t *dcp) parentname = driver->baseclasses[0]->name; else parentname = NULL; - *dcp = devclass_find_internal(driver->name, parentname, TRUE); + child_dc = devclass_find_internal(driver->name, parentname, TRUE); + if (dcp != NULL) + *dcp = child_dc; dl->driver = driver; TAILQ_INSERT_TAIL(&dc->drivers, dl, link);