summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>1999-11-30 07:06:03 +0000
committermdodd <mdodd@FreeBSD.org>1999-11-30 07:06:03 +0000
commitea4e794bb807fdbcfd6db950211fb87d26d00292 (patch)
tree81632ef9003642427a49ecd6f8ea3bb962faac35 /sys/kern
parent679b553dfa3bff9c4f61583330de3dcc30c5167d (diff)
downloadFreeBSD-src-ea4e794bb807fdbcfd6db950211fb87d26d00292.zip
FreeBSD-src-ea4e794bb807fdbcfd6db950211fb87d26d00292.tar.gz
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
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_bus.c14
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
OpenPOWER on IntegriCloud