Reduce code duplication.

Hopefully this clears up some confusion about the nature of
devclass_get_softc() vs. device_get_softc() as well.

The check against DS_ATTACHED remains as this is not
a change that modifies functionality.

Reviewed by:	Peter "in principle" Wemm
This commit is contained in:
Matthew N. Dodd 1999-11-30 07:06:03 +00:00
parent 98733bd871
commit 44a451ba24
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=53938

View File

@ -432,12 +432,14 @@ devclass_get_softc(devclass_t dc, int unit)
{
device_t dev;
if (unit < 0 || unit >= dc->maxunit)
return NULL;
dev = dc->devices[unit];
if (!dev || dev->state < DS_ATTACHED)
return NULL;
return dev->softc;
dev = devclass_get_device(dc, unit);
if (!dev)
return (NULL);
if (device_get_state(dev) < DS_ATTACHED)
return (NULL);
return (device_get_softc(dev));
}
int