From 9937071c27b8397fd9a78cc456dabce5a2f1c120 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 22 Jul 2004 22:53:38 +0000 Subject: [PATCH] MFp4: Improve child_detached a little and make it conform better to style(9). Also, improve comment about what we'll be doing in the future about driver_added. Soon it will be possible to kldload usb drivers and have them attach w/o a need to disconnect/reconnect them. --- sys/dev/usb/uhub.c | 59 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c index 96cfdf24dab..37fe5c3caba 100644 --- a/sys/dev/usb/uhub.c +++ b/sys/dev/usb/uhub.c @@ -690,42 +690,41 @@ uhub_child_pnpinfo_str(device_t cbdev, device_t child, char *buf, Static void uhub_child_detached(device_t self, device_t child) { - struct uhub_softc *sc = device_get_softc(self); - usbd_device_handle devhub = sc->sc_hub; - usbd_device_handle dev; - int nports; - int port; - int i; - - if (!devhub->hub) - /* should never happen; children are only created after init */ - panic("hub not fully initialised, but child deleted?"); - - nports = devhub->hub->hubdesc.bNbrPorts; - for (port = 0; port < nports; port++) { - dev = devhub->hub->ports[port].device; - if (dev && dev->subdevs) { - for (i = 0; dev->subdevs[i]; i++) { - if (dev->subdevs[i] == child) { - dev->subdevs[i] = NULL; - return; - } - } - } - } + struct uhub_softc *sc = device_get_softc(self); + usbd_device_handle devhub = sc->sc_hub; + usbd_device_handle dev; + int nports; + int port; + int i; + + if (!devhub->hub) + /* should never happen; children are only created after init */ + panic("hub not fully initialised, but child deleted?"); + + nports = devhub->hub->hubdesc.bNbrPorts; + for (port = 0; port < nports; port++) { + dev = devhub->hub->ports[port].device; + if (dev == NULL || dev->subdevs == NULL) + continue; + for (i = 0; dev->subdevs[i]; i++) { + if (dev->subdevs[i] == child) { + dev->subdevs[i] = NULL; + return; + } + } + } } Static void uhub_driver_added(device_t _dev, driver_t *_driver) { - /* Don't do anything, as reprobing does not work currently. We should - * really call through to usbd_new_device or a function along those - * lines that reinitialises the device if it is not owned by any - * driver. But this is complicated. Manual replugging by the user is - * easier. + /* + * Don't do anything, as reprobing does not work currently. + * In the future we should properly allocate ivars so we can + * leave the devices attached to the newbus tree. Once we do + * that, then we can reprobe on driver loading with the + * default driver added routines. */ - - ; } #endif -- 2.45.2