diff options
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r-- | sys/kern/subr_bus.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 385e1de..eff46ad 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -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 |