ChangeSet 1.883.3.15, 2002/12/17 22:22:16-08:00, david-b@pacbell.net [PATCH] hub driver uses dev_info(), less log clutter This patch converts most common hub diagnostics to use the device model diagnostic macros ... not all, someone should reduce the number of err() strings for "bogus hub" cases, and ideally streamline some of the dozen or so "here's what's special about this new hub" dbg() messages. So the messages become more useful: they id the port (and implicitly the device) involved, using a kernel-wide standard convention. Size overhead is smaller too. For folk running with USB debugging enabled, it also cuts the useless chatter on connections by deleting the per-poll success messages and a partial dup message when things change. And it deletes a newish diagnostic on a (non-hub) unlink path. It also makes Pete's new debounce message use the right port number -- one-based, not zero-based. My main issue with this patch is that it doesn't change more messages, but it seems reasonable to merge it anyway. diff -Nru a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c --- a/drivers/usb/core/hcd.c Wed Dec 18 00:34:16 2002 +++ b/drivers/usb/core/hcd.c Wed Dec 18 00:34:16 2002 @@ -389,8 +389,8 @@ break; case DeviceOutRequest | USB_REQ_SET_ADDRESS: // wValue == urb->dev->devaddr - dbg ("%s root hub device address %d", - hcd->self.bus_name, wValue); + dev_dbg (*hcd->controller, "root hub device address %d\n", + wValue); break; /* INTERFACE REQUESTS (no defined feature/status flags) */ @@ -1188,7 +1188,6 @@ if (urb->transfer_flags & URB_ASYNC_UNLINK) return -EINPROGRESS; - dev_dbg (*sys, "wait for giveback urb %p\n", urb); wait_for_completion (&splice.done); return 0; diff -Nru a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c --- a/drivers/usb/core/hub.c Wed Dec 18 00:34:16 2002 +++ b/drivers/usb/core/hub.c Wed Dec 18 00:34:16 2002 @@ -57,6 +57,12 @@ } #endif +/* for dev_info, dev_dbg, etc */ +static inline struct device *hubdev (struct usb_device *dev) +{ + return &dev->actconfig->interface [0].dev; +} + /* USB 2.0 spec Section 11.24.4.5 */ static int usb_get_hub_descriptor(struct usb_device *dev, void *data, int size) { @@ -298,7 +304,7 @@ } dev->maxchild = hub->descriptor->bNbrPorts; - info("%d port%s detected", dev->maxchild, + dev_info (*hubdev (dev), "%d port%s detected\n", dev->maxchild, (dev->maxchild == 1) ? "" : "s"); le16_to_cpus(&hub->descriptor->wHubCharacteristics); @@ -521,7 +527,7 @@ } /* We found a hub */ - info("USB hub found at %s", dev->devpath); + dev_info (*hubdev (dev), "USB hub found\n"); hub = kmalloc(sizeof(*hub), GFP_KERNEL); if (!hub) { @@ -651,8 +657,6 @@ else { *status = le16_to_cpu(portsts->wPortStatus); *change = le16_to_cpu(portsts->wPortChange); - dbg("port %d, portstatus %x, change %x, %s", port + 1, - *status, *change, portspeed(*status)); ret = 0; } kfree(portsts); @@ -710,8 +714,9 @@ if (delay_time >= 2 * HUB_SHORT_RESET_TIME) delay = HUB_LONG_RESET_TIME; - dbg("port %d of hub %s not reset yet, waiting %dms", port + 1, - hub->devpath, delay); + dev_dbg (*hubdev (hub), + "port %d not reset yet, waiting %dms\n", + port + 1, delay); } return -1; @@ -735,14 +740,15 @@ return status; } - dbg("port %d of hub %s not enabled, trying reset again...", - port + 1, hub->devpath); + dev_dbg (*hubdev (hub), + "port %d not enabled, trying reset again...\n", + port + 1); delay = HUB_LONG_RESET_TIME; } - err("Cannot enable port %i of hub %s, disabling port.", - port + 1, hub->devpath); - err("Maybe the USB cable is bad?"); + dev_err (*hubdev (hub), + "Cannot enable port %i. Maybe the USB cable is bad?\n", + port + 1); return -1; } @@ -808,8 +814,9 @@ } /* XXX Replace this with dbg() when 2.6 is about to ship. */ - info("debounce: hub %d port %d: delay %dms stable %d status 0x%x\n", - hub->devnum, port, delay_time, stable_count, portstatus); + dev_info (*hubdev (hub), + "debounce: port %d: delay %dms stable %d status 0x%x\n", + port + 1, delay_time, stable_count, portstatus); return ((portstatus&USB_PORT_STAT_CONNECTION)) ? 0 : 1; } @@ -822,9 +829,9 @@ unsigned int delay = HUB_SHORT_RESET_TIME; int i; - dbg("hub %s port %d, portstatus %x, change %x, %s", - hub->devpath, port + 1, - portstatus, portchange, portspeed (portstatus)); + dev_dbg (hubstate->intf->dev, + "port %d, status %x, change %x, %s\n", + port + 1, portstatus, portchange, portspeed (portstatus)); /* Clear the connection change status */ usb_clear_port_feature(hub, port + 1, USB_PORT_FEAT_C_CONNECTION); @@ -842,7 +849,9 @@ } if (usb_hub_port_debounce(hub, port)) { - err("connect-debounce failed, port %d disabled", port+1); + dev_err (hubstate->intf->dev, + "connect-debounce failed, port %d disabled\n", + port+1); usb_hub_port_disable(hub, port); return; } @@ -861,7 +870,8 @@ /* Allocate a new device struct */ dev = usb_alloc_dev(hub, hub->bus); if (!dev) { - err("couldn't allocate usb_device"); + dev_err (hubstate->intf->dev, + "couldn't allocate usb_device\n"); break; } @@ -904,10 +914,12 @@ len = snprintf (dev->devpath, sizeof dev->devpath, "%d", port + 1); if (len == sizeof dev->devpath) - warn ("devpath size! usb/%03d/%03d path %s", + dev_err (hubstate->intf->dev, + "devpath size! usb/%03d/%03d path %s\n", dev->bus->busnum, dev->devnum, dev->devpath); - info("new USB device %s-%s, assigned address %d", - dev->bus->bus_name, dev->devpath, dev->devnum); + dev_info (hubstate->intf->dev, + "new USB device on port %d, assigned address %d\n", + port + 1, dev->devnum); /* put the device in the global device tree. the hub port * is the "bus_id"; hubs show in hierarchy like bridges @@ -992,12 +1004,11 @@ } if (portchange & USB_PORT_STAT_C_CONNECTION) { - dbg("hub %s port %d connection change", - dev->devpath, i + 1); usb_hub_port_connect_change(hub, i, portstatus, portchange); } else if (portchange & USB_PORT_STAT_C_ENABLE) { - dbg("hub %s port %d enable change, status %x", - dev->devpath, i + 1, portstatus); + dev_dbg (*hubdev (dev), + "port %d enable change, status %x\n", + i + 1, portstatus); usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_ENABLE);