From 44a451ba24017543461111e62ffd51f9c6eff080 Mon Sep 17 00:00:00 2001 From: "Matthew N. Dodd" Date: Tue, 30 Nov 1999 07:06:03 +0000 Subject: [PATCH] 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 --- sys/kern/subr_bus.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 385e1de72b5..eff46ad3126 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