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
This commit is contained in:
John Baldwin 2022-04-19 10:42:38 -07:00
parent 434215c26d
commit 5bdea8826b

View File

@ -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);